Advertisement
Guest User

Untitled

a guest
Mar 3rd, 2015
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. @Named
  2. @Path(CUSTOMERS_PATH)
  3. @Produces(MediaType.APPLICATION_JSON)
  4. public class CustomerResourceImpl extends AbstractResource implements
  5. ICustomerResource
  6.  
  7. ...
  8.  
  9. @Override
  10. @POST
  11. @Consumes(MediaType.APPLICATION_JSON)
  12. public Response add(final CustomerDto pDto) {
  13. try {
  14. getService().add(pDto);
  15. } catch (final ValidationException ve) {
  16. badRequest(ve.getErrors());
  17. }
  18.  
  19. return Response.ok().build();
  20. }
  21.  
  22. }
  23.  
  24. @Test
  25. public void addTest() {
  26. final Response response = target(NameTokens.CUSTOMERS_PATH).request()
  27. .header("Content-Type", MediaType.APPLICATION_JSON)
  28. .post(Entity.entity(new CustomerDto(), MediaType.APPLICATION_JSON));
  29.  
  30. Assert.assertNotNull(response, "Response cannot be null");
  31. Assert.assertEquals(response.getStatus(), Status.OK.getStatusCode(),
  32. "Response status code isn't ok");
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement