RestServiceImpl implements RestService { @Override public Response getTrackerOperations( final String source, final String fromDate, final String toDate, final int limit ) { try { SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); Date fromDat = df.parse( fromDate + " 00:00:00" ); Date toDat = df.parse( toDate + " 23:59:59" ); List<TrackerOperationView> pos = tracker.getTrackerOperations( source, fromDat, toDat, limit ); return Response.ok().entity( GSON.toJson( pos ) ).build(); } catch ( ParseException e ) { LOG.error( "Error in getTrackerOperations", 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 testGetProductOperations() throws Exception { SimpleDateFormat df = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss" ); Type listPOVType = new TypeToken<List<TrackerOperationViewImpl>>() { }.getType(); Response response = restService.getTrackerOperations( SOURCE, df.format( new Date() ), df.format( new Date() ), 1 ); List<TrackerOperationView> pov = JsonUtil.fromJson( response.getEntity().toString(), listPOVType ); assertEquals( Response.Status.OK.getStatusCode(), response.getStatus() ); assertTrue( !pov.isEmpty() ); }
@Test public void testGetProductOperationsException() throws Exception { Response response = restService.getTrackerOperations( SOURCE, null, "", 1 ); assertEquals( Response.Status.BAD_REQUEST.getStatusCode(), response.getStatus() ); }