diff --git a/src/main/java/org/opensrp/repository/postgres/UniqueIdRepositoryImpl.java b/src/main/java/org/opensrp/repository/postgres/UniqueIdRepositoryImpl.java index d248af8a3..709c60c7e 100644 --- a/src/main/java/org/opensrp/repository/postgres/UniqueIdRepositoryImpl.java +++ b/src/main/java/org/opensrp/repository/postgres/UniqueIdRepositoryImpl.java @@ -229,7 +229,7 @@ protected Long retrievePrimaryKey(UniqueId uniqueId) { UniqueIdExample example; List pgEntities; - if (fromOpenMrs == Boolean.TRUE) { + if (Boolean.TRUE.equals(fromOpenMrs)) { identifier = uniqueOpenMrsIdentifier.toString(); example = new UniqueIdExample(); example.createCriteria().andOpenmrsIdEqualTo(identifier); diff --git a/src/test/java/org/opensrp/service/PlanServiceTest.java b/src/test/java/org/opensrp/service/PlanServiceTest.java index c4e67973f..6294728e9 100755 --- a/src/test/java/org/opensrp/service/PlanServiceTest.java +++ b/src/test/java/org/opensrp/service/PlanServiceTest.java @@ -510,10 +510,6 @@ public void testPopulateTaskCountForLarvalDipping() { null, false)).thenReturn(1l); Map properties = new HashMap<>(); properties.put(PlanConstants.TYPE, PlanConstants.LARVAL_DIPPING_SITE); - List structureIds = new ArrayList<>(); - structureIds.add("structure-id-1"); - structureIds.add("structure-id-2"); - structureIds.add("structure-id-3"); when(locationService.countStructuresByProperties(Collections.singletonList("location-id1"), properties)).thenReturn(3l); @@ -540,10 +536,6 @@ public void testPopulateTaskCountForMosquitoCollection() { null, false)).thenReturn(1l); Map properties = new HashMap<>(); properties.put(PlanConstants.TYPE, PlanConstants.MOSQUITO_COLLECTION_POINT); - List structureIds = new ArrayList<>(); - structureIds.add("structure-id-1"); - structureIds.add("structure-id-2"); - structureIds.add("structure-id-3"); when(locationService.countStructuresByProperties(Collections.singletonList("location-id1"), properties)).thenReturn(3l); diff --git a/src/test/java/org/opensrp/service/PractitionerRoleServiceTest.java b/src/test/java/org/opensrp/service/PractitionerRoleServiceTest.java index 4d7539d75..3bce65084 100755 --- a/src/test/java/org/opensrp/service/PractitionerRoleServiceTest.java +++ b/src/test/java/org/opensrp/service/PractitionerRoleServiceTest.java @@ -24,13 +24,6 @@ import static org.mockito.Matchers.eq; import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyLong; -import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.atLeastOnce; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; @@ -50,7 +43,30 @@ public class PractitionerRoleServiceTest { @Mock private PractitionerService practitionerService; - + private static PractitionerRole initTestPractitionerRole(){ + PractitionerRole practitionerRole = new PractitionerRole(); + practitionerRole.setIdentifier("pr1-identifier"); + practitionerRole.setActive(true); + practitionerRole.setOrganizationIdentifier("org-identifier"); + practitionerRole.setPractitionerIdentifier("p1-identifier"); + PractitionerRoleCode code = new PractitionerRoleCode(); + code.setText("pr1Code"); + practitionerRole.setCode(code); + return practitionerRole; + } + + private static PractitionerRole initTestPractitionerRole2(){ + PractitionerRole practitionerRole = new PractitionerRole(); + practitionerRole.setIdentifier("pr2-identifier"); + practitionerRole.setActive(true); + practitionerRole.setOrganizationIdentifier("org1"); + practitionerRole.setPractitionerIdentifier("p2-identifier"); + PractitionerRoleCode code = new PractitionerRoleCode(); + code.setText("pr2Code"); + practitionerRole.setCode(code); + return practitionerRole; + } + @Test public void testGetAllPractitionerRoles() { List expectedPractitionerRoles = new ArrayList<>(); @@ -145,7 +161,7 @@ public void testDeleteByOrganizationAndPractitionerShouldCallRepostorySafeRemove org.opensrp.domain.postgres.Practitioner pgPractitioner = new org.opensrp.domain.postgres.Practitioner(); pgPractitioner.setId(1l); - + when(practitionerService.getPgPractitioner(anyString())).thenReturn(pgPractitioner); PractitionerRole practitionerRole = initTestPractitionerRole(); @@ -153,7 +169,6 @@ public void testDeleteByOrganizationAndPractitionerShouldCallRepostorySafeRemove verify(practitionerRoleRepository).safeRemove(anyLong(), anyLong()); } - @Test public void testGetRolesForPractitionerShouldCallGetRolesForPractitionerMethod() { List expectedPractitionerRoles = new ArrayList<>(); @@ -255,28 +270,4 @@ public void testAssignPractitionerRoleWithException() { PractitionerRole practitionerRole = initTestPractitionerRole(); practitionerRoleService.assignPractitionerRole(organizationId, practitionerIdentifier, code, practitionerRole); } - - private static PractitionerRole initTestPractitionerRole(){ - PractitionerRole practitionerRole = new PractitionerRole(); - practitionerRole.setIdentifier("pr1-identifier"); - practitionerRole.setActive(true); - practitionerRole.setOrganizationIdentifier("org-identifier"); - practitionerRole.setPractitionerIdentifier("p1-identifier"); - PractitionerRoleCode code = new PractitionerRoleCode(); - code.setText("pr1Code"); - practitionerRole.setCode(code); - return practitionerRole; - } - - private static PractitionerRole initTestPractitionerRole2(){ - PractitionerRole practitionerRole = new PractitionerRole(); - practitionerRole.setIdentifier("pr2-identifier"); - practitionerRole.setActive(true); - practitionerRole.setOrganizationIdentifier("org1"); - practitionerRole.setPractitionerIdentifier("p2-identifier"); - PractitionerRoleCode code = new PractitionerRoleCode(); - code.setText("pr2Code"); - practitionerRole.setCode(code); - return practitionerRole; - } } diff --git a/src/test/java/org/opensrp/service/PractitionerServiceTest.java b/src/test/java/org/opensrp/service/PractitionerServiceTest.java index 106ae7c5f..3cfdc86bd 100755 --- a/src/test/java/org/opensrp/service/PractitionerServiceTest.java +++ b/src/test/java/org/opensrp/service/PractitionerServiceTest.java @@ -24,9 +24,6 @@ import static org.mockito.Matchers.anyString; import static org.mockito.Matchers.eq; import static org.mockito.Mockito.doReturn; -import static org.mockito.Mockito.mock; -import static org.mockito.ArgumentMatchers.*; -import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; diff --git a/src/test/java/org/opensrp/service/formSubmission/EventListenerTest.java b/src/test/java/org/opensrp/service/formSubmission/EventListenerTest.java index 3bd38e399..34ad55625 100644 --- a/src/test/java/org/opensrp/service/formSubmission/EventListenerTest.java +++ b/src/test/java/org/opensrp/service/formSubmission/EventListenerTest.java @@ -4,10 +4,7 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyBoolean; import static org.mockito.ArgumentMatchers.anyString; -import static org.mockito.Mockito.inOrder; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.spy; -import static org.mockito.Mockito.when; +import static org.mockito.Mockito.*; import java.util.HashMap; import java.util.List; @@ -23,7 +20,6 @@ import org.opensrp.common.AllConstants; import org.opensrp.domain.AppStateToken; import org.opensrp.service.ExportEventDataMapper; -import org.opensrp.repository.ClientsRepository; import org.opensrp.repository.EventsRepository; import org.opensrp.repository.PlanRepository; import org.opensrp.service.ClientService; @@ -48,9 +44,6 @@ public class EventListenerTest { @Mock private EventsRepository allEvents; - @Mock - private ClientsRepository allClients; - @Mock private ErrorTraceService errorTraceService; @@ -85,7 +78,7 @@ public void setUp() { } @Test - public void shouldHandleNewEvent() throws Exception { + public void shouldHandleNewEvent() { EventsHandler eventHandler = mock(EventsHandler.class); Map handlerMap = new HashMap<>(); handlerMap.put("VaccinesScheduleHandler", eventHandler); @@ -96,8 +89,8 @@ public void shouldHandleNewEvent() throws Exception { new Event()); when(configService.getAppStateTokenByName(AllConstants.Config.EVENTS_PARSER_LAST_PROCESSED_EVENT)) - .thenReturn(new AppStateToken("token", 1l, 0l)); - when(allEvents.findByServerVersion(1l)).thenReturn(events); + .thenReturn(new AppStateToken("token", 1L, 0l)); + when(allEvents.findByServerVersion(1L)).thenReturn(events); when(clientService.findAllByIdentifier(AllConstants.Client.ZEIR_ID.toUpperCase(), "2")).thenReturn(clients); when(allEvents.findByBaseEntityAndType("222", "Birth Registration")).thenReturn(events); @@ -108,7 +101,7 @@ public void shouldHandleNewEvent() throws Exception { spyEventListener.processEvent(); - InOrder inOrder = inOrder(eventService, eventsRouter, eventHandler); + InOrder inOrder = inOrder(eventService, eventsRouter); clients.get(0).setServerVersion(System.currentTimeMillis()); events.get(0).setServerVersion(System.currentTimeMillis()); inOrder.verify(eventService).processOutOfArea(events.get(0));