Search in sources :

Example 6 with ImageCatalog

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

the class ImageCatalogServiceTest method testGetWhenEnvDefault.

@Test
public void testGetWhenEnvDefault() {
    String name = "cloudbreak-default";
    ImageCatalog actual = underTest.get(name);
    verify(imageCatalogRepository, times(0)).findByName(name, USER_ID, ACCOUNT);
    Assert.assertEquals(actual.getImageCatalogName(), name);
    Assert.assertNull(actual.getId());
}
Also used : ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.Test)

Example 7 with ImageCatalog

use of com.sequenceiq.cloudbreak.domain.ImageCatalog 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());
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) UserProfile(com.sequenceiq.cloudbreak.domain.UserProfile) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.Test)

Example 8 with ImageCatalog

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

the class ImageCatalogV1Controller method createImageCatalog.

private ImageCatalogResponse createImageCatalog(ImageCatalogRequest imageCatalogRequest, boolean publicInAccount) {
    IdentityUser identityUser = authenticatedUserService.getCbUser();
    ImageCatalog imageCatalog = conversionService.convert(imageCatalogRequest, ImageCatalog.class);
    imageCatalog.setAccount(identityUser.getAccount());
    imageCatalog.setOwner(identityUser.getUserId());
    imageCatalog.setPublicInAccount(publicInAccount);
    imageCatalog = imageCatalogService.create(imageCatalog);
    return convert(imageCatalog);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog)

Example 9 with ImageCatalog

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

the class ImageCatalogServiceTest method testGetImagesWhenCustomImageCatalogExists.

@Test
public void testGetImagesWhenCustomImageCatalogExists() throws Exception {
    ImageCatalog ret = new ImageCatalog();
    ret.setImageCatalogUrl("");
    when(imageCatalogRepository.findByName("name", "userId", "account")).thenReturn(ret);
    when(imageCatalogProvider.getImageCatalogV2("")).thenReturn(null);
    underTest.getImages("name", "aws");
    verify(imageCatalogProvider, times(1)).getImageCatalogV2("");
}
Also used : ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.Test)

Example 10 with ImageCatalog

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

the class ImageCatalogServiceTest method testGet.

@Test
public void testGet() {
    String name = "img-name";
    ImageCatalog imageCatalog = new ImageCatalog();
    IdentityUser user = getIdentityUser();
    when(authenticatedUserService.getCbUser()).thenReturn(user);
    when(imageCatalogRepository.findByName(name, user.getUserId(), user.getAccount())).thenReturn(imageCatalog);
    ImageCatalog actual = underTest.get(name);
    Assert.assertEquals(actual, imageCatalog);
}
Also used : IdentityUser(com.sequenceiq.cloudbreak.common.model.user.IdentityUser) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) Test(org.junit.Test)

Aggregations

ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)17 IdentityUser (com.sequenceiq.cloudbreak.common.model.user.IdentityUser)7 Test (org.junit.Test)4 BadRequestException (com.sequenceiq.cloudbreak.controller.BadRequestException)2 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)2 UserProfile (com.sequenceiq.cloudbreak.domain.UserProfile)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Versioned (com.sequenceiq.cloudbreak.cloud.model.Versioned)1 CloudbreakImageCatalogV2 (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakImageCatalogV2)1 CloudbreakVersion (com.sequenceiq.cloudbreak.cloud.model.catalog.CloudbreakVersion)1 Image (com.sequenceiq.cloudbreak.cloud.model.catalog.Image)1 Images (com.sequenceiq.cloudbreak.cloud.model.catalog.Images)1 APIResourceType (com.sequenceiq.cloudbreak.common.type.APIResourceType)1 AuthenticatedUserService (com.sequenceiq.cloudbreak.controller.AuthenticatedUserService)1 NotFoundException (com.sequenceiq.cloudbreak.controller.NotFoundException)1 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)1 ImageCatalogRepository (com.sequenceiq.cloudbreak.repository.ImageCatalogRepository)1 AuthorizationService (com.sequenceiq.cloudbreak.service.AuthorizationService)1 AccountPreferencesService (com.sequenceiq.cloudbreak.service.account.AccountPreferencesService)1 StatedImage.statedImage (com.sequenceiq.cloudbreak.service.image.StatedImage.statedImage)1