@Test
  @Transactional
  public void createForum() throws Exception {
    int databaseSizeBeforeCreate = forumRepository.findAll().size();

    // Create the Forum
    restForumMockMvc
        .perform(
            post("/api/forums")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(forum)))
        .andExpect(status().isCreated());

    // Validate the Forum in the database
    List<Forum> forums = forumRepository.findAll();
    assertThat(forums).hasSize(databaseSizeBeforeCreate + 1);
    Forum testForum = forums.get(forums.size() - 1);
    assertThat(testForum.getName()).isEqualTo(DEFAULT_NAME);
    assertThat(testForum.getDescription()).isEqualTo(DEFAULT_DESCRIPTION);
    assertThat(testForum.getDisplay()).isEqualTo(DEFAULT_DISPLAY);
    assertThat(testForum.getLft()).isEqualTo(DEFAULT_LFT);
    assertThat(testForum.getRgt()).isEqualTo(DEFAULT_RGT);
    assertThat(testForum.getPostCount()).isEqualTo(DEFAULT_POST_COUNT);
    assertThat(testForum.getTopicCount()).isEqualTo(DEFAULT_TOPIC_COUNT);
    assertThat(testForum.getLocked()).isEqualTo(DEFAULT_LOCKED);
  }
  @Test
  @Transactional
  public void deleteForum() throws Exception {
    // Initialize the database
    forumRepository.saveAndFlush(forum);

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

    // Get the forum
    restForumMockMvc
        .perform(delete("/api/forums/{id}", forum.getId()).accept(TestUtil.APPLICATION_JSON_UTF8))
        .andExpect(status().isOk());

    // Validate the database is empty
    List<Forum> forums = forumRepository.findAll();
    assertThat(forums).hasSize(databaseSizeBeforeDelete - 1);
  }
  @Test
  @Transactional
  public void checkNameIsRequired() throws Exception {
    // Validate the database is empty
    assertThat(forumRepository.findAll()).hasSize(0);
    // set the field null
    forum.setName(null);

    // Create the Forum, which fails.
    restForumMockMvc
        .perform(
            post("/api/forums")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(forum)))
        .andExpect(status().isBadRequest());

    // Validate the database is still empty
    List<Forum> forums = forumRepository.findAll();
    assertThat(forums).hasSize(0);
  }
  @Test
  @Transactional
  public void updateForum() throws Exception {
    // Initialize the database
    forumRepository.saveAndFlush(forum);

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

    // Update the forum
    forum.setName(UPDATED_NAME);
    forum.setDescription(UPDATED_DESCRIPTION);
    forum.setDisplay(UPDATED_DISPLAY);
    forum.setLft(UPDATED_LFT);
    forum.setRgt(UPDATED_RGT);
    forum.setPostCount(UPDATED_POST_COUNT);
    forum.setTopicCount(UPDATED_TOPIC_COUNT);
    forum.setLocked(UPDATED_LOCKED);
    restForumMockMvc
        .perform(
            put("/api/forums")
                .contentType(TestUtil.APPLICATION_JSON_UTF8)
                .content(TestUtil.convertObjectToJsonBytes(forum)))
        .andExpect(status().isOk());

    // Validate the Forum in the database
    List<Forum> forums = forumRepository.findAll();
    assertThat(forums).hasSize(databaseSizeBeforeUpdate);
    Forum testForum = forums.get(forums.size() - 1);
    assertThat(testForum.getName()).isEqualTo(UPDATED_NAME);
    assertThat(testForum.getDescription()).isEqualTo(UPDATED_DESCRIPTION);
    assertThat(testForum.getDisplay()).isEqualTo(UPDATED_DISPLAY);
    assertThat(testForum.getLft()).isEqualTo(UPDATED_LFT);
    assertThat(testForum.getRgt()).isEqualTo(UPDATED_RGT);
    assertThat(testForum.getPostCount()).isEqualTo(UPDATED_POST_COUNT);
    assertThat(testForum.getTopicCount()).isEqualTo(UPDATED_TOPIC_COUNT);
    assertThat(testForum.getLocked()).isEqualTo(UPDATED_LOCKED);
  }