use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerMvcTest method shouldUpdatePotentialDuplicate.
@Test
void shouldUpdatePotentialDuplicate() throws Exception {
String uid = "uid";
PotentialDuplicate potentialDuplicate = new PotentialDuplicate(teiA, teiB);
when(deduplicationService.getPotentialDuplicateByUid(uid)).thenReturn(potentialDuplicate);
mockMvc.perform(put(ENDPOINT + "/" + uid).param("status", DeduplicationStatus.INVALID.name()).content(objectMapper.writeValueAsString(potentialDuplicate)).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
ArgumentCaptor<PotentialDuplicate> potentialDuplicateArgumentCaptor = ArgumentCaptor.forClass(PotentialDuplicate.class);
verify(deduplicationService).getPotentialDuplicateByUid(uid);
verify(deduplicationService).updatePotentialDuplicate(potentialDuplicateArgumentCaptor.capture());
assertEquals(DeduplicationStatus.INVALID, potentialDuplicateArgumentCaptor.getValue().getStatus());
}
use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerMvcTest method shouldThrowPostPotentialDuplicateMissingTei.
@Test
void shouldThrowPostPotentialDuplicateMissingTei() throws Exception {
PotentialDuplicate potentialDuplicate = new PotentialDuplicate(teiA, null);
mockMvc.perform(post(ENDPOINT).content(objectMapper.writeValueAsString(potentialDuplicate)).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(result -> assertTrue(result.getResolvedException() instanceof BadRequestException));
}
use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerMvcTest method setUp.
@BeforeEach
void setUp() {
deduplicationMergeParams = DeduplicationMergeParams.builder().potentialDuplicate(new PotentialDuplicate(teiA, teiB)).original(trackedEntityInstanceA).duplicate(trackedEntityInstanceB).mergeObject(MergeObject.builder().build()).build();
mockMvc = MockMvcBuilders.standaloneSetup(deduplicationController).setControllerAdvice(new CrudControllerAdvice()).build();
lenient().when(trackedEntityInstanceService.getTrackedEntityInstance(teiA)).thenReturn(trackedEntityInstanceA);
lenient().when(trackedEntityInstanceService.getTrackedEntityInstance(teiB)).thenReturn(trackedEntityInstanceB);
lenient().when(trackerAccessManager.canRead(any(), any(TrackedEntityInstance.class))).thenReturn(Lists.newArrayList());
}
Aggregations