ActivityProviderServiceImpl implements ActivityInfoProviderService { @GET @Override @Path("/{id}/{devicetype}/{deviceid}") public Response getActivityByDevice(@PathParam("id") @Size(max = 45) String id, @PathParam("devicetype") @Size(max = 45) String devicetype, @PathParam("deviceid") @Size(max = 45) String deviceid, @HeaderParam("If-Modified-Since") String ifModifiedSince) { Activity activity; DeviceManagementProviderService dmService; try { RequestValidationUtil.validateActivityId(id); DeviceIdentifier deviceIdentifier = new DeviceIdentifier(); deviceIdentifier.setId(deviceid); deviceIdentifier.setType(devicetype); dmService = DeviceMgtAPIUtils.getDeviceManagementService(); activity = dmService.getOperationByActivityIdAndDevice(id, deviceIdentifier); if (activity == null) { return Response.status(404).entity( new ErrorResponse.ErrorResponseBuilder().setMessage("No activity can be " + "found upon the provided activity id '" + id + "'").build()).build(); } return Response.status(Response.Status.OK).entity(activity).build(); } catch (OperationManagementException e) { String msg = "ErrorResponse occurred while fetching the activity for the supplied id."; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } }  @GET @Override @Path("/{id}") Response getActivity(@PathParam("id")
                                @Size(max = 45) String id,
                                @HeaderParam("If-Modified-Since") String ifModifiedSince); @GET @Override @Path("/ids") Response getActivities(@QueryParam("ids") ActivityIdList activityIdList); @GET @Override @Path("/{id}/{devicetype}/{deviceid}") Response getActivityByDevice(@PathParam("id")
                                        @Size(max = 45) String id,
                                        @PathParam("devicetype")
                                        @Size(max = 45) String devicetype,
                                        @PathParam("deviceid")
                                        @Size(max = 45) String deviceid,
                                        @HeaderParam("If-Modified-Since") String ifModifiedSince); @GET @Override @Path("/type/{operationCode}") Response getActivities(@PathParam("operationCode") String operationCode,
                                  @QueryParam("offset") int offset, @QueryParam("limit") int limit); @GET @Override Response getActivities(@QueryParam("since") String since,  @QueryParam("initiatedBy")String initiatedBy,
                                  @QueryParam("offset") int offset, @QueryParam("limit") int limit,
                                  @HeaderParam("If-Modified-Since") String ifModifiedSince);  }
@Test(description = "This method tests getting details of an activity for a given device") public void testGetActivitiesByDevice() throws OperationManagementException { PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getDeviceManagementService")) .toReturn(this.deviceManagementProviderService); Mockito.when(this.deviceManagementProviderService .getOperationByActivityIdAndDevice(TEST_ACTIVITY_ID, deviceIdentifier)).thenReturn(activity); Response response = this.activityInfoProviderService.getActivityByDevice(TEST_ACTIVITY_ID, DEVICE_TYPE, DEVICE_ID, IF_MODIFIED_SINCE); Assert.assertNotNull(response); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode()); Mockito.reset(this.deviceManagementProviderService); }