|
2 | 2 |
|
3 | 3 | import android.content.Intent;
|
4 | 4 |
|
5 |
| -import androidx.localbroadcastmanager.content.LocalBroadcastManager; |
6 |
| - |
7 | 5 | import com.ibm.fhir.model.resource.QuestionnaireResponse;
|
8 | 6 | import com.ibm.fhir.model.resource.Task;
|
9 | 7 |
|
|
30 | 28 | import java.util.List;
|
31 | 29 | import java.util.UUID;
|
32 | 30 |
|
| 31 | +import androidx.localbroadcastmanager.content.LocalBroadcastManager; |
| 32 | + |
33 | 33 | import static com.ibm.fhir.model.type.code.TaskStatus.READY;
|
34 | 34 | import static org.junit.Assert.assertEquals;
|
35 | 35 | import static org.junit.Assert.assertNotNull;
|
@@ -107,22 +107,39 @@ public void testFindTasksForEntity() {
|
107 | 107 | }
|
108 | 108 |
|
109 | 109 | @Test
|
110 |
| - public void testFindTasksByJurisdiction() { |
| 110 | + public void testFindTasksByJurisdictionAndPlanShouldReturnMatchingRecords() { |
111 | 111 | String jurisdictionId = "jurisdiction-id";
|
112 | 112 | String planId = "plan-id";
|
113 | 113 |
|
114 |
| - String query = "SELECT * FROM task WHERE group_id = ? AND plan_id = ?"; |
115 |
| - when(sqLiteDatabase.rawQuery(query, new String[]{jurisdictionId,planId})).thenReturn(getCursor()); |
| 114 | + String query = "SELECT * FROM task WHERE group_id =? AND plan_id =?"; // ensure query exactly matches what is in TaskDaoImpl |
| 115 | + when(sqLiteDatabase.rawQuery(query, new String[]{jurisdictionId, planId})).thenReturn(getCursor()); |
116 | 116 | taskDao = Mockito.spy(taskDao);
|
117 | 117 |
|
118 | 118 | // Call the method under test
|
119 |
| - List<Task> allTasks = taskDao.findTasksByJurisdiction(jurisdictionId,planId); |
| 119 | + List<Task> allTasks = taskDao.findTasksByJurisdiction(jurisdictionId, planId); |
120 | 120 |
|
121 | 121 | // Perform verifications and assertions
|
122 | 122 | verify(taskDao).getTasksByJurisdictionAndPlan(jurisdictionId, planId);
|
123 | 123 | assertEquals(1, allTasks.size());
|
124 | 124 | }
|
125 | 125 |
|
| 126 | + @Test |
| 127 | + public void testFindTasksByJurisdictionShouldReturnMatchingRecords() { |
| 128 | + String jurisdictionId = "jurisdiction-id"; |
| 129 | + |
| 130 | + String query = "SELECT * FROM task WHERE group_id =?"; // ensure query exactly matches what is in TaskDaoImpl |
| 131 | + when(sqLiteDatabase.rawQuery(query, new String[]{jurisdictionId})).thenReturn(getCursor()); |
| 132 | + taskDao = Mockito.spy(taskDao); |
| 133 | + |
| 134 | + // Call the method under test |
| 135 | + List<Task> allTasks = taskDao.findTasksByJurisdiction(jurisdictionId); |
| 136 | + |
| 137 | + // Perform verifications and assertions |
| 138 | + verify(taskDao).getTasksByJurisdiction(jurisdictionId); |
| 139 | + assertEquals(1, allTasks.size()); |
| 140 | + } |
| 141 | + |
| 142 | + |
126 | 143 | @Test
|
127 | 144 | public void testUpdateTaskShouldInvokeExpectedMethods() {
|
128 | 145 | taskDao = Mockito.spy(taskDao);
|
|
0 commit comments