-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
57 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
opensrp-child/src/test/java/org/smartregister/child/task/GetSiblingsTaskTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.smartregister.child.task; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.mockito.Mock; | ||
import org.mockito.MockitoAnnotations; | ||
import org.robolectric.util.ReflectionHelpers; | ||
import org.smartregister.child.BaseUnitTest; | ||
import org.smartregister.child.contract.IGetSiblings; | ||
import org.smartregister.child.util.Constants; | ||
import org.smartregister.child.util.DBConstants; | ||
import org.smartregister.commonregistry.CommonPersonObjectClient; | ||
import org.smartregister.utils.Assert; | ||
|
||
import java.util.HashMap; | ||
|
||
public class GetSiblingsTaskTest extends BaseUnitTest { | ||
|
||
private GetSiblingsTask getSiblingsTask; | ||
private CommonPersonObjectClient commonPersonObjectClient; | ||
|
||
@Mock | ||
private IGetSiblings getSiblings; | ||
|
||
@Before | ||
public void setUp() { | ||
MockitoAnnotations.initMocks(this); | ||
|
||
HashMap<String, String> details = new HashMap<>(); | ||
details.put(DBConstants.KEY.ZEIR_ID, "123123"); | ||
commonPersonObjectClient = new CommonPersonObjectClient("baseEntityId", details, Constants.KEY.CHILD); | ||
getSiblingsTask = new GetSiblingsTask(commonPersonObjectClient, getSiblings); | ||
} | ||
|
||
@Test | ||
public void testConstructorNotNull() { | ||
Assert.notNull(getSiblingsTask); | ||
} | ||
|
||
@Test | ||
public void testConstructWhereClauseFiltersDeadChild() { | ||
String whereClause = ReflectionHelpers.callInstanceMethod(getSiblingsTask, "constructWhereClause", ReflectionHelpers.ClassParameter.from(String.class, "123")); | ||
assertEquals(" WHERE ec_child_details.relational_id IN ('123') AND ec_client.date_removed IS NULL AND ec_client.dod IS NULL AND ec_client.is_closed = 0", whereClause); | ||
} | ||
|
||
} |