NotificationManagementServiceImpl implements NotificationManagementService { @PUT @Path("/{id}/mark-checked") public Response updateNotificationStatus(@PathParam("id") int id) { String msg; Notification.Status status = Notification.Status.CHECKED; Notification notification; try { DeviceMgtAPIUtils.getNotificationManagementService().updateNotificationStatus(id, status); } catch (NotificationManagementException e) { msg = "Error occurred while updating notification status."; log.error(msg, e); return Response.serverError().entity( new ErrorResponse.ErrorResponseBuilder().setMessage(msg).build()).build(); } try { notification = DeviceMgtAPIUtils.getNotificationManagementService().getNotification(id); return Response.status(Response.Status.OK).entity(notification).build(); } catch (NotificationManagementException e) { msg = "Notification updated successfully. But the retrial of the updated notification failed"; log.error(msg, e); return Response.status(Response.Status.OK).entity(msg).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 updateNotificationStatus method under different conditions") public void testUpdateNotificationStatus() throws NotificationManagementException { PowerMockito.stub(PowerMockito.method(DeviceMgtAPIUtils.class, "getNotificationManagementService")) .toReturn(this.notificationManagementService); Mockito.doReturn(true).when(notificationManagementService) .updateNotificationStatus(1, Notification.Status.CHECKED); Mockito.doThrow(NotificationManagementException.class).when(notificationManagementService) .updateNotificationStatus(2, Notification.Status.CHECKED); Mockito.doReturn(true).when(notificationManagementService) .updateNotificationStatus(3, Notification.Status.CHECKED); Mockito.doReturn(new Notification()).when(notificationManagementService).getNotification(1); Mockito.doThrow(new NotificationManagementException()).when(notificationManagementService).getNotification(3); Response response = notificationManagement.updateNotificationStatus(1); Assert.assertEquals(response.getStatus(), Response.Status.OK.getStatusCode(), "Notification status update failed under correct conditions"); response = notificationManagement.updateNotificationStatus(2); Assert.assertEquals(response.getStatus(), Response.Status.INTERNAL_SERVER_ERROR.getStatusCode(), "Notification status update succeeded under erroneous conditions"); response = notificationManagement.updateNotificationStatus(3); Assert.assertEquals(response.getEntity(), "Notification updated successfully. But the retrial of the updated " + "notification failed", "Notification status update succeeded under erroneous conditions"); }