DeduplicationController { @RequestMapping( method = { RequestMethod.PUT, RequestMethod.POST }, value = "/{id}/invalidation" ) public void markPotentialDuplicateInvalid( @PathVariable String id ) throws WebMessageException { PotentialDuplicate potentialDuplicate = deduplicationService.getPotentialDuplicateByUid( id ); if ( potentialDuplicate == null ) { throw new WebMessageException( notFound( "No potentialDuplicate records found with id '" + id + "'." ) ); } deduplicationService.markPotentialDuplicateInvalid( potentialDuplicate ); } DeduplicationController( DeduplicationService deduplicationService,
        TrackedEntityInstanceService trackedEntityInstanceService,
        TrackerAccessManager trackerAccessManager, CurrentUserService currentUserService,
        FieldFilterService fieldFilterService,
        ContextService contextService ); @GetMapping Node getAll(
        PotentialDuplicateQuery query,
        HttpServletResponse response
    ); @GetMapping( value = "/{id}" ) PotentialDuplicate getPotentialDuplicate(
        @PathVariable String id
    ); @PostMapping PotentialDuplicate postPotentialDuplicate(
        @RequestBody PotentialDuplicate potentialDuplicate
    ); @RequestMapping( method = { RequestMethod.PUT, RequestMethod.POST }, value = "/{id}/invalidation" ) void markPotentialDuplicateInvalid(
        @PathVariable String id
    ); @DeleteMapping( value = "/{id}" ) void deletePotentialDuplicate(
        @PathVariable String id
    );  }
@Test public void markPotentialDuplicateInvalid() throws WebMessageException { PotentialDuplicate pd = new PotentialDuplicate( "teiA" ); Mockito.when( deduplicationService.getPotentialDuplicateByUid( Mockito.eq( "1" ) ) ).thenReturn( pd ); controller.markPotentialDuplicateInvalid( "1" ); Mockito.verify( deduplicationService ).markPotentialDuplicateInvalid( Mockito.eq( pd ) ); }
@Test public void markPotentialDuplicateInvalidNotFound() { Mockito.when( deduplicationService.getPotentialDuplicateByUid( Mockito.eq( "0" ) ) ).thenReturn( null ); try { controller.markPotentialDuplicateInvalid( "0" ); } catch ( WebMessageException e ) { WebMessage wm = e.getWebMessage(); assertEquals( "Not Found", wm.getHttpStatus() ); assertEquals( 404, wm.getHttpStatusCode().intValue() ); assertEquals( Status.ERROR, wm.getStatus() ); assertEquals( "No potentialDuplicate records found with id '0'.", wm.getMessage() ); } }