diff --git a/opensrp-core/src/main/java/org/smartregister/repository/EventClientRepository.java b/opensrp-core/src/main/java/org/smartregister/repository/EventClientRepository.java index f14f75c67..987e387d5 100644 --- a/opensrp-core/src/main/java/org/smartregister/repository/EventClientRepository.java +++ b/opensrp-core/src/main/java/org/smartregister/repository/EventClientRepository.java @@ -2365,10 +2365,10 @@ public DuplicateZeirIdStatus cleanDuplicateMotherIds() throws Exception { Map duplicates = Context.getInstance().zeirIdCleanupRepository().getClientsWithDuplicateZeirIds(); long unusedIdsCount = uniqueIdRepository.countUnUsedIds(); - Timber.d("%d duplicates for provider: %s - %s", duplicates.size(), username, duplicates.toString()); + Timber.e("%d duplicates for provider: %s - %s", duplicates.size(), username, duplicates.toString()); if (duplicates.size() > 0) { - Timber.d( + Timber.e( "%s: %d duplicates for provider: %s - %s\nUnused Unique IDs: %d", this.getClass().getSimpleName(), duplicates.size(), @@ -2386,7 +2386,7 @@ public DuplicateZeirIdStatus cleanDuplicateMotherIds() throws Exception { JSONObject identifiers = clientJson.getJSONObject(AllConstants.IDENTIFIERS); long unusedIds = uniqueIdRepository.countUnUsedIds(); - if (unusedIds <= 2) { + if (unusedIds <= 30) { // Mske sure we have enough unused IDs left Timber.e("%s: No more unique IDs available to assign to %s - %s; provider: %s", this.getClass().getSimpleName(), baseEntityId, zeirId, username); android.content.Context applicationContext = CoreLibrary.getInstance().context().applicationContext(); applicationContext.startService(new Intent(applicationContext, PullUniqueIdsIntentService.class)); @@ -2432,7 +2432,7 @@ public DuplicateZeirIdStatus cleanDuplicateMotherIds() throws Exception { uniqueIdRepository.close(newZeirId); - Timber.d("%s: %s - %s updated to %s; provider: %s", this.getClass().getSimpleName(), baseEntityId, zeirId, newZeirId, username); + Timber.e("%s: %s - %s updated to %s; provider: %s", this.getClass().getSimpleName(), baseEntityId, zeirId, newZeirId, username); } if (duplicates.size() > 0) { diff --git a/opensrp-core/src/test/java/org/smartregister/repository/EventClientRepositoryTest.java b/opensrp-core/src/test/java/org/smartregister/repository/EventClientRepositoryTest.java index 77b360f3e..222fb8875 100644 --- a/opensrp-core/src/test/java/org/smartregister/repository/EventClientRepositoryTest.java +++ b/opensrp-core/src/test/java/org/smartregister/repository/EventClientRepositoryTest.java @@ -765,6 +765,7 @@ public void testCleanDuplicateMotherIdsShouldFixAndMarkDuplicateClientsUnSynced( DuplicateZeirIdStatus duplicateZeirIdStatus = eventClientRepository.cleanDuplicateMotherIds(); Assert.assertEquals(DuplicateZeirIdStatus.CLEANED, duplicateZeirIdStatus); + verify(sqliteDatabase, times(1)).rawQuery(eq(DUPLICATES_SQL), any()); verify(sqliteDatabase, times(1)).insert(eq("client"), eq(null), any()); } diff --git a/opensrp-core/src/test/java/org/smartregister/view/contract/ECDetailTest.java b/opensrp-core/src/test/java/org/smartregister/view/contract/ECDetailTest.java new file mode 100644 index 000000000..9fb2f3155 --- /dev/null +++ b/opensrp-core/src/test/java/org/smartregister/view/contract/ECDetailTest.java @@ -0,0 +1,33 @@ +package org.smartregister.view.contract; + +import org.junit.Assert; +import org.junit.Before; +import org.junit.Test; +import org.smartregister.util.DateUtil; + +import java.util.ArrayList; +import java.util.List; + +public class ECDetailTest { + private ECDetail ecDetail; + private String caseId = "1234-5678-1234"; + @Before + public void setup(){ + ecDetail = new ECDetail(caseId,"Kogelo","kisumu", "456", true, + "addres1", "sd-card/photos", new ArrayList(),null, null ); + } + + @Test + public void addTimelineEventsReturnsTheSameECDdetailObject() { + List timelineEvents = new ArrayList<>(); + timelineEvents.add(getAnEvent()); + Assert.assertEquals(ecDetail.addTimelineEvents(timelineEvents), ecDetail); + } + + + private TimelineEvent getAnEvent(){ + return new TimelineEvent("PREGNANCY","pregnancy event", + new String[]{"ANC","Registered"}, + DateUtil.formatDateForTimelineEvent("2011-10-21")); + } +} \ No newline at end of file