OrderResource { @GET @Path("/orders") public Response findAll(@BeanParam PageableImpl pageable) { LOGGER.debug("REST request to get all Users"); return Response.ok().entity(orderService.findAll(pageable)).build(); } @Inject  OrderResource(OrderService orderService); @GET @Path("/orders") Response findAll(@BeanParam PageableImpl pageable); @GET @Path("/orders/me") Response findMyData(); @GET @Path("/orders/{id}") Response findById(@PathParam("id") long id); @POST @Path("/orders") Response create(OrderDTO orderDTO); @DELETE @Path("/orders/{id}") Response delete(@PathParam("id") long id);  }
@Test public void createOrder() { int databaseSizeBeforeCreate = orderRepository.findAll().size(); given() .contentType(JSON) .body(orderMapper.toDto(this.order)) .when().post("/api/orders") .then() .statusCode(201); List<Order> orderList = orderRepository.findAll(); Assertions.assertEquals(orderList.size(), databaseSizeBeforeCreate + 1); Order order = orderList.get(orderList.size() - 1); Assertions.assertEquals(order.getTotalPrice().floatValue(), DEFAULT_TOTAL_PRICE.floatValue()); }
@Test public void createOrderWithExistingId() { int databaseSizeBeforeCreate = orderRepository.findAll().size(); order.setId(10L); given() .contentType(JSON) .body(order) .when().post("/api/orders") .then() .statusCode(400); List<Order> orderList = orderRepository.findAll(); Assertions.assertEquals(orderList.size(), databaseSizeBeforeCreate); }