Beispiel #1
0
  @Test
  @Transactional
  public void updateBlog() throws Exception {
    // Initialize the database
    blogRepository.saveAndFlush(blog);

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

    // Update the blog
    blog.setName(UPDATED_NAME);
    blog.setHandle(UPDATED_HANDLE);

    restBlogMockMvc
        .perform(
            put("/api/blogs")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(blog)))
        .andExpect(status().isOk());

    // Validate the Blog in the database
    List<Blog> blogs = blogRepository.findAll();
    assertThat(blogs).hasSize(databaseSizeBeforeUpdate);
    Blog testBlog = blogs.get(blogs.size() - 1);
    assertThat(testBlog.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testBlog.getHandle()).isEqualTo(UPDATED_HANDLE);
  }
Beispiel #2
0
  @Test
  @Transactional
  public void checkHandleIsRequired() throws Exception {
    int databaseSizeBeforeTest = blogRepository.findAll().size();
    // set the field null
    blog.setHandle(null);

    // Create the Blog, which fails.

    restBlogMockMvc
        .perform(
            post("/api/blogs")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(blog)))
        .andExpect(status().isBadRequest());

    List<Blog> blogs = blogRepository.findAll();
    assertThat(blogs).hasSize(databaseSizeBeforeTest);
  }
Beispiel #3
0
 @Before
 public void initTest() {
   blog = new Blog();
   blog.setName(DEFAULT_NAME);
   blog.setHandle(DEFAULT_HANDLE);
 }