@Test @Transactional public void updateCoupon() throws Exception { // Initialize the database couponRepository.saveAndFlush(coupon); int databaseSizeBeforeUpdate = couponRepository.findAll().size(); // Update the coupon coupon.setCode(UPDATED_CODE); coupon.setPassword(UPDATED_PASSWORD); coupon.setCategory(UPDATED_CATEGORY); coupon.setStatus(STATUS.Unused); restCouponMockMvc .perform( put("/api/coupons") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(coupon))) .andExpect(status().isOk()); // Validate the Coupon in the database List<Coupon> coupons = couponRepository.findAll(); assertThat(coupons).hasSize(databaseSizeBeforeUpdate); Coupon testCoupon = coupons.get(coupons.size() - 1); assertThat(testCoupon.getCode()).isEqualTo(UPDATED_CODE); assertThat(testCoupon.getPassword()).isEqualTo(UPDATED_PASSWORD); assertThat(testCoupon.getCategory()).isEqualTo(UPDATED_CATEGORY); assertThat(testCoupon.getStatus()).isEqualTo(UPDATED_STATUS); }
@Test @Transactional public void createCoupon() throws Exception { int databaseSizeBeforeCreate = couponRepository.findAll().size(); // Create the Coupon restCouponMockMvc .perform( post("/api/coupons") .contentType(TestUtil.APPLICATION_JSON_UTF8) .content(TestUtil.convertObjectToJsonBytes(coupon))) .andExpect(status().isCreated()); // Validate the Coupon in the database List<Coupon> coupons = couponRepository.findAll(); assertThat(coupons).hasSize(databaseSizeBeforeCreate + 1); Coupon testCoupon = coupons.get(coupons.size() - 1); assertThat(testCoupon.getCode()).isEqualTo(DEFAULT_CODE); assertThat(testCoupon.getPassword()).isEqualTo(DEFAULT_PASSWORD); assertThat(testCoupon.getCategory()).isEqualTo(DEFAULT_CATEGORY); assertThat(testCoupon.getStatus()).isEqualTo(DEFAULT_STATUS); }