-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from Qorder/issueOrderTotalPrice
Completed issue #35
- Loading branch information
Showing
8 changed files
with
407 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
QorderWS/src/test/java/com/qorder/qorderws/entities/AllEntitiesEqualityTests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.qorder.qorderws.entities; | ||
|
||
import org.junit.runner.RunWith; | ||
import org.junit.runners.Suite; | ||
import org.junit.runners.Suite.SuiteClasses; | ||
|
||
@RunWith(Suite.class) | ||
@SuiteClasses({ ProductEqualityTest.class, ProductHolderEqualityTest.class }) | ||
public class AllEntitiesEqualityTests { | ||
|
||
} |
161 changes: 161 additions & 0 deletions
161
QorderWS/src/test/java/com/qorder/qorderws/entities/ProductEqualityTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
package com.qorder.qorderws.entities; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.math.BigDecimal; | ||
|
||
import org.junit.After; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.qorder.qorderws.model.product.Product; | ||
|
||
public class ProductEqualityTest { | ||
|
||
private Product product1; | ||
|
||
private Product product2; | ||
|
||
@Before | ||
public void setUp() throws Exception { | ||
product1 = new Product(); | ||
product2 = new Product(); | ||
} | ||
|
||
@After | ||
public void tearDown() throws Exception { | ||
product1 = null; | ||
product2 = null; | ||
} | ||
|
||
@Test | ||
public void SuccessfulProductEqualitytest() { | ||
System.out.println("Successful product equality test"); | ||
|
||
product1.setName("ProductName"); | ||
product1.setPrice(BigDecimal.valueOf(1.1)); | ||
product1.addDescription("Description 1"); | ||
product1.addDescription("Description 2"); | ||
|
||
product2.setName("ProductName"); | ||
product2.setPrice(BigDecimal.valueOf(1.1)); | ||
product2.addDescription("Description 1"); | ||
product2.addDescription("Description 2"); | ||
|
||
boolean equalityResult = product1.equals(product2); | ||
assertTrue(equalityResult); | ||
} | ||
|
||
@Test | ||
public void FailProductEqualitytestByName() { | ||
System.out.println("Failed product equality test by name"); | ||
|
||
product1.setName("ProductName"); | ||
product1.setPrice(BigDecimal.valueOf(1.1)); | ||
product1.addDescription("Description 1"); | ||
product1.addDescription("Description 2"); | ||
|
||
|
||
product2.setName("OtherProductName"); | ||
product2.setPrice(BigDecimal.valueOf(1.1)); | ||
product2.addDescription("Description 1"); | ||
product2.addDescription("Description 2"); | ||
|
||
boolean equalityResult = product1.equals(product2); | ||
assertFalse(equalityResult); | ||
} | ||
|
||
@Test | ||
public void FailProductEqualitytestByPrice() { | ||
System.out.println("Failed product equality test by price"); | ||
|
||
product1.setName("ProductName"); | ||
product1.setPrice(BigDecimal.valueOf(1.1)); | ||
product1.addDescription("Description 1"); | ||
product1.addDescription("Description 2"); | ||
|
||
product2.setName("ProductName"); | ||
product2.setPrice(BigDecimal.valueOf(2.1)); | ||
product2.addDescription("Description 1"); | ||
product2.addDescription("Description 2"); | ||
|
||
boolean equalityResult = product1.equals(product2); | ||
assertFalse(equalityResult); | ||
} | ||
|
||
@Test | ||
public void FailProductEqualitytestByOneMoreDescription() { | ||
System.out.println("Failed product equality test by one more description"); | ||
|
||
product1.setName("ProductName"); | ||
product1.setPrice(BigDecimal.valueOf(1.1)); | ||
product1.addDescription("Description 1"); | ||
product1.addDescription("Description 2"); | ||
product1.addDescription("Description 3"); | ||
|
||
product2.setName("ProductName"); | ||
product2.setPrice(BigDecimal.valueOf(1.1)); | ||
product2.addDescription("Description 1"); | ||
product2.addDescription("Description 2"); | ||
|
||
boolean equalityResult = product1.equals(product2); | ||
assertFalse(equalityResult); | ||
} | ||
|
||
@Test | ||
public void FailProductEqualitytestByOneLessDescription() { | ||
System.out.println("Failed product equality test by one less description"); | ||
|
||
product1.setName("ProductName"); | ||
product1.setPrice(BigDecimal.valueOf(1.1)); | ||
product1.addDescription("Description 1"); | ||
|
||
product2.setName("ProductName"); | ||
product2.setPrice(BigDecimal.valueOf(1.1)); | ||
product2.addDescription("Description 1"); | ||
product2.addDescription("Description 2"); | ||
|
||
boolean equalityResult = product1.equals(product2); | ||
assertFalse(equalityResult); | ||
} | ||
|
||
@Test | ||
public void FailProductEqualitytestByNullProductName() { | ||
System.out.println("Failed product equality test by one less description"); | ||
|
||
product1.setName(null); | ||
product1.setPrice(BigDecimal.valueOf(1.1)); | ||
product1.addDescription("Description 1"); | ||
product1.addDescription("Description 2"); | ||
|
||
product2.setName("ProductName"); | ||
product2.setPrice(BigDecimal.valueOf(1.1)); | ||
product2.addDescription("Description 1"); | ||
product2.addDescription("Description 2"); | ||
|
||
boolean equalityResult = product1.equals(product2); | ||
assertFalse(equalityResult); | ||
} | ||
|
||
@Test | ||
public void FailProductEqualitytestByNullDescriptionList() { | ||
System.out.println("Failed product equality test by one less description"); | ||
|
||
product1.setName(null); | ||
product1.setPrice(BigDecimal.valueOf(1.1)); | ||
product1.setDescriptions(null); | ||
|
||
product2.setName("ProductName"); | ||
product2.setPrice(BigDecimal.valueOf(1.1)); | ||
product2.addDescription("Description 1"); | ||
product2.addDescription("Description 2"); | ||
|
||
boolean equalityResult = product1.equals(product2); | ||
assertFalse(equalityResult); | ||
} | ||
|
||
|
||
|
||
|
||
} |
Oops, something went wrong.