コード例 #1
0
  @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);
  }
コード例 #2
0
 @Before
 public void initTest() {
   forum = new Forum();
   forum.setName(DEFAULT_NAME);
   forum.setDescription(DEFAULT_DESCRIPTION);
   forum.setDisplay(DEFAULT_DISPLAY);
   forum.setLft(DEFAULT_LFT);
   forum.setRgt(DEFAULT_RGT);
   forum.setPostCount(DEFAULT_POST_COUNT);
   forum.setTopicCount(DEFAULT_TOPIC_COUNT);
   forum.setLocked(DEFAULT_LOCKED);
 }
コード例 #3
0
  @Test
  @Transactional
  public void getForum() throws Exception {
    // Initialize the database
    forumRepository.saveAndFlush(forum);

    // Get the forum
    restForumMockMvc
        .perform(get("/api/forums/{id}", forum.getId()))
        .andExpect(status().isOk())
        .andExpect(content().contentType(MediaType.APPLICATION_JSON))
        .andExpect(jsonPath("$.id").value(forum.getId().intValue()))
        .andExpect(jsonPath("$.name").value(DEFAULT_NAME.toString()))
        .andExpect(jsonPath("$.description").value(DEFAULT_DESCRIPTION.toString()))
        .andExpect(jsonPath("$.display").value(DEFAULT_DISPLAY))
        .andExpect(jsonPath("$.lft").value(DEFAULT_LFT))
        .andExpect(jsonPath("$.rgt").value(DEFAULT_RGT))
        .andExpect(jsonPath("$.postCount").value(DEFAULT_POST_COUNT))
        .andExpect(jsonPath("$.topicCount").value(DEFAULT_TOPIC_COUNT))
        .andExpect(jsonPath("$.locked").value(DEFAULT_LOCKED.booleanValue()));
  }
コード例 #4
0
  @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);
  }
コード例 #5
0
  @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);
  }
コード例 #6
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);
  }