NotificationManagementServiceImpl implements NotificationManagementService { @GET @Override public Response getNotifications( @QueryParam("status") @Size(max = 45) String status, @HeaderParam("If-Modified-Since") String ifModifiedSince, @QueryParam("offset") int offset, @QueryParam("limit") int limit) { RequestValidationUtil.validatePaginationParameters(offset, limit); PaginationRequest request = new PaginationRequest(offset, limit); PaginationResult result; NotificationList notificationList = new NotificationList(); String msg; try { if (status != null) { RequestValidationUtil.validateNotificationStatus(status); result = DeviceMgtAPIUtils.getNotificationManagementService().getNotificationsByStatus( Notification.Status.valueOf(status), request); } else { result = DeviceMgtAPIUtils.getNotificationManagementService().getAllNotifications(request); } notificationList.setCount(result.getRecordsTotal()); notificationList.setNotifications((List<Notification>) result.getData()); return Response.status(Response.Status.OK).entity(notificationList).build(); } catch (NotificationManagementException e) { msg = "Error occurred while retrieving notification list"; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } }  @GET @Override Response getNotifications(
            @QueryParam("status") @Size(max = 45) String status,
            @HeaderParam("If-Modified-Since") String ifModifiedSince,
            @QueryParam("offset") int offset, @QueryParam("limit") int limit); @PUT @Path("/{id}/mark-checked") Response updateNotificationStatus(@PathParam("id") int id); @Override Response clearAllNotifications();  }
@Test(description = "This method tests the behaviour of getNotifications method under different conditions") public void testGetNotifications() throws NotificationManagementException { PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getNotificationManagementService")) .toReturn(this.notificationManagementService); Response response = notificationManagement.getNotifications("NEW", "test", 0, 10); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Notification retrieval failed"); response = notificationManagement.getNotifications(null, "test", 0, 10); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Notification retrieval failed"); Mockito.reset(this.notificationManagementService); Mockito.doThrow(new NotificationManagementException()).when(notificationManagementService) .getAllNotifications(Mockito.any()); response = notificationManagement.getNotifications(null, "test", 0, 10); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Notification retrieval succeeded with issues in NotificationManagement OSGI service"); Mockito.reset(this.notificationManagementService); }