### Question:
ProviderRestService extends RestEntityServiceBase { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) @AuditIgnore public Object getAll(@QueryParam("from") Integer from, @QueryParam("size") Integer size) { return entityService.getAll(from, size, FIELDS_TO_REMOVE); }  @PostConstruct void init(); @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) @AuditIgnore Object getAll(@QueryParam("from") Integer from, @QueryParam("size") Integer size); @GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) @Override @AuditIgnore Object get(@PathParam("id") String id); @POST @Path("/") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Object create(@AuditContent Map<String, Object> data); @POST @Path("/{id}") @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) Object create(@PathParam("id") @AuditId String id, @AuditContent Map<String, Object> data); @POST @Path("/{id}/password") @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) Object changePassword(@PathParam("id") @AuditId String id, String pwd); @POST @Path("/{id}/content_manipulation_lock") @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) Object contentManipulationLockCreate(@PathParam("id") @AuditId String id); @DELETE @Path("/{id}/content_manipulation_lock") @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) Object contentManipulationLockDelete(@PathParam("id") @AuditId String id); @GET @Path("/{id}/content_manipulation_lock") @RolesAllowed({ Role.ADMIN, Role.PROVIDER }) @Produces(MediaType.APPLICATION_JSON) Map<String, Object> contentManipulationLockInfo(@PathParam("id") @AuditId String id);  }### Answer:
@Test public void getAll() { ProviderRestService tested = getTested(); ESDataOnlyResponse res = new ESDataOnlyResponse(null); Mockito.when(tested.entityService.getAll(10, 12, ProviderRestService.FIELDS_TO_REMOVE)).thenReturn(res); Assert.assertEquals(res, tested.getAll(10, 12)); Mockito.verify(tested.entityService).getAll(10, 12, ProviderRestService.FIELDS_TO_REMOVE); Mockito.verifyNoMoreInteractions(tested.entityService); Mockito.reset(tested.entityService); Mockito.when(tested.entityService.getAll(10, 12, ProviderRestService.FIELDS_TO_REMOVE)).thenReturn(null); Assert.assertEquals(null, tested.getAll(10, 12)); Mockito.verify(tested.entityService).getAll(10, 12, ProviderRestService.FIELDS_TO_REMOVE); Mockito.verifyNoMoreInteractions(tested.entityService); }
@Test(expected = RuntimeException.class) public void getAll_exceptionFromService() { ProviderRestService tested = getTested(); Mockito.reset(tested.entityService); Mockito.when(tested.entityService.getAll(10, 12, ProviderRestService.FIELDS_TO_REMOVE)).thenThrow( new RuntimeException("my exception")); TestUtils.assertResponseStatus(tested.getAll(10, 12), Status.INTERNAL_SERVER_ERROR); Mockito.verify(tested.entityService).getAll(10, 12, ProviderRestService.FIELDS_TO_REMOVE); Mockito.verifyNoMoreInteractions(tested.entityService); }