Skip to content

Commit

Permalink
Update test with more robust test data
Browse files Browse the repository at this point in the history
  • Loading branch information
jtankw3 committed Apr 10, 2019
1 parent dcd95da commit 6a0aa38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"batchNumber" : "GKP1685",
"expiry" : "15/08/2019",
"quantity" : "300"
},
{
"batchNumber" : "GKP1682",
"expiry" : "31/07/2019",
"quantity" : "5"
} ]
}, {
"name" : "Lipitor",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import seedu.address.model.UserPrefs;
import seedu.address.model.medicine.Batch;
import seedu.address.model.medicine.BatchNumber;
import seedu.address.model.medicine.Expiry;
import seedu.address.model.medicine.Medicine;
import seedu.address.model.medicine.Quantity;
import seedu.address.testutil.BatchBuilder;
Expand Down Expand Up @@ -201,16 +202,17 @@ public void execute_removeBatchUnfilteredListOneOtherBatch_success() {
Batch batchToRemove = iter.next();

assertTrue(iter.hasNext()); // There is one more batch after removing
Batch batchRemaining = iter.next();

batches.remove(batchToRemove.getBatchNumber());

int newQuantity = medicineToUpdate.getTotalQuantity().getNumericValue()
- batchToRemove.getQuantity().getNumericValue();

Expiry newExpiry = batches.values().stream().min(Comparator.comparing(Batch::getExpiry)).get().getExpiry();

Medicine updatedMedicine = new MedicineBuilder(medicineToUpdate)
.withQuantity(Integer.toString(newQuantity))
.withExpiry(batchRemaining.getExpiry().toString())
.withExpiry(newExpiry.toString())
.withBatches(batches).build();

Batch inputBatch = new BatchBuilder(batchToRemove).withQuantity("0").build();
Expand Down

0 comments on commit 6a0aa38

Please sign in to comment.