Skip to content

Commit

Permalink
Added test
Browse files Browse the repository at this point in the history
  • Loading branch information
rkodev committed Aug 26, 2019
1 parent 806a9a7 commit d7e10a7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -644,9 +644,9 @@ public static String toCSV(List<String> list) {
if (list.size() > 0) {
StringBuilder sb = new StringBuilder();
for (String s : list) {
sb.append(s).append(",");
sb.append(s).append(", ");
}
result = sb.deleteCharAt(sb.length() - 1).toString();
result = sb.deleteCharAt(sb.length() - 2).toString();
}
return result;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package org.smartregister.chw.anc.util;

import org.junit.Assert;
import org.junit.Test;
import org.smartregister.chw.anc.domain.VisitDetail;

import java.util.ArrayList;
import java.util.List;

public class NCUtilsTest {

@Test
public void testGetText() {
List<VisitDetail> details = new ArrayList<>();

VisitDetail visitDetail1 = new VisitDetail();
visitDetail1.setHumanReadable("test1");
details.add(visitDetail1);

VisitDetail visitDetail2 = new VisitDetail();
visitDetail2.setHumanReadable("test2");
details.add(visitDetail2);

VisitDetail visitDetail3 = new VisitDetail();
details.add(visitDetail3);

details.add(null);

String val = NCUtils.getText(details).trim();
String expected = "test1, test2";

Assert.assertEquals(expected, val);
}

@Test
public void testGetTextOneParam() {

VisitDetail visitDetail1 = new VisitDetail();
visitDetail1.setHumanReadable("test1");

String val = NCUtils.getText(visitDetail1).trim();
String expected = "test1";

Assert.assertEquals(expected, val);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
import static org.junit.Assert.assertTrue;

@PrepareForTest({AncLibrary.class, JsonFormUtils.class, ImmunizationLibrary.class})
public class VisitNCUtilsTest {
public class VisitUtilsTest {
@Rule
public PowerMockRule rule = new PowerMockRule();

Expand Down

0 comments on commit d7e10a7

Please sign in to comment.