예제 #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
  @Test
  @Transactional
  public void createPromotion() throws Exception {
    int databaseSizeBeforeCreate = promotionRepository.findAll().size();

    // Create the Promotion

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

    // Validate the Promotion in the database
    List<Promotion> promotions = promotionRepository.findAll();
    assertThat(promotions).hasSize(databaseSizeBeforeCreate + 1);
    Promotion testPromotion = promotions.get(promotions.size() - 1);
    assertThat(testPromotion.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testPromotion.getPercent()).isEqualTo(DEFAULT_PERCENT);
    assertThat(testPromotion.getReduction()).isEqualTo(DEFAULT_REDUCTION);
  }