UserResourceIntTest.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:devoxxus-jhipster-microservices-demo 作者:
@Test
@Transactional
public void createUserWithExistingEmail() throws Exception {
    // Initialize the database
    userRepository.saveAndFlush(user);
    int databaseSizeBeforeCreate = userRepository.findAll().size();

    Set<String> autorities = new HashSet<>();
    autorities.add("ROLE_USER");
    ManagedUserVM managedUserVM = new ManagedUserVM(
        null,
        "anotherlogin",
        DEFAULT_PASSWORD,
        DEFAULT_FIRSTNAME,
        DEFAULT_LASTNAME,
        DEFAULT_EMAIL, // this email should already be used
        true,
        DEFAULT_IMAGEURL,
        DEFAULT_LANGKEY,
        null,
        null,
        null,
        null,
        autorities);

    // Create the User
    restUserMockMvc.perform(post("/api/users")
        .contentType(TestUtil.APPLICATION_JSON_UTF8)
        .content(TestUtil.convertObjectToJsonBytes(managedUserVM)))
        .andExpect(status().isBadRequest());

    // Validate the User in the database
    List<User> userList = userRepository.findAll();
    assertThat(userList).hasSize(databaseSizeBeforeCreate);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号