From c91c24a6c1dd0ff599e8651ac93bc8cec962e3be Mon Sep 17 00:00:00 2001 From: mwithi Date: Mon, 23 Dec 2024 22:41:23 +0100 Subject: [PATCH] Fix tests --- .../java/org/isf/medicalsinventory/Tests.java | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/src/test/java/org/isf/medicalsinventory/Tests.java b/src/test/java/org/isf/medicalsinventory/Tests.java index 3cd3728a2..b65927fab 100644 --- a/src/test/java/org/isf/medicalsinventory/Tests.java +++ b/src/test/java/org/isf/medicalsinventory/Tests.java @@ -122,18 +122,18 @@ class Tests extends OHCoreTestCase { @Autowired SupplierIoOperationRepository supplierIoOperationRepository; - + @Autowired MedicalStockIoOperationRepository medicalStockIoOperationRepository; - + @Autowired MedicalStockIoOperations medicalStockIoOperation; static Stream 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) { @@ -141,7 +141,7 @@ private static void setGeneralData(boolean in, boolean out, boolean toward) { GeneralData.AUTOMATICLOT_OUT = out; GeneralData.AUTOMATICLOTWARD_TOWARD = toward; } - + @BeforeAll static void setUpClass() { testMedicalInventory = new TestMedicalInventory(); @@ -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(); @@ -329,7 +329,7 @@ void testMgrGetMedicalInventoryWithStatus() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); List medicalInventories = medicalInventoryManager.getMedicalInventoryByStatusAndInventoryType(firstMedicalInventory.getStatus(), - firstMedicalInventory.getInventoryType()); + firstMedicalInventory.getInventoryType()); assertThat(medicalInventories).hasSize(1); assertThat(medicalInventories.get(0).getStatus()).isEqualTo(firstMedicalInventory.getStatus()); } @@ -348,7 +348,7 @@ void testIoGetMedicalInventoryWithStatus() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); List medicalInventories = medicalInventoryIoOperation.getMedicalInventoryByStatusAndInventoryType(firstMedicalInventory.getStatus(), - firstMedicalInventory.getInventoryType()); + firstMedicalInventory.getInventoryType()); assertThat(medicalInventories).hasSize(1); assertThat(medicalInventories.get(0).getStatus()).isEqualTo(firstMedicalInventory.getStatus()); } @@ -369,7 +369,7 @@ void testMgrGetMedicalInventoryWithStatusAndWard() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); List 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()); @@ -391,7 +391,7 @@ void testIoGetMedicalInventoryWithStatusAndWard() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); List 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()); @@ -413,10 +413,10 @@ void testMgrGetMedicalInventoryByParams() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); List 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 @@ -435,7 +435,7 @@ void testMgrGetMedicalInventoryByParamsNullStatus() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); List 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); @@ -459,11 +459,11 @@ void testMgrGetMedicalInventoryByParamsPageable() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); Page 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 @@ -482,8 +482,8 @@ void testMgrGetMedicalInventoryByParamsNullStatusPagable() throws Exception { MedicalInventory secondMedicalInventory = medIvnIoOperationRepository.saveAndFlush(inventory); assertThat(secondMedicalInventory).isNotNull(); Page 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); @@ -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); @@ -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(); @@ -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(); @@ -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); @@ -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);