Ejemplo n.º 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);
  }
Ejemplo n.º 2
0
  @Test
  @Transactional
  public void deleteBlog() throws Exception {
    // Initialize the database
    blogRepository.saveAndFlush(blog);

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

    // Get the blog
    restBlogMockMvc
        .perform(delete("/api/blogs/{id}", blog.getId()).accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<Blog> blogs = blogRepository.findAll();
    assertThat(blogs).hasSize(databaseSizeBeforeDelete - 1);
  }
Ejemplo n.º 3
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);
  }
Ejemplo n.º 4
0
  @Test
  @Transactional
  public void createBlog() throws Exception {
    int databaseSizeBeforeCreate = blogRepository.findAll().size();

    // Create the Blog

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

    // Validate the Blog in the database
    List<Blog> blogs = blogRepository.findAll();
    assertThat(blogs).hasSize(databaseSizeBeforeCreate + 1);
    Blog testBlog = blogs.get(blogs.size() - 1);
    assertThat(testBlog.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testBlog.getHandle()).isEqualTo(DEFAULT_HANDLE);
  }
Ejemplo n.º 5
0
  @Test
  @Transactional
  public void getBlog() throws Exception {
    // Initialize the database
    blogRepository.saveAndFlush(blog);

    // Get the blog
    restBlogMockMvc
        .perform(get("/api/blogs/{id}", blog.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(blog.getId().intValue()))
        .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()))
        .andExpect(jsonPath("$.handle").value(DEFAULT_HANDLE.toString()));
  }