@Test
public void postPotentialDuplicateAlreadyExists()
{

    PotentialDuplicate pd = new PotentialDuplicate( "ABCDEFGHIJ1", "ABCDEFGHIJ2" );
    TrackedEntityInstance teiA = new TrackedEntityInstance();
    TrackedEntityInstance teiB = new TrackedEntityInstance();
    teiA.setUid( "ABCDEFGHIJ1" );
    teiB.setUid( "ABCDEFGHIJ2" );
    Mockito.when( trackedEntityInstanceService.getTrackedEntityInstance( Mockito.eq( "ABCDEFGHIJ1" ) ) )
        .thenReturn( teiA );
    Mockito.when( trackedEntityInstanceService.getTrackedEntityInstance( Mockito.eq( "ABCDEFGHIJ2" ) ) )
        .thenReturn( teiB );
    Mockito.when( trackerAccessManager.canRead( Mockito.any(), Mockito.eq( teiA ) ) ).thenReturn(
        Lists.newArrayList() );
    Mockito.when( trackerAccessManager.canRead( Mockito.any(), Mockito.eq( teiB ) ) ).thenReturn(
        Lists.newArrayList() );
    Mockito.when( deduplicationService.exists( pd ) ).thenReturn( true );
    try
    {
        controller.postPotentialDuplicate( pd );
    }
    catch ( WebMessageException e )
    {
        WebMessage wm = e.getWebMessage();
        assertEquals( "Conflict", wm.getHttpStatus() );
        assertEquals( 409, wm.getHttpStatusCode().intValue() );
        assertEquals( Status.ERROR, wm.getStatus() );
        assertEquals( "'ABCDEFGHIJ1' and 'ABCDEFGHIJ2' is already marked as a potential duplicate",
            wm.getMessage() );
    }
}