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