RestServiceImpl implements RestService { @Override public Response getTrackerOperation( final String source, final String uuid ) { try { UUID poUUID = UUID.fromString( uuid ); TrackerOperationView trackerOperationView = tracker.getTrackerOperation( source, poUUID ); if ( trackerOperationView != null ) { return Response.ok().entity( GSON.toJson( trackerOperationView ) ).build(); } else { return Response.status( Response.Status.NOT_FOUND ).build(); } } catch ( NullPointerException | IllegalArgumentException e ) { LOG.error( "Error in getTrackerOperation", e ); return Response.status( Response.Status.BAD_REQUEST ).entity( e.getMessage() ).build(); } } RestServiceImpl( final Tracker tracker ); @Override Response getTrackerOperation( final String source, final String uuid ); @Override Response getTrackerOperations( final String source, final String fromDate, final String toDate,
                                          final int limit ); @Override Response getTrackerOperationSources();  }
@Test public void testGetProductOperation() throws Exception { Response response = restService.getTrackerOperation( SOURCE, OPERATION_ID.toString() ); TrackerOperationView pov = JsonUtil.fromJson( response.getEntity().toString(), TrackerOperationViewImpl.class ); assertEquals( Response.Status.OK.getStatusCode(), response.getStatus() ); assertNotNull( pov ); }
@Test public void testGetProductOperationNotFound() throws Exception { Response response = restService.getTrackerOperation( SOURCE, OPERATION_ID2.toString() ); assertEquals( Response.Status.NOT_FOUND.getStatusCode(), response.getStatus() ); }
@Test public void testGetProductOperationException() throws Exception { Response response = restService.getTrackerOperation( SOURCE, null ); assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus() ); }