### Question:
RestEntityServiceBase extends RestServiceBase { @GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @AuditIgnore public Object get(@PathParam("id") @AuditId String id) { if ((id = SearchUtils.trimToNull(id)) == null) { throw new RequiredFieldException("id"); } Map<String, Object> ret = entityService.get(id); if (ret == null) { return Response.status(Response.Status.NOT_FOUND).build(); } return ret; }  @GET @Path("/") @Produces(MediaType.APPLICATION_JSON) @AuditIgnore Object getAll(@QueryParam("from") Integer from, @QueryParam("size") Integer size); @GET @Path("/{id}") @Produces(MediaType.APPLICATION_JSON) @AuditIgnore Object get(@PathParam("id") @AuditId 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); @DELETE @Path("/{id}") Object delete(@PathParam("id") @AuditId String id);  }### Answer:
@Test(expected = RequiredFieldException.class) public void get_inputParamValidation_1() { RestEntityServiceBase tested = getTested(); tested.get(null); }
@Test(expected = RequiredFieldException.class) public void get_inputParamValidation_2() { RestEntityServiceBase tested = getTested(); tested.get(""); }
@Test public void get() { RestEntityServiceBase tested = getTested(); Map<String, Object> m = new HashMap<String, Object>(); Mockito.when(tested.entityService.get("10")).thenReturn(m); Assert.assertEquals(m, tested.get("10")); Mockito.verify(tested.entityService).get("10"); Mockito.verifyNoMoreInteractions(tested.entityService); Mockito.reset(tested.entityService); Mockito.when(tested.entityService.get("10")).thenReturn(null); Assert.assertEquals(Response.Status.NOT_FOUND.getStatusCode(), ((Response) tested.get("10")).getStatus()); Mockito.verify(tested.entityService).get("10"); Mockito.verifyNoMoreInteractions(tested.entityService); Mockito.reset(tested.entityService); Mockito.when(tested.entityService.get("10")).thenThrow(new RuntimeException("my exception")); try { tested.get("10"); Assert.fail("RuntimeException expected"); } catch (RuntimeException e) { Mockito.verify(tested.entityService).get("10"); Mockito.verifyNoMoreInteractions(tested.entityService); } }
@Test public void createResponseWithId() { RestEntityServiceBase tested = getTested(); Map<String, Object> m = tested.createResponseWithId("22"); Assert.assertEquals("22", m.get("id")); }