@Test public void listSerialiations() { Serialization serialization1 = new Serialization(); serialization1.setId("serialization-1"); Serialization serialization2 = new Serialization(); serialization2.setId("serialization-2"); List<Serialization> mockedSerializations = new ArrayList<Serialization>(); mockedSerializations.add(serialization1); mockedSerializations.add(serialization2); when(serializationServiceMock.listSerializations()).thenReturn(mockedSerializations); List<Serialization> responseSerializations = resource().path("/api/serializations") .accept(MediaType.APPLICATION_JSON).get(new GenericType<List<Serialization>>(){}); assertEquals("Response serializations should be equal to the mocked serializations", mockedSerializations, responseSerializations); verify(serializationServiceMock).listSerializations(); }
@GET @Produces(MediaType.APPLICATION_JSON) public List<Serialization> listSerializations() { return serializationService.listSerializations(); }
SerializationResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Serialization> listSerializations() { return serializationService.listSerializations(); } }
SerializationResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Serialization> listSerializations() { return serializationService.listSerializations(); } @Inject  SerializationResource(SerializationService serializationService); }
SerializationResource { @GET @Produces(MediaType.APPLICATION_JSON) public List<Serialization> listSerializations() { return serializationService.listSerializations(); } @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 @Produces(MediaType.APPLICATION_JSON) public List<Serialization> listSerializations() { return serializationService.listSerializations(); } @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);  }