use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response in project cloudbreak by hortonworks.
the class StackResponseUtilsTest method validateGetRoleConfigNameForHostGroup.
private void validateGetRoleConfigNameForHostGroup(String testService, String testRole, String testHostGroup, String expectedRoleConfigName) throws Exception {
StackV4Response mockStackResponse = mock(StackV4Response.class);
ClusterV4Response mockCluster = mock(ClusterV4Response.class);
BlueprintV4Response mockBluePrint = mock(BlueprintV4Response.class);
when(mockStackResponse.getCluster()).thenReturn(mockCluster);
when(mockCluster.getBlueprint()).thenReturn(mockBluePrint);
when(mockBluePrint.getBlueprint()).thenReturn(getTestBP());
String hostGroupRolename = underTest.getRoleConfigNameForHostGroup(mockStackResponse, testHostGroup, testService, testRole);
assertEquals("RoleConfigName in template should match for HostGroup", expectedRoleConfigName, hostGroupRolename);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response in project cloudbreak by hortonworks.
the class BlueprintToBlueprintV4ResponseConverterTest method testConvertContainsExpectedSingleKeyValuePairInTagsProperty.
@Test
public void testConvertContainsExpectedSingleKeyValuePairInTagsProperty() {
String key = "name";
String name = "greg";
Blueprint source = createSource();
source.setTags(new JsonToString().convertToEntityAttribute(String.format("{\"%s\":\"%s\"}", key, name)));
BlueprintV4Response result = underTest.convert(source);
Assert.assertNotNull(result.getTags());
Assert.assertTrue(result.getTags().containsKey(key));
Assert.assertNotNull(result.getTags().get(key));
Assert.assertEquals(name, result.getTags().get(key));
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response in project cloudbreak by hortonworks.
the class ClusterToClusterV4ResponseConverterTest method testConvert.
@Test
public void testConvert() {
// GIVEN
getSource().setConfigStrategy(ConfigStrategy.NEVER_APPLY);
getSource().setBlueprint(new Blueprint());
getSource().setExtendedBlueprintText("asdf");
getSource().setFqdn("some.fqdn");
getSource().setCertExpirationState(CertExpirationState.HOST_CERT_EXPIRING);
given(stackUtil.extractClusterManagerIp(any(Stack.class))).willReturn("10.0.0.1");
given(stackUtil.extractClusterManagerAddress(any(Stack.class))).willReturn("some.fqdn");
Cluster source = getSource();
TestUtil.setSecretField(Cluster.class, "cloudbreakAmbariUser", source, "user", "secret/path");
TestUtil.setSecretField(Cluster.class, "cloudbreakAmbariPassword", source, "pass", "secret/path");
TestUtil.setSecretField(Cluster.class, "dpAmbariUser", source, "user", "secret/path");
TestUtil.setSecretField(Cluster.class, "dpAmbariPassword", source, "pass", "secret/path");
when(stringToSecretResponseConverter.convert("secret/path")).thenReturn(new SecretResponse("kv", "pass"));
when(blueprintToBlueprintV4ResponseConverter.convert(getSource().getBlueprint())).thenReturn(new BlueprintV4Response());
when(serviceEndpointCollector.getManagerServerUrl(any(Cluster.class), anyString())).thenReturn("http://server/");
given(proxyConfigDtoService.getByCrn(anyString())).willReturn(ProxyConfig.builder().withCrn("crn").withName("name").build());
// WHEN
ClusterV4Response result = underTest.convert(source);
// THEN
assertEquals(1L, (long) result.getId());
assertEquals(getSource().getExtendedBlueprintText(), result.getExtendedBlueprintText());
assertEquals(CertExpirationState.HOST_CERT_EXPIRING, result.getCertExpirationState());
List<String> skippedFields = Lists.newArrayList("customContainers", "cm", "creationFinished", "cloudStorage", "gateway", "customConfigurationsName", "customConfigurationsCrn");
assertAllFieldsNotNull(result, skippedFields);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response in project cloudbreak by hortonworks.
the class BlueprintToBlueprintV4ResponseConverter method convert.
public BlueprintV4Response convert(Blueprint entity) {
BlueprintV4Response blueprintJson = new BlueprintV4Response();
blueprintJson.setName(entity.getName());
blueprintJson.setDescription(entity.getDescription() == null ? "" : entity.getDescription());
blueprintJson.setHostGroupCount(entity.getHostGroupCount());
blueprintJson.setStatus(entity.getStatus());
blueprintJson.setTags(entity.getTags().getMap());
blueprintJson.setBlueprint(entity.getBlueprintText());
blueprintJson.setCrn(entity.getResourceCrn());
blueprintJson.setCreated(entity.getCreated());
return blueprintJson;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response in project cloudbreak by hortonworks.
the class BlueprintToBlueprintV4ResponseConverterTest method testConvertWhereEveryDataHasTransferredCorrectlyToResponseAndEntityDescriptionIsNotNullThenResultDescriptionShouldBeEmpty.
@Test
public void testConvertWhereEveryDataHasTransferredCorrectlyToResponseAndEntityDescriptionIsNotNullThenResultDescriptionShouldBeEmpty() {
Blueprint source = createSource();
source.setDescription("some description");
source.setTags(JSON_TO_STRING.convertToEntityAttribute("{}"));
BlueprintV4Response result = underTest.convert(source);
Assert.assertNotNull(result);
Assert.assertEquals(source.getResourceCrn(), result.getCrn());
Assert.assertEquals(source.getName(), result.getName());
Assert.assertEquals(source.getDescription(), result.getDescription());
Assert.assertEquals(Integer.valueOf(source.getHostGroupCount()), result.getHostGroupCount());
Assert.assertEquals(source.getStatus(), result.getStatus());
Assert.assertNotNull(result.getTags());
Assert.assertTrue(result.getTags().isEmpty());
Assert.assertEquals(source.getBlueprintText(), result.getBlueprint());
}
Aggregations