use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerTest method postPotentialDuplicateTeiNotFound.
@Test
void postPotentialDuplicateTeiNotFound() {
when(trackedEntityInstanceService.getTrackedEntityInstance(teiA)).thenReturn(null);
try {
deduplicationController.postPotentialDuplicate(new PotentialDuplicate(teiA, teiB));
} catch (OperationNotAllowedException | ConflictException | NotFoundException | BadRequestException | PotentialDuplicateConflictException e) {
assertTrue(e instanceof NotFoundException);
}
verify(deduplicationService, times(0)).addPotentialDuplicate(any());
}
use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerTest method postPotentialDuplicateNoAccessToTeiA.
@Test
void postPotentialDuplicateNoAccessToTeiA() {
when(trackerAccessManager.canRead(Mockito.any(), eq(trackedEntityInstanceA))).thenReturn(Lists.newArrayList("Error"));
try {
deduplicationController.postPotentialDuplicate(new PotentialDuplicate(teiA, teiB));
} catch (OperationNotAllowedException | ConflictException | NotFoundException | BadRequestException | PotentialDuplicateConflictException e) {
assertTrue(e instanceof OperationNotAllowedException);
}
verify(deduplicationService, times(0)).addPotentialDuplicate(any());
verify(trackerAccessManager).canRead(user, trackedEntityInstanceA);
}
use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerTest method postPotentialDuplicateNoAccessToTeiB.
@Test
void postPotentialDuplicateNoAccessToTeiB() {
when(trackerAccessManager.canRead(Mockito.any(), eq(trackedEntityInstanceA))).thenReturn(Lists.newArrayList());
when(trackerAccessManager.canRead(Mockito.any(), eq(trackedEntityInstanceB))).thenReturn(Lists.newArrayList("Error"));
try {
deduplicationController.postPotentialDuplicate(new PotentialDuplicate(teiA, teiB));
} catch (OperationNotAllowedException | ConflictException | NotFoundException | BadRequestException | PotentialDuplicateConflictException e) {
assertTrue(e instanceof OperationNotAllowedException);
}
verify(deduplicationService, times(0)).addPotentialDuplicate(any());
verify(trackerAccessManager).canRead(user, trackedEntityInstanceA);
verify(trackerAccessManager).canRead(user, trackedEntityInstanceB);
}
use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerTest method shouldThrowUpdatePotentialDuplicateMergeRequest.
@Test
void shouldThrowUpdatePotentialDuplicateMergeRequest() {
PotentialDuplicate potentialDuplicate = new PotentialDuplicate(teiA, teiB);
when(deduplicationService.getPotentialDuplicateByUid(uid)).thenReturn(potentialDuplicate);
assertThrows(BadRequestException.class, () -> deduplicationController.updatePotentialDuplicate(uid, DeduplicationStatus.MERGED.name()));
}
use of org.hisp.dhis.deduplication.PotentialDuplicate in project dhis2-core by dhis2.
the class DeduplicationControllerTest method getPotentialDuplicateByUid.
@Test
void getPotentialDuplicateByUid() throws NotFoundException {
when(deduplicationService.getPotentialDuplicateByUid(uid)).thenReturn(new PotentialDuplicate(teiA, teiB));
PotentialDuplicate pd = deduplicationController.getPotentialDuplicateById(uid);
assertEquals(teiA, pd.getOriginal());
verify(deduplicationService).getPotentialDuplicateByUid(uid);
}
Aggregations