use of org.hisp.dhis.deduplication.PotentialDuplicateConflictException in project dhis2-core by dhis2.
the class DeduplicationControllerMvcTest method shouldThrowAutoMergeConflictException.
@Test
void shouldThrowAutoMergeConflictException() throws Exception {
String uid = "uid";
PotentialDuplicate potentialDuplicate = new PotentialDuplicate(teiA, teiB);
when(deduplicationService.getPotentialDuplicateByUid(uid)).thenReturn(potentialDuplicate);
doThrow(new PotentialDuplicateConflictException("Conflict")).when(deduplicationService).autoMerge(deduplicationMergeParams);
MergeObject mergeObject = MergeObject.builder().build();
mockMvc.perform(post(ENDPOINT + "/" + uid + "/merge").content(objectMapper.writeValueAsString(mergeObject)).param("mergeStrategy", MergeStrategy.AUTO.name()).contentType(MediaType.APPLICATION_JSON).accept(MediaType.APPLICATION_JSON)).andExpect(result -> assertTrue(result.getResolvedException() instanceof PotentialDuplicateConflictException));
verify(deduplicationService).autoMerge(deduplicationMergeParams);
verify(deduplicationService, times(0)).manualMerge(deduplicationMergeParams);
}
Aggregations