use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.
the class ImageCatalogServiceDefaultTest method beforeTest.
@Before
public void beforeTest() throws Exception {
MockitoAnnotations.initMocks(this);
String catalogJson = FileReaderUtils.readFileFromClasspath(catalogFile);
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 ImageCatalogServiceTest method testDeleteImageCatalog.
@Test
public void testDeleteImageCatalog() {
String name = "img-name";
IdentityUser user = getIdentityUser();
UserProfile userProfile = new UserProfile();
ImageCatalog imageCatalog = new ImageCatalog();
imageCatalog.setImageCatalogName(name);
imageCatalog.setArchived(false);
when(authenticatedUserService.getCbUser()).thenReturn(user);
when(imageCatalogRepository.findByName(name, user.getUserId(), user.getAccount())).thenReturn(imageCatalog);
when(userProfileService.get(user.getAccount(), user.getUserId(), user.getUsername())).thenReturn(userProfile);
underTest.delete(name);
verify(imageCatalogRepository, times(1)).save(imageCatalog);
Assert.assertTrue(imageCatalog.isArchived());
Assert.assertTrue(imageCatalog.getImageCatalogName().startsWith(name) && imageCatalog.getImageCatalogName().indexOf("_") == name.length());
}
use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.
the class UserProfileCredentialHandler method destroyProfilePreparation.
public void destroyProfilePreparation(Credential credential) {
Set<UserProfile> userProfiles = userProfileService.findOneByCredentialId(credential.getId());
for (UserProfile userProfile : userProfiles) {
userProfile.setCredential(null);
userProfileService.save(userProfile);
}
}
use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.
the class UserProfileCredentialHandler method createProfilePreparation.
public void createProfilePreparation(Credential credential) {
UserProfile userProfile = userProfileService.get(credential.getAccount(), credential.getOwner());
if (userProfile != null && userProfile.getCredential() == null) {
userProfile.setCredential(credential);
userProfileService.save(userProfile);
}
}
use of com.sequenceiq.cloudbreak.domain.UserProfile in project cloudbreak by hortonworks.
the class UserProfileServiceTest method getEmptyUserName.
@Test
public void getEmptyUserName() {
String account = "account1";
String owner = "123-123-123";
UserProfile foundProfile = new UserProfile();
foundProfile.setOwner(owner);
foundProfile.setAccount(account);
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));
assertEquals(account, returnedUserProfile.getAccount());
assertEquals(owner, returnedUserProfile.getOwner());
assertNotNull(returnedUserProfile);
assertNull(returnedUserProfile.getUserName());
}
Aggregations