Search in sources :

Example 1 with UserDto

use of org.eclipse.vorto.repository.web.account.dto.UserDto in project vorto by eclipse.

the class AccountControllerTest method verifyTechnicalUserCreatedBy.

@Test
public void verifyTechnicalUserCreatedBy() throws Exception {
    UserDto payload = UserDto.fromUser(new UserBuilder().withName("theTechnicalUser").withAuthenticationProviderID("GITHUB").withAuthenticationSubject("theSubject").build());
    repositoryServer.perform(post("/rest/accounts/createTechnicalUser").content(objectMapper.writeValueAsString(payload)).contentType("application/json").with(userSysadmin)).andExpect(status().isCreated());
    // fetch sysadmin id
    User sysadmin = userRepository.findByUsername(USER_SYSADMIN_NAME);
    assertNotNull(sysadmin);
    // compare with the tech user created by
    User theTechnicalUser = userRepository.findByUsername("theTechnicalUser");
    assertNotNull(theTechnicalUser);
    assertEquals(sysadmin.getId(), theTechnicalUser.getCreatedBy());
}
Also used : User(org.eclipse.vorto.repository.domain.User) UserDto(org.eclipse.vorto.repository.web.account.dto.UserDto) UserBuilder(org.eclipse.vorto.repository.services.UserBuilder) Test(org.junit.Test)

Aggregations

User (org.eclipse.vorto.repository.domain.User)1 UserBuilder (org.eclipse.vorto.repository.services.UserBuilder)1 UserDto (org.eclipse.vorto.repository.web.account.dto.UserDto)1 Test (org.junit.Test)1