Skip to content
Snippets Groups Projects
Commit f51c1baa authored by cristiano's avatar cristiano
Browse files

Finished Integration Tests

parent aadd1b6e
No related branches found
Tags v3.0
No related merge requests found
boolean addBid(Bid bid)
{
if(bid.price > currentHighestBid.price && (bid.price - currentHighestBid.price) >= bidIncrement)
{
listOfBids.add(bid);
currentHighestBid = bid;
return true;
}
return false;
}
......@@ -110,12 +110,6 @@ public class Auction {
}
public Date getStart() {
return start;
}
public double getPrice() {
return price;
......@@ -138,17 +132,11 @@ public class Auction {
this.end = endDate;
}
public Seller getSeller() {
return seller;
}
public void setSeller(Seller seller) {
this.seller = seller;
}
public ArrayList<Bid> getBids() {
return bids;
}
......@@ -156,10 +144,6 @@ public class Auction {
public void setBids(ArrayList<Bid> bids) {
this.bids = bids;
}
public void setBidIncrement(double bidIncrement) {
this.bidIncrement = bidIncrement;
}
public double getBidIncrement() {
return bidIncrement;
......
......@@ -83,12 +83,6 @@ public class AuctionManager {
return false;
}
public void computePrice(Bid bid) {
auction.setPrice(bid.getValue() + auction.getPrice());
}
public static Date parseDate(String value) {
Date date = null;
......
......@@ -8,33 +8,24 @@ public class Bid {
private int value;
private User user;
private Auction auction;
public Bid(Date d, int value, User user, Auction auction) {
this.user = user;
this.value = value;
this.date = d;
this.auction = auction;
}
public Bid() {
}
public Bid getInstance() {
return new Bid();
}
public int getValue() {
return value;
}
public Date getDate() {
return date;
}
public Auction getAuction() {
return auction;
}
}
......@@ -71,12 +71,6 @@ public class Item {
}
public ArrayList<Auction> getAuctionHistory() {
return null;
}
public static Item getItem(int item) {
for (Item i : items) {
......@@ -149,12 +143,6 @@ public class Item {
return id;
}
public void setOwner(int newOwner) {
this.userOwner = newOwner;
}
public String getTitle() {
return this.title;
......
......@@ -55,14 +55,5 @@ public class ItemPicture {
return null;
}
public void setItem(Item item) {
this.item = item;
}
public static ItemPicture getInstance() {
return new ItemPicture();
}
}
......@@ -147,15 +147,4 @@ public class Seller extends User {
}
public void setMyAuctions(ArrayList<Auction> sellerAuctions) {
this.myAuctions = sellerAuctions;
}
public ArrayList<Auction> displayMyAuctions() {
return this.myAuctions;
}
}
......@@ -149,12 +149,6 @@ public class User {
}
public ArrayList<Auction> retrieveSubscribedAuction() {
return null;
}
public ArrayList<Item> searchItem(String title, String category)
throws CategoryInvalidException, TitleInvalidException {
......
......@@ -200,37 +200,29 @@ public class AuctionManagerUnitTest {
}
@TestFactory
public Collection<DynamicTest> externalAddBidTest() {
public Collection<DynamicTest> externalAddBidTestFalse() {
Auction auction = Auction.getInstance();
User user = User.getInstance();
AuctionManager manager = AuctionManager.getInstance();
ArrayList<Double> prices = new ArrayList<Double>();
ArrayList<Integer> values = new ArrayList<Integer>();
manager.setAuction(auction);
for(int i = 1; i < 11; i++) {
prices.add((double) i);
values.add(11-i); // reverse values in order to have half list working and half not
for(int i = 1; i < 6; i++) {
values.add(i);
}
Collection<DynamicTest> dynamicTests = new ArrayList<DynamicTest>();
for (int e = 0; e < 10; e++) {
for (int e = 0; e < 5; e++) {
DynamicTest dTest;
auction.setPrice(prices.get(e));
auction.setPrice(10);
int toCheck = values.get(e);
if (toCheck > 5) {
Executable exec = () -> assertTrue(manager.placeBid(user, toCheck));
dTest = DynamicTest.dynamicTest("Bigger bid than current auction price", exec);
} else {
Executable exec = () -> assertFalse(manager.placeBid(user, toCheck));
dTest = DynamicTest.dynamicTest("Lower bid than current auction price", exec);
}
Executable exec = () -> assertFalse(manager.placeBid(user, toCheck));
dTest = DynamicTest.dynamicTest("Lower bid than current auction price", exec);
dynamicTests.add(dTest);
}
......@@ -238,5 +230,21 @@ public class AuctionManagerUnitTest {
return dynamicTests;
}
@ParameterizedTest
@ValueSource(ints = { 2, 3, 4, 5, 6 })
public void externalAddBidTrue(int toCheck) throws BidBelowZeroException, ParseException {
Auction auction = Auction.getInstance();
User user = User.getInstance();
AuctionManager manager = AuctionManager.getInstance();
auction.setPrice(1);
manager.setAuction(auction);
assertTrue(manager.placeBid(user, toCheck));
}
}
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>gmmm</groupId>
<artifactId>gmmm</artifactId>
<version>0.0.1-SNAPSHOT</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>AuctionManager</groupId>
<artifactId>it.unibz.inf.bl.AuctionManager</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>
${basedir}\resources\AuctionSystemPublic.jar
</systemPath>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>8</source>
<target>8</target>
<testSource>8</testSource>
<testTarget>8</testTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
<dependencies>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-surefire-provider</artifactId>
<version>1.2.0</version>
</dependency>
</dependencies>
<configuration>
<FailureIgnore>true</FailureIgnore>
<excludes>
<exclude>fixture/*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>unit</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>fixture/*</exclude>
<exclude>**/AuctionUnitTest.java</exclude>
<exclude>**/integration/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>fixture/*</exclude>
<exclude>**/gmmm/**</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>unit_integration</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>fixture/*</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment