Skip to content

Commit

Permalink
PR feedback changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hamza-vd committed Sep 21, 2022
1 parent d0f884d commit 239af37
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2365,10 +2365,10 @@ public DuplicateZeirIdStatus cleanDuplicateMotherIds() throws Exception {
Map<String, String> 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(),
Expand All @@ -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));
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<Child>(),null, null );
}

@Test
public void addTimelineEventsReturnsTheSameECDdetailObject() {
List<TimelineEvent> 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"));
}
}

0 comments on commit 239af37

Please sign in to comment.