@Test @Transactional public void updateOrderItem() throws Exception { // Initialize the database orderItemRepository.saveAndFlush(orderItem); int databaseSizeBeforeUpdate = orderItemRepository.findAll().size(); // Update the orderItem orderItem.setPrice(UPDATED_PRICE); orderItem.setQty(UPDATED_QTY); orderItem.setNotes(UPDATED_NOTES); orderItem.setOrderIndex(UPDATED_ORDER_INDEX); orderItem.setSerialNumber(UPDATED_SERIAL_NUMBER); restOrderItemMockMvc .perform( put("/api/orderItems") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(orderItem))) .andExpect(status().isOk()); // Validate the OrderItem in the database List<OrderItem> orderItems = orderItemRepository.findAll(); assertThat(orderItems).hasSize(databaseSizeBeforeUpdate); OrderItem testOrderItem = orderItems.get(orderItems.size() - 1); assertThat(testOrderItem.getPrice()).isEqualTo(UPDATED_PRICE); assertThat(testOrderItem.getQty()).isEqualTo(UPDATED_QTY); assertThat(testOrderItem.getNotes()).isEqualTo(UPDATED_NOTES); assertThat(testOrderItem.getOrderIndex()).isEqualTo(UPDATED_ORDER_INDEX); assertThat(testOrderItem.getSerialNumber()).isEqualTo(UPDATED_SERIAL_NUMBER); }
@Test @Transactional public void getOrderItem() throws Exception { // Initialize the database orderItemRepository.saveAndFlush(orderItem); // Get the orderItem restOrderItemMockMvc .perform(get("/api/orderItems/{id}", orderItem.getId())) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON)) .andExpect(jsonPath("$.id").value(orderItem.getId().intValue())) .andExpect(jsonPath("$.price").value(DEFAULT_PRICE.intValue())) .andExpect(jsonPath("$.qty").value(DEFAULT_QTY)) .andExpect(jsonPath("$.notes").value(DEFAULT_NOTES.toString())) .andExpect(jsonPath("$.orderIndex").value(DEFAULT_ORDER_INDEX)) .andExpect(jsonPath("$.serialNumber").value(DEFAULT_SERIAL_NUMBER.toString())); }
@Test @Transactional public void deleteOrderItem() throws Exception { // Initialize the database orderItemRepository.saveAndFlush(orderItem); int databaseSizeBeforeDelete = orderItemRepository.findAll().size(); // Get the orderItem restOrderItemMockMvc .perform( delete("/api/orderItems/{id}", orderItem.getId()) .accept(TestUtil.APPLICATION_JSON_UTF8)) .andExpect(status().isOk()); // Validate the database is empty List<OrderItem> orderItems = orderItemRepository.findAll(); assertThat(orderItems).hasSize(databaseSizeBeforeDelete - 1); }