Пример #1
0
  @Test
  @Transactional
  public void getCoupon() throws Exception {
    // Initialize the database
    couponRepository.saveAndFlush(coupon);

    // Get the coupon
    restCouponMockMvc
        .perform(get("/api/coupons/{id}", coupon.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(coupon.getId().intValue()))
        .andExpect(jsonPath("$.code").value(DEFAULT_CODE.toString()))
        .andExpect(jsonPath("$.password").value(DEFAULT_PASSWORD.toString()))
        .andExpect(jsonPath("$.category").value(DEFAULT_CATEGORY.intValue()))
        .andExpect(jsonPath("$.status").value(DEFAULT_STATUS.toString()));
  }
Пример #2
0
  @Test
  @Transactional
  public void deleteCoupon() throws Exception {
    // Initialize the database
    couponRepository.saveAndFlush(coupon);

    int databaseSizeBeforeDelete = couponRepository.findAll().size();

    // Get the coupon
    restCouponMockMvc
        .perform(delete("/api/coupons/{id}", coupon.getId()).accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<Coupon> coupons = couponRepository.findAll();
    assertThat(coupons).hasSize(databaseSizeBeforeDelete - 1);
  }