예제 #1
0
  @Test
  @Transactional
  public void updatePromotion() throws Exception {
    // Initialize the database
    promotionRepository.saveAndFlush(promotion);

    int databaseSizeBeforeUpdate = promotionRepository.findAll().size();

    // Update the promotion
    promotion.setName(UPDATED_NAME);
    promotion.setPercent(UPDATED_PERCENT);
    promotion.setReduction(UPDATED_REDUCTION);

    restPromotionMockMvc
        .perform(
            put("/api/promotions")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(promotion)))
        .andExpect(status().isOk());

    // Validate the Promotion in the database
    List<Promotion> promotions = promotionRepository.findAll();
    assertThat(promotions).hasSize(databaseSizeBeforeUpdate);
    Promotion testPromotion = promotions.get(promotions.size() - 1);
    assertThat(testPromotion.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testPromotion.getPercent()).isEqualTo(UPDATED_PERCENT);
    assertThat(testPromotion.getReduction()).isEqualTo(UPDATED_REDUCTION);
  }
예제 #2
0
 @Before
 public void initTest() {
   promotion = new Promotion();
   promotion.setName(DEFAULT_NAME);
   promotion.setPercent(DEFAULT_PERCENT);
   promotion.setReduction(DEFAULT_REDUCTION);
 }
예제 #3
0
  @Test
  @Transactional
  public void checkPercentIsRequired() throws Exception {
    int databaseSizeBeforeTest = promotionRepository.findAll().size();
    // set the field null
    promotion.setPercent(null);

    // Create the Promotion, which fails.

    restPromotionMockMvc
        .perform(
            post("/api/promotions")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(promotion)))
        .andExpect(status().isBadRequest());

    List<Promotion> promotions = promotionRepository.findAll();
    assertThat(promotions).hasSize(databaseSizeBeforeTest);
  }