Search in sources :

Example 1 with PLATFORM

use of com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM in project cloudbreak by hortonworks.

the class ImageServiceTest method testGivenBaseImageIdAndDisabledBaseImageShouldReturnError.

@Test
public void testGivenBaseImageIdAndDisabledBaseImageShouldReturnError() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    when(imageCatalogService.getImageByCatalogName(anyLong(), anyString(), anyString())).thenReturn(ImageTestUtil.getImageFromCatalog(false, "uuid", STACK_VERSION));
    CloudbreakImageCatalogException exception = assertThrows(CloudbreakImageCatalogException.class, () -> underTest.determineImageFromCatalog(WORKSPACE_ID, imageSettingsV4Request, PLATFORM, PLATFORM, TestUtil.blueprint(), false, false, TestUtil.user(USER_ID, USER_ID_STRING), image -> true));
    assertEquals("Inconsistent request, base images are disabled but image with id uuid is base image!", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Mock(org.mockito.Mock) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) ImageCatalogPlatform.imageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform) MockitoAnnotations(org.mockito.MockitoAnnotations) StackMatrixService(com.sequenceiq.cloudbreak.service.StackMatrixService) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) PLATFORM(com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM) MethodSource(org.junit.jupiter.params.provider.MethodSource) InjectMocks(org.mockito.InjectMocks) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) Mockito.when(org.mockito.Mockito.when) Arguments(org.junit.jupiter.params.provider.Arguments) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) CloudPlatformConnectors(com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors) Assert.assertFalse(org.junit.Assert.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 2 with PLATFORM

use of com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM in project cloudbreak by hortonworks.

the class ImageServiceTest method testUseBaseImageAndDisabledBaseImageShouldReturnError.

@Test
public void testUseBaseImageAndDisabledBaseImageShouldReturnError() {
    imageSettingsV4Request.setId(null);
    CloudbreakImageCatalogException exception = assertThrows(CloudbreakImageCatalogException.class, () -> underTest.determineImageFromCatalog(WORKSPACE_ID, imageSettingsV4Request, PLATFORM, PLATFORM, TestUtil.blueprint(), true, false, TestUtil.user(USER_ID, USER_ID_STRING), image -> true));
    assertEquals("Inconsistent request, base images are disabled but custom repo information is submitted!", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Mock(org.mockito.Mock) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) ImageCatalogPlatform.imageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform) MockitoAnnotations(org.mockito.MockitoAnnotations) StackMatrixService(com.sequenceiq.cloudbreak.service.StackMatrixService) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) PLATFORM(com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM) MethodSource(org.junit.jupiter.params.provider.MethodSource) InjectMocks(org.mockito.InjectMocks) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) Mockito.when(org.mockito.Mockito.when) Arguments(org.junit.jupiter.params.provider.Arguments) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) CloudPlatformConnectors(com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors) Assert.assertFalse(org.junit.Assert.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 3 with PLATFORM

use of com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM in project cloudbreak by hortonworks.

the class ImageServiceTest method testDetermineImageFromCatalogWithNonExistingCatalogNameAndIdSpecified.

@Test
public void testDetermineImageFromCatalogWithNonExistingCatalogNameAndIdSpecified() throws CloudbreakImageNotFoundException, CloudbreakImageCatalogException {
    when(imageCatalogService.getImageByCatalogName(WORKSPACE_ID, "anImageId", "aCatalog")).thenThrow(new CloudbreakImageCatalogException("Image catalog not found with name: aCatalog"));
    CloudbreakImageCatalogException exception = assertThrows(CloudbreakImageCatalogException.class, () -> underTest.determineImageFromCatalog(WORKSPACE_ID, imageSettingsV4Request, PLATFORM, PLATFORM, TestUtil.blueprint(), true, true, TestUtil.user(USER_ID, USER_ID_STRING), image -> true));
    assertEquals("Image catalog not found with name: aCatalog", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Mock(org.mockito.Mock) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) ImageCatalogPlatform.imageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform) MockitoAnnotations(org.mockito.MockitoAnnotations) StackMatrixService(com.sequenceiq.cloudbreak.service.StackMatrixService) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) PLATFORM(com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM) MethodSource(org.junit.jupiter.params.provider.MethodSource) InjectMocks(org.mockito.InjectMocks) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) Mockito.when(org.mockito.Mockito.when) Arguments(org.junit.jupiter.params.provider.Arguments) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) CloudPlatformConnectors(com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors) Assert.assertFalse(org.junit.Assert.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 4 with PLATFORM

use of com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM in project cloudbreak by hortonworks.

the class ImageServiceTest method testDetermineImageFromCatalogWithNonExistingCatalogName.

@Test
public void testDetermineImageFromCatalogWithNonExistingCatalogName() {
    when(imageCatalogService.getImageCatalogByName(WORKSPACE_ID, "aCatalog")).thenThrow(new NotFoundException("Image catalog not found with name: aCatalog"));
    ImageSettingsV4Request imageRequest = new ImageSettingsV4Request();
    imageRequest.setCatalog("aCatalog");
    imageRequest.setOs(OS);
    CloudbreakImageCatalogException exception = assertThrows(CloudbreakImageCatalogException.class, () -> underTest.determineImageFromCatalog(WORKSPACE_ID, imageRequest, PLATFORM, PLATFORM, TestUtil.blueprint(), true, true, TestUtil.user(USER_ID, USER_ID_STRING), image -> true));
    assertEquals("Image catalog not found with name: aCatalog", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ArgumentMatchers.any(org.mockito.ArgumentMatchers.any) BeforeEach(org.junit.jupiter.api.BeforeEach) ArgumentMatchers.anyLong(org.mockito.ArgumentMatchers.anyLong) Mock(org.mockito.Mock) TestUtil(com.sequenceiq.cloudbreak.TestUtil) ComponentConfigProviderService(com.sequenceiq.cloudbreak.service.ComponentConfigProviderService) ImageCatalogPlatform.imageCatalogPlatform(com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform) MockitoAnnotations(org.mockito.MockitoAnnotations) StackMatrixService(com.sequenceiq.cloudbreak.service.StackMatrixService) ClusterComponentConfigProvider(com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) PLATFORM(com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM) MethodSource(org.junit.jupiter.params.provider.MethodSource) InjectMocks(org.mockito.InjectMocks) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) Mockito.when(org.mockito.Mockito.when) Arguments(org.junit.jupiter.params.provider.Arguments) ImageCatalog(com.sequenceiq.cloudbreak.domain.ImageCatalog) CloudConnector(com.sequenceiq.cloudbreak.cloud.CloudConnector) Workspace(com.sequenceiq.cloudbreak.workspace.model.Workspace) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) Stream(java.util.stream.Stream) CloudPlatformConnectors(com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors) Assert.assertFalse(org.junit.Assert.assertFalse) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) BlueprintUtils(com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) ImageSettingsV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) CloudbreakImageNotFoundException(com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException) CloudbreakImageCatalogException(com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

TestUtil (com.sequenceiq.cloudbreak.TestUtil)4 ImageSettingsV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.image.ImageSettingsV4Request)4 CloudConnector (com.sequenceiq.cloudbreak.cloud.CloudConnector)4 CloudPlatformConnectors (com.sequenceiq.cloudbreak.cloud.init.CloudPlatformConnectors)4 ClusterComponentConfigProvider (com.sequenceiq.cloudbreak.cluster.service.ClusterComponentConfigProvider)4 BlueprintUtils (com.sequenceiq.cloudbreak.cmtemplate.utils.BlueprintUtils)4 NotFoundException (com.sequenceiq.cloudbreak.common.exception.NotFoundException)4 CloudbreakImageCatalogException (com.sequenceiq.cloudbreak.core.CloudbreakImageCatalogException)4 CloudbreakImageNotFoundException (com.sequenceiq.cloudbreak.core.CloudbreakImageNotFoundException)4 ImageCatalog (com.sequenceiq.cloudbreak.domain.ImageCatalog)4 ComponentConfigProviderService (com.sequenceiq.cloudbreak.service.ComponentConfigProviderService)4 StackMatrixService (com.sequenceiq.cloudbreak.service.StackMatrixService)4 PLATFORM (com.sequenceiq.cloudbreak.service.image.ImageTestUtil.PLATFORM)4 ImageCatalogPlatform.imageCatalogPlatform (com.sequenceiq.cloudbreak.service.image.catalog.model.ImageCatalogPlatform.imageCatalogPlatform)4 Workspace (com.sequenceiq.cloudbreak.workspace.model.Workspace)4 Stream (java.util.stream.Stream)4 Assert.assertFalse (org.junit.Assert.assertFalse)4 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)4 Assertions.assertThrows (org.junit.jupiter.api.Assertions.assertThrows)4 Assertions.assertTrue (org.junit.jupiter.api.Assertions.assertTrue)4