### Question:
ProjectRestService extends RestEntityServiceBase { @GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @Override @PermitAll @AuditIgnore public Object get(@PathParam("id") String id) { Principal principal = securityContext.getUserPrincipal(); if (principal == null) { return super.getFiltered(id, fieldsToRemove); } else { return super.get(id); } }  @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 get_ok() { ProjectRestService tested = getTested(); Map<String, Object> m = new HashMap<String, Object>(); Mockito.when(tested.entityService.get("10")).thenReturn(m); Assert.assertEquals(m, tested.get("10")); }
@Test(expected = RuntimeException.class) public void get_errorFromService() { ProjectRestService tested = getTested(); Mockito.reset(tested.entityService); Mockito.when(tested.entityService.get("10")).thenThrow(new RuntimeException("my exception")); tested.get("10"); }