Search in sources :

Example 6 with UserProfile

use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.

the class UserController method getProfile.

@Override
public UserProfileResponse getProfile() {
    IdentityUser user = authenticatedUserService.getCbUser();
    UserProfile userProfile = userProfileService.get(user.getAccount(), user.getUserId(), user.getUsername());
    return conversionService.convert(userProfile, UserProfileResponse.class);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile)

Example 7 with UserProfile

use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.

the class ImageCatalogServiceDefaultNotFoundTest method beforeTest.

@Before
public void beforeTest() throws Exception {
    String catalogJson = FileReaderUtils.readFileFromClasspath("com/sequenceiq/cloudbreak/service/image/no-default-imagecatalog.json");
    CloudbreakImageCatalogV2 catalog = JsonUtil.readValue(catalogJson, CloudbreakImageCatalogV2.class);
    when(imageCatalogProvider.getImageCatalogV2("")).thenReturn(catalog);
    IdentityUser user = getIdentityUser();
    when(authenticatedUserService.getCbUser()).thenReturn(user);
    when(userProfileService.get(user.getAccount(), user.getUserId(), user.getUsername())).thenReturn(new UserProfile());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) CloudbreakImageCatalogV2(com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2) Before(org.junit.Before)

Example 8 with UserProfile

use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.

the class UserProfileServiceTest method getShouldntDeleteUserName.

@Test
public void getShouldntDeleteUserName() {
    String account = "account1";
    String owner = "123-123-123";
    String savedUserName = "test@hortonworks.com";
    UserProfile foundProfile = new UserProfile();
    foundProfile.setOwner(owner);
    foundProfile.setAccount(account);
    foundProfile.setUserName(savedUserName);
    when(userProfileRepository.findOneByOwnerAndAccount(anyString(), anyString())).thenReturn(foundProfile);
    when(userProfileRepository.save(any(UserProfile.class))).thenReturn(new UserProfile());
    UserProfile returnedUserProfile = userProfileService.get(account, owner);
    verify(userProfileRepository, never()).save(any(UserProfile.class));
    assertNotNull(returnedUserProfile);
    assertEquals(account, returnedUserProfile.getAccount());
    assertEquals(owner, returnedUserProfile.getOwner());
    assertEquals(savedUserName, returnedUserProfile.getUserName());
}
Also used : UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 9 with UserProfile

use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.

the class UserProfileServiceTest method getWithUsername.

@Test
public void getWithUsername() {
    when(userProfileRepository.save(any(UserProfile.class))).thenReturn(new UserProfile());
    ArgumentCaptor<UserProfile> userProfileCaptor = ArgumentCaptor.forClass(UserProfile.class);
    String account = "account1";
    String owner = "123-123-123";
    String username = "test@hortonworks.com";
    UserProfile returnedUserProfile = userProfileService.get(account, owner, username);
    verify(userProfileRepository).save(userProfileCaptor.capture());
    UserProfile capturedProfile = userProfileCaptor.getValue();
    assertEquals(account, capturedProfile.getAccount());
    assertEquals(owner, capturedProfile.getOwner());
    assertEquals(username, capturedProfile.getUserName());
    assertNotNull(returnedUserProfile);
}
Also used : UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 10 with UserProfile

use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.

the class UserProfileServiceTest method getWithoutUsername.

@Test
public void getWithoutUsername() {
    when(userProfileRepository.save(any(UserProfile.class))).thenReturn(new UserProfile());
    ArgumentCaptor<UserProfile> userProfileCaptor = ArgumentCaptor.forClass(UserProfile.class);
    String account = "account1";
    String owner = "123-123-123";
    UserProfile returnedUserProfile = userProfileService.get(account, owner);
    verify(userProfileRepository).save(userProfileCaptor.capture());
    UserProfile capturedProfile = userProfileCaptor.getValue();
    assertEquals(account, capturedProfile.getAccount());
    assertEquals(owner, capturedProfile.getOwner());
    assertNull("username should be null", capturedProfile.getUserName());
    assertNotNull(returnedUserProfile);
}
Also used : UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

UserProfile (com.sequenceiq.cloudbreak.domain.UserProfile)17 Test (org.junit.Test)7 Matchers.anyString (org.mockito.Matchers.anyString)6 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)4 CloudbreakImageCatalogV2 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2)2 Cluster (com.sequenceiq.cloudbreak.domain.Cluster)2 Stack (com.sequenceiq.cloudbreak.domain.Stack)2 OperationDetails (com.sequenceiq.cloudbreak.structuredevent.event.OperationDetails)2 Before (org.junit.Before)2 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 Credential (com.sequenceiq.cloudbreak.domain.Credential)1 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)1 Json (com.sequenceiq.cloudbreak.domain.json.Json)1 BlueprintDetails (com.sequenceiq.cloudbreak.structuredevent.event.BlueprintDetails)1 ClusterDetails (com.sequenceiq.cloudbreak.structuredevent.event.ClusterDetails)1 NotificationDetails (com.sequenceiq.cloudbreak.structuredevent.event.NotificationDetails)1 StackDetails (com.sequenceiq.cloudbreak.structuredevent.event.StackDetails)1 StructuredFlowErrorEvent (com.sequenceiq.cloudbreak.structuredevent.event.StructuredFlowErrorEvent)1