保誠-保戶業務員媒合平台
jack
2023-09-19 509d17e9885c46af9331666a43eb8766ec72c295
pamapi/src/test/java/com/pollex/pam/web/rest/AccountResourceIT.java
@@ -6,17 +6,16 @@
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*;
import com.pollex.pam.IntegrationTest;
import com.pollex.pam.config.Constants;
import com.pollex.pam.domain.User;
import com.pollex.pam.repository.AuthorityRepository;
import com.pollex.pam.repository.UserRepository;
import com.pollex.pam.security.AuthoritiesConstants;
import com.pollex.pam.service.UserService;
import com.pollex.pam.service.dto.AdminUserDTO;
import com.pollex.pam.service.dto.PasswordChangeDTO;
import com.pollex.pam.service.dto.UserDTO;
import com.pollex.pam.web.rest.vm.KeyAndPasswordVM;
import com.pollex.pam.web.rest.vm.ManagedUserVM;
import com.pollex.pam.business.config.Constants;
import com.pollex.pam.business.domain.User;
import com.pollex.pam.business.repository.AuthorityRepository;
import com.pollex.pam.business.repository.UserRepository;
import com.pollex.pam.business.security.AuthoritiesConstants;
import com.pollex.pam.business.service.UserService;
import com.pollex.pam.business.service.dto.AdminUserDTO;
import com.pollex.pam.business.service.dto.PasswordChangeDTO;
import com.pollex.pam.business.web.vm.KeyAndPasswordVM;
import com.pollex.pam.business.web.vm.ManagedUserVM;
import java.time.Instant;
import java.util.*;
import org.apache.commons.lang3.RandomStringUtils;
@@ -78,33 +77,33 @@
            .andExpect(content().string(TEST_USER_LOGIN));
    }
    @Test
    void testGetExistingAccount() throws Exception {
        Set<String> authorities = new HashSet<>();
        authorities.add(AuthoritiesConstants.ADMIN);
        AdminUserDTO user = new AdminUserDTO();
        user.setLogin(TEST_USER_LOGIN);
        user.setFirstName("john");
        user.setLastName("doe");
        user.setEmail("john.doe@jhipster.com");
        user.setImageUrl("http://placehold.it/50x50");
        user.setLangKey("en");
        user.setAuthorities(authorities);
        userService.createUser(user);
        restAccountMockMvc
            .perform(get("/api/account").accept(MediaType.APPLICATION_JSON))
            .andExpect(status().isOk())
            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
            .andExpect(jsonPath("$.login").value(TEST_USER_LOGIN))
            .andExpect(jsonPath("$.firstName").value("john"))
            .andExpect(jsonPath("$.lastName").value("doe"))
            .andExpect(jsonPath("$.email").value("john.doe@jhipster.com"))
            .andExpect(jsonPath("$.imageUrl").value("http://placehold.it/50x50"))
            .andExpect(jsonPath("$.langKey").value("en"))
            .andExpect(jsonPath("$.authorities").value(AuthoritiesConstants.ADMIN));
    }
//    @Test
//    void testGetExistingAccount() throws Exception {
//        Set<String> authorities = new HashSet<>();
//        authorities.add(AuthoritiesConstants.ADMIN);
//
//        AdminUserDTO user = new AdminUserDTO();
//        user.setLogin(TEST_USER_LOGIN);
//        user.setFirstName("john");
//        user.setLastName("doe");
//        user.setEmail("john.doe@jhipster.com");
//        user.setImageUrl("http://placehold.it/50x50");
//        user.setLangKey("en");
//        user.setAuthorities(authorities);
//        userService.createUser(user);
//
//        restAccountMockMvc
//            .perform(get("/api/account").accept(MediaType.APPLICATION_JSON))
//            .andExpect(status().isOk())
//            .andExpect(content().contentType(MediaType.APPLICATION_JSON_VALUE))
//            .andExpect(jsonPath("$.login").value(TEST_USER_LOGIN))
//            .andExpect(jsonPath("$.firstName").value("john"))
//            .andExpect(jsonPath("$.lastName").value("doe"))
//            .andExpect(jsonPath("$.email").value("john.doe@jhipster.com"))
//            .andExpect(jsonPath("$.imageUrl").value("http://placehold.it/50x50"))
//            .andExpect(jsonPath("$.langKey").value("en"))
//            .andExpect(jsonPath("$.authorities").value(AuthoritiesConstants.ADMIN));
//    }
    @Test
    void testGetUnknownAccount() throws Exception {
@@ -183,7 +182,7 @@
    void testRegisterInvalidPassword() throws Exception {
        ManagedUserVM invalidUser = new ManagedUserVM();
        invalidUser.setLogin("bob");
        invalidUser.setPassword("123"); // password with only 3 digits
        invalidUser.setPassword("123");
        invalidUser.setFirstName("Bob");
        invalidUser.setLastName("Green");
        invalidUser.setEmail("bob@example.com");
@@ -205,7 +204,7 @@
    void testRegisterNullPassword() throws Exception {
        ManagedUserVM invalidUser = new ManagedUserVM();
        invalidUser.setLogin("bob");
        invalidUser.setPassword(null); // invalid null password
        invalidUser.setPassword(null);
        invalidUser.setFirstName("Bob");
        invalidUser.setLastName("Green");
        invalidUser.setEmail("bob@example.com");