Skip to content
Snippets Groups Projects
Commit 3c42e093 authored by Lucian Cristiano (Student Com17)'s avatar Lucian Cristiano (Student Com17) :battery:
Browse files

Merge branch 'integrationTesting' into 'master'

Integration testing

See merge request TTST1920/clar!5
parents 66b9bf76 1c7e5fbd
No related branches found
Tags v3.0
No related merge requests found
Showing
with 428 additions and 84 deletions
<?xml version="1.0" encoding="UTF-8"?>
<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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>clar.team</groupId>
<artifactId>clar</artifactId>
<version>2.0</version>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.1</version>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.5</version>
<executions>
<execution>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>unit</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>AuctionManagerIntegrationTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>integration</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>AuctionManagerUnitTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>regression</id>
<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>AuctionManagerUnitTest.java</exclude>
<exclude>AuctionManagerIntegrationTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>Auction</groupId>
<artifactId>it.unibz.Auction</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>C:\Users\Utente\Documents\clar\EclipseProject\resources\AuctionSystemPublic.jar</systemPath>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.5.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>opentest4j</artifactId>
<groupId>org.opentest4j</groupId>
</exclusion>
<exclusion>
<artifactId>junit-platform-commons</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<artifactId>junit-platform-engine</artifactId>
<groupId>org.junit.platform</groupId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<properties>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>1.8</maven.compiler.source>
</properties>
</project>
<profiles>
<profile>
<id>unit</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*IntegrationTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
</profiles>
......@@ -3,8 +3,9 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<artifactId>clar</artifactId>
<groupId>clar.team</groupId>
<version>1.0.0-SNAPSHOT</version>
<version>2.1</version>
<modelVersion>4.0.0</modelVersion>
<packaging>jar</packaging>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
......@@ -13,6 +14,15 @@
<dependencies>
<!-- https://mvnrepository.com/artifact/org.junit.jupiter/junit-jupiter -->
<dependency>
<groupId>Auction</groupId>
<artifactId>it.unibz.Auction</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>
${basedir}\resources\AuctionSystemPublic.jar
</systemPath>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
......@@ -66,6 +76,68 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
</execution>
</executions>
</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>AuctionManagerIntegrationTest.java</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>*/**UnitTest.java</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>regression</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
\ No newline at end of file
File added
......@@ -8,17 +8,19 @@ public class Auction {
static int idCounter;
public static ArrayList<Auction> auctions = new ArrayList<Auction>();
private ArrayList<User> subscribedUsers = new ArrayList<User>();
private ArrayList<Bid> bids = new ArrayList<Bid>();
private ArrayList<User> subscribedUsers;
private ArrayList<Bid> bids;
private int id;
private Item item;
private Date start, end;
private double price, bidIncrement;
private User currentLeader;
private Seller seller;
public Auction(Item item, Date start, Date end, double price, double bidIncrement) {
subscribedUsers = new ArrayList<User>();
bids = new ArrayList<Bid>();
id = idCounter++;
this.item = item;
this.start = start;
......@@ -32,7 +34,14 @@ public class Auction {
public Auction() {
subscribedUsers = new ArrayList<User>();
bids = new ArrayList<Bid>();
seller = Seller.getInstance();
id = idCounter++;
this.item = new Item();
this.start = new Date();
this.end = new Date();
this.price = 0;
this.bidIncrement = 0;
auctions.add(this);
}
......@@ -125,6 +134,10 @@ public class Auction {
}
public Seller getSeller() {
return seller;
}
public ArrayList<Bid> getBids() {
return bids;
......@@ -137,4 +150,8 @@ public class Auction {
}
public double getBidIncrement() {
return bidIncrement;
}
}
......@@ -11,15 +11,15 @@ import exceptions.BidBelowZeroException;
public class AuctionManager {
private Auction auction;
private project.Auction auction;
public AuctionManager() {
this.auction = new Auction();
this.auction = new project.Auction();
}
public void setAuction(Auction a) {
public void setAuction(project.Auction a) {
this.auction = a;
......@@ -44,15 +44,13 @@ public class AuctionManager {
} else if (checkTime(d)) {
Bid b = new Bid(d, value, user, auction);
computePrice(b);
Seller s = auction.getSeller();
ArrayList<Bid> toSet = auction.getBids();
toSet.add(b);
it.unibz.Bid extBid = new it.unibz.Bid(null, null, b.getValue());
it.unibz.Seller extSeller = new it.unibz.Seller("", "", "", "", "", "", s.getSsn());
it.unibz.Auction extAuction = new it.unibz.Auction(extSeller, (int) auction.getBidIncrement(), null, null, auction.getPrice(), null);
auction.setBids(toSet);
auction.setCurrentLeader(user);
return true;
return extAuction.addBid(extBid);
}
......@@ -75,7 +73,7 @@ public class AuctionManager {
}
}
if (d.before(auction.getEnd())) {
return true;
......@@ -85,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,34 +8,28 @@ 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;
}
}
}
......@@ -75,12 +75,6 @@ public class Item {
}
public ArrayList<Auction> getAuctionHistory() {
return null;
}
public static Item getItem(int item) {
for (Item i : items) {
......@@ -160,12 +154,6 @@ public class Item {
}
public void setOwner(int newOwner) {
this.userOwner = newOwner;
}
public String getTitle() {
return this.title;
......
......@@ -56,9 +56,9 @@ public class ItemPicture {
}
}
return null;
}
public static ItemPicture getInstance() {
......@@ -66,4 +66,5 @@ public class ItemPicture {
return new ItemPicture();
}
}
......@@ -78,6 +78,10 @@ public class Seller extends User {
}
public String getSsn() {
return ssn;
}
public static Seller getInstance() {
Seller s = new Seller();
......@@ -143,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 {
......
package integrationTest;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Collection;
import org.junit.jupiter.api.DynamicTest;
import org.junit.jupiter.api.TestFactory;
import org.junit.jupiter.api.function.Executable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import exceptions.BidBelowZeroException;
import project.Auction;
import project.AuctionManager;
import project.User;
public class AuctionManagerIntegrationTest {
@TestFactory
public Collection<DynamicTest> externalAddBidTestFalse() {
Auction auction = Auction.getInstance();
User user = User.getInstance();
AuctionManager manager = AuctionManager.getInstance();
ArrayList<Integer> values = new ArrayList<Integer>();
manager.setAuction(auction);
for (int i = 1; i < 6; i++) {
values.add(i);
}
Collection<DynamicTest> dynamicTests = new ArrayList<DynamicTest>();
for (int e = 0; e < 5; e++) {
DynamicTest dTest;
auction.setPrice(10);
int toCheck = values.get(e);
Executable exec = () -> assertFalse(manager.placeBid(user, toCheck));
dTest = DynamicTest.dynamicTest("Lower bid than current auction price", exec);
dynamicTests.add(dTest);
}
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));
}
}
......@@ -11,6 +11,112 @@ in order to present the user stories and acceptance test, we would like to highl
Here you can find the list of our design choiches:
- the incrementation bid is a value determined by the seller, who decides how big the increment of each offer should be
- the user must only offer integer times of the increment bid, he cannot decide a precise amount of money;
- it is possible to login both with the email account or the username;
- it is not possible to modify pictures in a given item thorugh the modify function: they can be only added or removed by other specific functions.
\ No newline at end of file
- it is not possible to modify pictures in a given item thorugh the modify function: they can be only added or removed by other specific functions.
## ASSIGNMENT 2
<u>*PROFILE: UNIT*</u>
Our existing unit tests worked because when a new Auction is created the price of it is set to 0. Since in the unit test we did not set a starting price, due to the fact that our bid is always the same incremental value set by the Seller at the time he created the Auction so there is not need to check that the bid has to be higher than the current price, and our unit tests on *placeBid()* checked the time of the auction with the time of the bid, there are no errors in our tests.
`[INFO] -------------------------------------------------------`
`[INFO] T E S T S`
`[INFO] -------------------------------------------------------`
`[INFO] Running unitTest.AuctionManagerUnitTest`
`[INFO] Tests run: 41, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.311 s - in unitTest.AuctionManagerUnitTest`
`[INFO] Running unitTest.AuctionUnitTest`
`[INFO] Tests run: 28, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0 s - in unitTest.AuctionUnitTest`
`[INFO] Running unitTest.ItemPictureUnitTest`
`[INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.03 s - in unitTest.ItemPictureUnitTest`
`[INFO] Running unitTest.ItemUnitTest`
`[INFO] Tests run: 23, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.055 s - in unitTest.ItemUnitTest`
`[INFO] Running unitTest.SellerUnitTest`
`[INFO] Tests run: 28, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.141 s - in unitTest.SellerUnitTest`
`[INFO] Running unitTest.UserUnitTest`
`[INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.047 s - in unitTest.UserUnitTest`
`[INFO]`
`[INFO] Results:`
`[INFO]`
`[INFO] Tests run: 162, Failures: 0, Errors: 0, Skipped: 0`
`[INFO]`
`[INFO]`
`[INFO] --- jacoco-maven-plugin:0.8.5:report (report) @ clar ---`
`[INFO] Loading execution data file C:\Users\Cris\Documents\UniBZ\GIT\clar\EclipseProject\target\jacoco.exec`
`[INFO] Analyzed bundle 'clar' with 22 classes`
`[INFO] ------------------------------------------------------------------------`
`[INFO] BUILD SUCCESS`
`[INFO] ------------------------------------------------------------------------`
`[INFO] Total time: 10.903 s`
`[INFO] Finished at: 2019-12-11T10:38:27+01:00`
`[INFO] ------------------------------------------------------------------------`
<u>*PROFILE: INTEGRATION*</u>
[`INFO] -------------------------------------------------------`
`[INFO] T E S T S`
`[INFO] -------------------------------------------------------`
`[INFO] Running integrationTest.AuctionManagerIntegrationTest`
`[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.535 s - in integrationTest.AuctionManagerIntegrationTest`
`[INFO]`
`[INFO] Results:`
`[INFO]`
`[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0`
`[INFO]`
`[INFO]`
`[INFO] --- jacoco-maven-plugin:0.8.5:report (report) @ clar ---`
`[INFO] Loading execution data file C:\Users\Cris\Documents\UniBZ\GIT\clar\EclipseProject\target\jacoco.exec`
`[INFO] Analyzed bundle 'clar' with 22 classes`
`[INFO] ------------------------------------------------------------------------`
`[INFO] BUILD SUCCESS`
`[INFO] ------------------------------------------------------------------------`
`[INFO] Total time: 10.700 s`
`[INFO] Finished at: 2019-12-11T11:00:30+01:00`
`[INFO] ------------------------------------------------------------------------`
<u>*PROFILE: REGRESSION*</u>
`[INFO] -------------------------------------------------------`
`[INFO] T E S T S`
`[INFO] -------------------------------------------------------`
`[INFO] Running integrationTest.AuctionManagerIntegrationTest`
`[INFO] Tests run: 10, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.253 s - in integrationTest.AuctionManagerIntegrationTest`
`[INFO] Running unitTest.AuctionManagerUnitTest`
`[INFO] Tests run: 41, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.133 s - in unitTest.AuctionManagerUnitTest`
`[INFO] Running unitTest.AuctionUnitTest`
`[INFO] Tests run: 14, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.066 s - in unitTest.AuctionUnitTest`
`[INFO] Running unitTest.ItemPictureUnitTest`
`[INFO] Tests run: 20, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s - in unitTest.ItemPictureUnitTest`
`[INFO] Running unitTest.ItemUnitTest`
`[INFO] Tests run: 52, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.089 s - in unitTest.ItemUnitTest`
`[INFO] Running unitTest.SellerUnitTest`
`[INFO] Tests run: 28, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.06 s - in unitTest.SellerUnitTest`
`[INFO] Running unitTest.UserUnitTest`
`[INFO] Tests run: 22, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.051 s - in unitTest.UserUnitTest`
`[INFO]`
`[INFO] Results:`
`[INFO]`
`[INFO] Tests run: 187, Failures: 0, Errors: 0, Skipped: 0`
`[INFO]`
`[INFO]`
`[INFO] --- jacoco-maven-plugin:0.8.5:report (report) @ clar ---`
`[INFO] Loading execution data file C:\Users\Cris\Documents\UniBZ\GIT\clar\EclipseProject\target\jacoco.exec`
`[INFO] Analyzed bundle 'clar' with 22 classes`
`[INFO] ------------------------------------------------------------------------`
`[INFO] BUILD SUCCESS`
`[INFO] ------------------------------------------------------------------------`
`[INFO] Total time: 10.766 s`
`[INFO] Finished at: 2019-12-11T11:03:34+01:00`
`[INFO] ------------------------------------------------------------------------`
\ 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