### Question:
ProjectRestService extends RestEntityServiceBase { @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) @Override @PermitAll @AuditIgnore public Object getAll(@QueryParam("from") Integer from, @QueryParam("size") Integer size) { Principal principal = securityContext.getUserPrincipal(); if (principal == null) { return entityService.getAll(from, size, fieldsToRemove); } else { return entityService.getAll(from, size, null); } }  @PostConstruct void init(); @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) @Override @PermitAll @AuditIgnore Object getAll(@QueryParam("from") Integer from, @QueryParam("size") Integer size); @GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @Override @PermitAll @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); @GET @Path("/search") @Produces(MediaType.APPLICATION_JSON) @AuditIgnore Object search(@Context UriInfo uriInfo); static final String PARAM_CODE; }### Answer:
@Test public void getAll_ok() { ProjectRestService tested = getTested(); ESDataOnlyResponse res = new ESDataOnlyResponse(null); Mockito.when(tested.entityService.getAll(10, 12, tested.fieldsToRemove)).thenReturn(res); Assert.assertEquals(res, tested.getAll(10, 12)); }
@Test(expected = RuntimeException.class) public void getAll_errorFromService() { ProjectRestService tested = getTested(); Mockito.reset(tested.entityService); Mockito.when(tested.entityService.getAll(10, 12, tested.fieldsToRemove)).thenThrow( new RuntimeException("my exception")); tested.getAll(10, 12); }