Search in sources :

Example 56 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverterTest method testConvertWheBlueprintExists.

@Test
public void testConvertWheBlueprintExists() {
    String blueprintName = "bp-name";
    Blueprint blueprint = new Blueprint();
    blueprint.setName(blueprintName);
    ClusterV4Request source = new ClusterV4Request();
    source.setBlueprintName(blueprintName);
    when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(blueprintName, workspace)).thenReturn(blueprint);
    Cluster actual = underTest.convert(source);
    assertThat(actual.getBlueprint(), is(blueprint));
    verify(blueprintService, times(1)).getByNameForWorkspaceAndLoadDefaultsIfNecessary(blueprintName, workspace);
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 57 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverterTest method testConvertWhenRdsConfigNotExists.

@Test
public void testConvertWhenRdsConfigNotExists() {
    ClusterV4Request source = new ClusterV4Request();
    Set<String> rdsConfigNames = singleton("fake-rds-name");
    when(rdsConfigService.findByNamesInWorkspace(rdsConfigNames, workspace.getId())).thenReturn(emptySet());
    source.setDatabases(rdsConfigNames);
    Exception exception = assertThrows(NotFoundException.class, () -> underTest.convert(source));
    assertEquals("RDS config names do not exist", exception.getMessage());
    verify(rdsConfigService, times(1)).findByNamesInWorkspace(rdsConfigNames, workspace.getId());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) NotFoundException(com.sequenceiq.cloudbreak.common.exception.NotFoundException) Test(org.junit.jupiter.api.Test)

Example 58 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverterTest method testConvertClouderaManagerRequestWithNullProductList.

@Test
public void testConvertClouderaManagerRequestWithNullProductList() {
    ClusterV4Request request = new ClusterV4Request();
    request.setBlueprintName(BLUEPRINT);
    blueprint.setStackType(StackType.CDH.name());
    when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
    ClouderaManagerV4Request cm = new ClouderaManagerV4Request();
    ClouderaManagerRepositoryV4Request repository = new ClouderaManagerRepositoryV4Request();
    repository.setBaseUrl("base.url");
    repository.setVersion("1.0");
    repository.setGpgKeyUrl("gpg.key.url");
    cm.setRepository(repository);
    request.setCm(cm);
    Cluster cluster = underTest.convert(request);
    assertFalse(cluster.getComponents().isEmpty());
    assertEquals(1, cluster.getComponents().size());
    ClusterComponent component = cluster.getComponents().iterator().next();
    assertEquals(ComponentType.CM_REPO_DETAILS, component.getComponentType());
    Json expectedRepoJson = new Json(repository);
    assertEquals(expectedRepoJson.getMap().size() + 1, component.getAttributes().getMap().size());
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) ClusterComponent(com.sequenceiq.cloudbreak.domain.stack.cluster.ClusterComponent) ClouderaManagerRepositoryV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) Json(com.sequenceiq.cloudbreak.common.json.Json) ClouderaManagerV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request) Test(org.junit.jupiter.api.Test)

Example 59 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class ClusterV4RequestToClusterConverterTest method testConvertWhenGatewayExists.

@Test
public void testConvertWhenGatewayExists() {
    String clusterName = "cluster-name";
    ClusterV4Request source = new ClusterV4Request();
    GatewayV4Request gatewayJson = new GatewayV4Request();
    source.setGateway(gatewayJson);
    source.setBlueprintName(BLUEPRINT);
    when(blueprintService.getByNameForWorkspaceAndLoadDefaultsIfNecessary(eq(BLUEPRINT), any())).thenReturn(blueprint);
    Gateway gateway = new Gateway();
    when(gatewayV4RequestToGatewayConverter.convert(gatewayJson)).thenReturn(gateway);
    Cluster actual = underTest.convert(source);
    assertThat(actual.getGateway(), is(gateway));
    verify(gatewayV4RequestToGatewayConverter, times(1)).convert(gatewayJson);
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) GatewayV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request) Gateway(com.sequenceiq.cloudbreak.domain.stack.cluster.gateway.Gateway) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.jupiter.api.Test)

Example 60 with ClusterV4Request

use of com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request in project cloudbreak by hortonworks.

the class AutoTlsFlagPreparatoryTest method testAutoTlsSettingFromPlatformParameterWithParent.

@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void testAutoTlsSettingFromPlatformParameterWithParent(String value) {
    ClusterV4Request request = new ClusterV4Request();
    Stack stack = new Stack();
    stack.setPlatformVariant("var");
    CloudConnector<Object> connector = mock(CloudConnector.class);
    when(cloudPlatformConnectors.get(Platform.platform("magic"), Variant.variant("var"))).thenReturn(connector);
    PlatformParameters platformParameters = mock(PlatformParameters.class);
    when(connector.parameters()).thenReturn(platformParameters);
    when(platformParameters.isAutoTlsSupported()).thenReturn(Boolean.valueOf(value));
    boolean result = underTest.provideAutoTlsFlag(request, stack, Optional.of("magic"));
    assertEquals(Boolean.valueOf(value), result);
}
Also used : ClusterV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request) PlatformParameters(com.sequenceiq.cloudbreak.cloud.PlatformParameters) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ClusterV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.ClusterV4Request)90 Test (org.junit.jupiter.api.Test)59 ClouderaManagerV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.ClouderaManagerV4Request)16 CloudStorageRequest (com.sequenceiq.common.api.cloudstorage.CloudStorageRequest)14 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)14 Test (org.junit.Test)13 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)13 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)12 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)10 SdxClusterRequest (com.sequenceiq.sdx.api.model.SdxClusterRequest)10 StackV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.StackV4Request)9 GatewayV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.gateway.GatewayV4Request)9 ClouderaManagerRepositoryV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.repository.ClouderaManagerRepositoryV4Request)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)8 SdxCloudStorageRequest (com.sequenceiq.sdx.api.model.SdxCloudStorageRequest)8 ClouderaManagerProductV4Request (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.cluster.cm.product.ClouderaManagerProductV4Request)7 ThreadBasedUserCrnProvider (com.sequenceiq.cloudbreak.auth.ThreadBasedUserCrnProvider)7 StorageLocationBase (com.sequenceiq.common.api.cloudstorage.StorageLocationBase)7 List (java.util.List)7 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)6