@Test public void getSerialization() { final Serialization mockedSerialization = new Serialization(); mockedSerialization.setId("serialization-1"); when(serializationServiceMock.getSerialization(anyString())).then(new Answer<Serialization>() { @Override public Serialization answer(InvocationOnMock invocation) throws Throwable { String argSerializationId = (String) invocation.getArguments()[0]; assertEquals("Service serialization ID should match the requested serialization ID", argSerializationId, mockedSerialization.getId()); return mockedSerialization; } }); Serialization responseSerialization = resource().path("/api/serializations/" + mockedSerialization.getId()) .accept(MediaType.APPLICATION_JSON).get(Serialization.class); assertEquals("Response serialization should match the mocked serialization", mockedSerialization, responseSerialization); verify(serializationServiceMock).getSerialization(anyString()); }
@GET @Path("/{serializationId}") @Produces(MediaType.APPLICATION_JSON) public Serialization getSerialization(@PathParam("serializationId") String serializationId) { return serializationService.getSerialization(serializationId); }
SerializationResource { @GET @Path("/{serializationId}") @Produces(MediaType.APPLICATION_JSON) public Serialization getSerialization(@PathParam("serializationId") String serializationId) { return serializationService.getSerialization(serializationId); } }
SerializationResource { @GET @Path("/{serializationId}") @Produces(MediaType.APPLICATION_JSON) public Serialization getSerialization(@PathParam("serializationId") String serializationId) { return serializationService.getSerialization(serializationId); } @Inject  SerializationResource(SerializationService serializationService); }
SerializationResource { @GET @Path("/{serializationId}") @Produces(MediaType.APPLICATION_JSON) public Serialization getSerialization(@PathParam("serializationId") String serializationId) { return serializationService.getSerialization(serializationId); } @Inject  SerializationResource(SerializationService serializationService); @GET @Produces(MediaType.APPLICATION_JSON) List<Serialization> listSerializations(); @GET @Path("/{serializationId}") @Produces(MediaType.APPLICATION_JSON) Serialization getSerialization(@PathParam("serializationId") String serializationId); }
SerializationResource { @GET @Path("/{serializationId}") @Produces(MediaType.APPLICATION_JSON) public Serialization getSerialization(@PathParam("serializationId") String serializationId) { return serializationService.getSerialization(serializationId); } @Inject  SerializationResource(SerializationService serializationService); @GET @Produces(MediaType.APPLICATION_JSON) List<Serialization> listSerializations(); @GET @Path("/{serializationId}") @Produces(MediaType.APPLICATION_JSON) Serialization getSerialization(@PathParam("serializationId") String serializationId);  }