Skip to content

Commit

Permalink
Remove manually called setUp()
Browse files Browse the repository at this point in the history
  • Loading branch information
PashaBarahimi committed Dec 14, 2023
1 parent 6d6bcf1 commit c616862
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 20 deletions.
16 changes: 0 additions & 16 deletions Baloot2/src/test/java/domain/EngineTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package domain;

import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.*;

public class EngineTest {
Expand All @@ -11,7 +10,6 @@ public void setUp() {
engine = new Engine();
}

@NotNull
public static Order constructOrder(int id, int customer, int price, int quantity) {
Order order = new Order();
order.setId(id);
Expand All @@ -26,14 +24,12 @@ public static Order constructOrder(int id, int customer, int price, int quantity
@Test
@DisplayName("Test average quantity with no orders")
public void testAverageQuantityNoOrders() {
setUp();
Assertions.assertEquals(0, engine.getAverageOrderQuantityByCustomer(1));
}

@Test
@DisplayName("Test average quantity with one order")
public void testAverageQuantityOneOrder() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
engine.orderHistory.add(order);
Assertions.assertEquals(2, engine.getAverageOrderQuantityByCustomer(1));
Expand All @@ -42,7 +38,6 @@ public void testAverageQuantityOneOrder() {
@Test
@DisplayName("Test average quantity with multiple orders")
public void testAverageQuantityMultipleOrders() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
Order order2 = constructOrder(1, 1, 8, 6);
engine.orderHistory.add(order);
Expand All @@ -53,7 +48,6 @@ public void testAverageQuantityMultipleOrders() {
@Test
@DisplayName("Test average quantity with unknown customer")
public void testAverageQuantityUnknownCustomer() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
engine.orderHistory.add(order);
Assertions.assertThrows(Exception.class, () -> engine.getAverageOrderQuantityByCustomer(2));
Expand All @@ -64,14 +58,12 @@ public void testAverageQuantityUnknownCustomer() {
@Test
@DisplayName("Test quantity pattern with no orders")
public void testQuantityPatternNoOrders() {
setUp();
Assertions.assertEquals(0, engine.getQuantityPatternByPrice(1));
}

@Test
@DisplayName("Test quantity pattern with linear increasing quantity for a price")
public void testQuantityPatternWithPattern() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
Order order2 = constructOrder(1, 2, 4, 8);
Order order3 = constructOrder(2, 2, 4, 14);
Expand All @@ -84,7 +76,6 @@ public void testQuantityPatternWithPattern() {
@Test
@DisplayName("Test quantity pattern without pattern")
public void testQuantityPatternWithoutPattern() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
Order order2 = constructOrder(1, 2, 4, 8);
Order order3 = constructOrder(2, 2, 4, 13);
Expand All @@ -97,7 +88,6 @@ public void testQuantityPatternWithoutPattern() {
@Test
@DisplayName("Test quantity pattern with pattern and different prices")
public void testQuantityPatternWithPatternAndDifferentPrices() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
Order order2 = constructOrder(1, 2, 4, 8);
Order order3 = constructOrder(2, 2, 5, 13);
Expand All @@ -114,7 +104,6 @@ public void testQuantityPatternWithPatternAndDifferentPrices() {
@Test
@DisplayName("Test fraudulent quantity with order quantity more than the average")
public void testFraudulentQuantityMoreThanAvg() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
Order order2 = constructOrder(1, 1, 8, 6);
engine.orderHistory.add(order);
Expand All @@ -124,7 +113,6 @@ public void testFraudulentQuantityMoreThanAvg() {
@Test
@DisplayName("Test fraudulent quantity with order quantity equal to the average")
public void testFraudulentQuantityEqualToAvg() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
engine.orderHistory.add(order);
Assertions.assertEquals(0, engine.getCustomerFraudulentQuantity(order));
Expand All @@ -133,7 +121,6 @@ public void testFraudulentQuantityEqualToAvg() {
@Test
@DisplayName("Test fraudulent quantity with order quantity less than the average")
public void testFraudulentQuantityLessThanAvg() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
Order order2 = constructOrder(1, 1, 8, 6);
engine.orderHistory.add(order2);
Expand All @@ -145,7 +132,6 @@ public void testFraudulentQuantityLessThanAvg() {
@Test
@DisplayName("Test adding already existing order")
public void testAddingAlreadyExistingOrder() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
engine.orderHistory.add(order);
Assertions.assertEquals(0, engine.addOrderAndGetFraudulentQuantity(order));
Expand All @@ -154,7 +140,6 @@ public void testAddingAlreadyExistingOrder() {
@Test
@DisplayName("Test adding order and getting fraudulent quantity (if not 0)")
public void testAddOrderAndGetFraudulent() {
setUp();
Order order = constructOrder(0, 1, 4, 2);
Order order2 = constructOrder(1, 1, 8, 6);
engine.orderHistory.add(order);
Expand All @@ -165,7 +150,6 @@ public void testAddOrderAndGetFraudulent() {
@Test
@DisplayName("Test adding order and getting fraudulent quantity of 0 (should return pattern)")
public void testAddOrderAndGetFraudulentBelowAvg() {
setUp();
Order order = constructOrder(0, 1, 4, 8);
Order order2 = constructOrder(1, 1, 4, 14);
Order order3 = constructOrder(2, 1, 4, 2);
Expand Down
4 changes: 0 additions & 4 deletions Baloot2/src/test/java/domain/OrderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public void setUp() {
@Test
@DisplayName("Test order.equals should only compare order ids")
public void testEqualsComparesIds() {
setUp();
Order order = new Order() {{
setId(0);
}};
Expand All @@ -28,7 +27,6 @@ public void testEqualsComparesIds() {
@Test
@DisplayName("Test order.equals with different order ids")
public void testEqualsDifferentIds() {
setUp();
Order newOrder = new Order() {{
setId(1);
}};
Expand All @@ -38,15 +36,13 @@ public void testEqualsDifferentIds() {
@Test
@DisplayName("Test order.equals with object of another type")
public void testEqualsWrongObject() {
setUp();
Object object = new Object();
Assertions.assertFalse(order.equals(object));
}

@Test
@DisplayName("Test order getter and setters")
public void testOrderGetterSetters() {
setUp();
order.setId(1);
order.setCustomer(2);
order.setPrice(3);
Expand Down

0 comments on commit c616862

Please sign in to comment.