Search in sources :

Example 1 with PotentialDuplicateForbiddenException

use of org.hisp.dhis.deduplication.PotentialDuplicateForbiddenException in project dhis2-core by dhis2.

the class DeduplicationControllerMvcTest method shouldThrowAutoMergeForbiddenException.

@Test
void shouldThrowAutoMergeForbiddenException() throws Exception {
    String uid = "uid";
    PotentialDuplicate potentialDuplicate = new PotentialDuplicate(teiA, teiB);
    when(deduplicationService.getPotentialDuplicateByUid(uid)).thenReturn(potentialDuplicate);
    doThrow(new PotentialDuplicateForbiddenException("Forbidden")).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 PotentialDuplicateForbiddenException));
    verify(deduplicationService).autoMerge(deduplicationMergeParams);
    verify(deduplicationService, times(0)).manualMerge(deduplicationMergeParams);
}
Also used : PotentialDuplicateForbiddenException(org.hisp.dhis.deduplication.PotentialDuplicateForbiddenException) MergeObject(org.hisp.dhis.deduplication.MergeObject) PotentialDuplicate(org.hisp.dhis.deduplication.PotentialDuplicate) Test(org.junit.jupiter.api.Test)

Aggregations

MergeObject (org.hisp.dhis.deduplication.MergeObject)1 PotentialDuplicate (org.hisp.dhis.deduplication.PotentialDuplicate)1 PotentialDuplicateForbiddenException (org.hisp.dhis.deduplication.PotentialDuplicateForbiddenException)1 Test (org.junit.jupiter.api.Test)1