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);
}
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());
}
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());
}
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);
}
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);
}
Aggregations