Example #1
0
  @Test
  @Transactional
  public void updateNews() throws Exception {
    // Initialize the database
    newsRepository.saveAndFlush(news);

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

    // Update the news
    news.setTitle(UPDATED_TITLE);
    news.setDate(UPDATED_DATE);
    news.setContent(UPDATED_CONTENT);

    restNewsMockMvc
        .perform(
            put("/api/newss")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(news)))
        .andExpect(status().isOk());

    // Validate the News in the database
    List<News> newss = newsRepository.findAll();
    assertThat(newss).hasSize(databaseSizeBeforeUpdate);
    News testNews = newss.get(newss.size() - 1);
    assertThat(testNews.getTitle()).isEqualTo(UPDATED_TITLE);
    assertThat(testNews.getDate()).isEqualTo(UPDATED_DATE);
    assertThat(testNews.getContent()).isEqualTo(UPDATED_CONTENT);
  }
Example #2
0
 @Before
 public void initTest() {
   news = new News();
   news.setTitle(DEFAULT_TITLE);
   news.setDate(DEFAULT_DATE);
   news.setContent(DEFAULT_CONTENT);
 }
Example #3
0
  @Test
  @Transactional
  public void checkContentIsRequired() throws Exception {
    int databaseSizeBeforeTest = newsRepository.findAll().size();
    // set the field null
    news.setContent(null);

    // Create the News, which fails.

    restNewsMockMvc
        .perform(
            post("/api/newss")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(news)))
        .andExpect(status().isBadRequest());

    List<News> newss = newsRepository.findAll();
    assertThat(newss).hasSize(databaseSizeBeforeTest);
  }