Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mwithi committed Dec 23, 2024
1 parent 62f2e4b commit c91c24a
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions src/test/java/org/isf/medicalsinventory/Tests.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,26 +122,26 @@ class Tests extends OHCoreTestCase {

@Autowired
SupplierIoOperationRepository supplierIoOperationRepository;

@Autowired
MedicalStockIoOperationRepository medicalStockIoOperationRepository;

@Autowired
MedicalStockIoOperations medicalStockIoOperation;

static Stream<Arguments> automaticlot() {
return Stream.of(Arguments.of(true, true, false),
Arguments.of(true, true, true),
Arguments.of(false, true, false),
Arguments.of(false, true, true));
Arguments.of(true, true, true),
Arguments.of(false, true, false),
Arguments.of(false, true, true));
}

private static void setGeneralData(boolean in, boolean out, boolean toward) {
GeneralData.AUTOMATICLOT_IN = in;
GeneralData.AUTOMATICLOT_OUT = out;
GeneralData.AUTOMATICLOTWARD_TOWARD = toward;
}

@BeforeAll
static void setUpClass() {
testMedicalInventory = new TestMedicalInventory();
Expand Down Expand Up @@ -294,7 +294,7 @@ void testDeleteMedicalInventoryWithInventoryRowsWithoutNewLot() throws Exception
assertThat(foundMedicalInventory).isNotNull();
assertThat(foundMedicalInventory.getStatus()).isEqualTo(InventoryStatus.canceled.toString());
}

@Test
void testDeleteMedicalInventoryWithInventoryRowsWithNewLot() throws Exception {
Integer id = setupTestMedicalInventory();
Expand Down Expand Up @@ -329,7 +329,7 @@ void testMgrGetMedicalInventoryWithStatus() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
List<MedicalInventory> medicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(firstMedicalInventory.getStatus(),
firstMedicalInventory.getInventoryType());
firstMedicalInventory.getInventoryType());
assertThat(medicalInventories).hasSize(1);
assertThat(medicalInventories.get(0).getStatus()).isEqualTo(firstMedicalInventory.getStatus());
}
Expand All @@ -348,7 +348,7 @@ void testIoGetMedicalInventoryWithStatus() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
List<MedicalInventory> medicalInventories = medicalInventoryIoOperation.getMedicalInventoryByStatusAndInventoryType(firstMedicalInventory.getStatus(),
firstMedicalInventory.getInventoryType());
firstMedicalInventory.getInventoryType());
assertThat(medicalInventories).hasSize(1);
assertThat(medicalInventories.get(0).getStatus()).isEqualTo(firstMedicalInventory.getStatus());
}
Expand All @@ -369,7 +369,7 @@ void testMgrGetMedicalInventoryWithStatusAndWard() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
List<MedicalInventory> medicalinventories = medicalInventoryManager.getMedicalInventoryByStatusAndWard(firstMedicalInventory.getStatus(),
firstMedicalInventory.getWard());
firstMedicalInventory.getWard());
assertThat(medicalinventories).hasSize(1);
assertThat(medicalinventories.get(0).getStatus()).isEqualTo(firstMedicalInventory.getStatus());
assertThat(medicalinventories.get(0).getWard()).isEqualTo(firstMedicalInventory.getWard());
Expand All @@ -391,7 +391,7 @@ void testIoGetMedicalInventoryWithStatusAndWard() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
List<MedicalInventory> medicalinventories = medicalInventoryIoOperation
.getMedicalInventoryByStatusAndWard(firstMedicalInventory.getStatus(), firstMedicalInventory.getWard());
.getMedicalInventoryByStatusAndWard(firstMedicalInventory.getStatus(), firstMedicalInventory.getWard());
assertThat(medicalinventories).hasSize(1);
assertThat(medicalinventories.get(0).getStatus()).isEqualTo(firstMedicalInventory.getStatus());
assertThat(medicalinventories.get(0).getWard()).isEqualTo(firstMedicalInventory.getWard());
Expand All @@ -413,10 +413,10 @@ void testMgrGetMedicalInventoryByParams() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
List<MedicalInventory> medicalinventories = medicalInventoryManager.getMedicalInventoryByParams(secondMedicalInventory.getInventoryDate().minusDays(2),
secondMedicalInventory.getInventoryDate().plusDays(2), status, secondMedicalInventory.getInventoryType());
assertThat(medicalinventories).hasSize(1);
assertThat(medicalinventories.get(0).getStatus()).isEqualTo(secondMedicalInventory.getStatus());
assertThat(medicalinventories.get(0).getWard()).isEqualTo(secondMedicalInventory.getWard());
secondMedicalInventory.getInventoryDate().plusDays(2), status, secondMedicalInventory.getInventoryType());
assertThat(medicalinventories).hasSize(2); // including draft inventory (id=1)
assertThat(medicalinventories.get(1).getStatus()).isEqualTo(secondMedicalInventory.getStatus());
assertThat(medicalinventories.get(1).getWard()).isEqualTo(secondMedicalInventory.getWard());
}

@Test
Expand All @@ -435,7 +435,7 @@ void testMgrGetMedicalInventoryByParamsNullStatus() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
List<MedicalInventory> medicalinventories = medicalInventoryManager.getMedicalInventoryByParams(secondMedicalInventory.getInventoryDate().minusDays(2),
secondMedicalInventory.getInventoryDate().plusDays(2), null, secondMedicalInventory.getInventoryType());
secondMedicalInventory.getInventoryDate().plusDays(2), null, secondMedicalInventory.getInventoryType());
assertThat(medicalinventories).hasSize(2);
assertThat(medicalinventories.get(0).getStatus()).containsAnyOf(firstMedicalInventory.getStatus(), status);
assertThat(medicalinventories.get(0).getWard()).containsAnyOf(firstMedicalInventory.getWard(), wardCode);
Expand All @@ -459,11 +459,11 @@ void testMgrGetMedicalInventoryByParamsPageable() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
Page<MedicalInventory> medicalinventories = medicalInventoryManager.getMedicalInventoryByParamsPageable(
secondMedicalInventory.getInventoryDate().minusDays(2), secondMedicalInventory.getInventoryDate().plusDays(2), status,
secondMedicalInventory.getInventoryType(), 0, 10);
assertThat(medicalinventories).hasSize(1);
assertThat(medicalinventories.getContent().get(0).getStatus()).isEqualTo(secondMedicalInventory.getStatus());
assertThat(medicalinventories.getContent().get(0).getWard()).isEqualTo(secondMedicalInventory.getWard());
secondMedicalInventory.getInventoryDate().minusDays(2), secondMedicalInventory.getInventoryDate().plusDays(2), status,
secondMedicalInventory.getInventoryType(), 0, 10);
assertThat(medicalinventories).hasSize(2); // including draft inventory (id=1)
assertThat(medicalinventories.getContent().get(1).getStatus()).isEqualTo(secondMedicalInventory.getStatus());
assertThat(medicalinventories.getContent().get(1).getWard()).isEqualTo(secondMedicalInventory.getWard());
}

@Test
Expand All @@ -482,8 +482,8 @@ void testMgrGetMedicalInventoryByParamsNullStatusPagable() throws Exception {
MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory);
assertThat(secondMedicalInventory).isNotNull();
Page<MedicalInventory> medicalinventories = medicalInventoryManager.getMedicalInventoryByParamsPageable(
secondMedicalInventory.getInventoryDate().minusDays(2), secondMedicalInventory.getInventoryDate().plusDays(2), null,
secondMedicalInventory.getInventoryType(), 0, 10);
secondMedicalInventory.getInventoryDate().minusDays(2), secondMedicalInventory.getInventoryDate().plusDays(2), null,
secondMedicalInventory.getInventoryType(), 0, 10);
assertThat(medicalinventories).hasSize(2);
assertThat(medicalinventories.getContent().get(0).getStatus()).containsAnyOf(firstMedicalInventory.getStatus(), status);
assertThat(medicalinventories.getContent().get(0).getWard()).containsAnyOf(firstMedicalInventory.getWard(), wardCode);
Expand Down Expand Up @@ -707,7 +707,7 @@ void testConfirmMedicalInventory(boolean in, boolean out, boolean toward) throws
medicalStockIoOperationRepository.saveAndFlush(secondmedicalStock);
MedicalInventoryRow medicalInventoryRowOne = testMedicalInventoryRow.setup(inventory, medical, lotOne, false);
medicalInventoryRowOne.setRealqty(60);
MedicalInventoryRow medicalInventoryRowTwo = testMedicalInventoryRow.setup(inventory, medical, lotTwo, false);
MedicalInventoryRow medicalInventoryRowTwo = testMedicalInventoryRow.setup(inventory, medical, lotTwo, false);
medicalInventoryRowTwo.setId(2);
medicalInventoryRowTwo.setRealqty(30);
MedicalInventoryRow medicalInventoryRowThree = testMedicalInventoryRow.setup(inventory, medical, lotThree, false);
Expand All @@ -726,7 +726,7 @@ void testConfirmMedicalInventory(boolean in, boolean out, boolean toward) throws
assertThat(inventory).isNotNull();
assertThat(inventory.getStatus()).isEqualTo(status);
}

@Test
void testReferenceOfInventoryExist() throws Exception {
int id = setupTestMedicalInventory();
Expand All @@ -736,14 +736,14 @@ void testReferenceOfInventoryExist() throws Exception {
boolean exist = medicalInventoryManager.referenceExists(reference);
assertThat(exist).isTrue();
}

@Test
void testGetInventoryByID() throws Exception {
int id = setupTestMedicalInventory();
MedicalInventory inventory = medicalInventoryManager.getInventoryById(id);
assertThat(inventory).isNotNull();
}

@Test
void testGetInventoryByReference() throws Exception {
int id = setupTestMedicalInventory();
Expand All @@ -754,7 +754,7 @@ void testGetInventoryByReference() throws Exception {
assertThat(found).isNotNull();
assertThat(found.getInventoryReference()).isEqualTo(inventory.getInventoryReference());
}

@Test
void testValidateMedicalInventory() throws Exception {
Ward ward = testWard.setup(false);
Expand Down Expand Up @@ -793,7 +793,7 @@ void testValidateMedicalInventory() throws Exception {
lotThree = lotIoOperationRepository.save(lotThree);
MedicalInventoryRow medicalInventoryRowOne = testMedicalInventoryRow.setup(inventory, medical, lotOne, false);
medicalInventoryRowOne.setRealqty(60);
MedicalInventoryRow medicalInventoryRowTwo = testMedicalInventoryRow.setup(inventory, medical, lotTwo, false);
MedicalInventoryRow medicalInventoryRowTwo = testMedicalInventoryRow.setup(inventory, medical, lotTwo, false);
medicalInventoryRowTwo.setId(2);
medicalInventoryRowTwo.setRealqty(30);
MedicalInventoryRow medicalInventoryRowThree = testMedicalInventoryRow.setup(inventory, medical, lotThree, false);
Expand Down

0 comments on commit c91c24a

Please sign in to comment.