Search in sources :

Example 1 with BlueprintV4Response

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);
}
Also used : ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) StackV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response) BlueprintV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response)

Example 2 with BlueprintV4Response

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));
}
Also used : JsonToString(com.sequenceiq.cloudbreak.common.json.JsonToString) BlueprintV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) JsonToString(com.sequenceiq.cloudbreak.common.json.JsonToString) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Example 3 with BlueprintV4Response

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);
}
Also used : SecretResponse(com.sequenceiq.cloudbreak.service.secret.model.SecretResponse) ClusterV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response) BlueprintV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) Cluster(com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Example 4 with BlueprintV4Response

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;
}
Also used : BlueprintV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response)

Example 5 with BlueprintV4Response

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());
}
Also used : BlueprintV4Response(com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response) Blueprint(com.sequenceiq.cloudbreak.domain.Blueprint) AbstractEntityConverterTest(com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest) Test(org.junit.Test)

Aggregations

BlueprintV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response)11 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)8 Test (org.junit.Test)8 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)7 JsonToString (com.sequenceiq.cloudbreak.common.json.JsonToString)3 ClusterV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.cluster.ClusterV4Response)2 BlueprintV4ViewResponse (com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4ViewResponse)1 StackV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.response.StackV4Response)1 Json (com.sequenceiq.cloudbreak.common.json.Json)1 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)1 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)1 SecretResponse (com.sequenceiq.cloudbreak.service.secret.model.SecretResponse)1 IntegrationTestContext (com.sequenceiq.it.IntegrationTestContext)1 CloudbreakClient (com.sequenceiq.it.cloudbreak.CloudbreakClient)1 CloudbreakTest (com.sequenceiq.it.cloudbreak.CloudbreakTest)1 Entity (com.sequenceiq.it.cloudbreak.Entity)1 BlueprintTestDto (com.sequenceiq.it.cloudbreak.dto.blueprint.BlueprintTestDto)1 Log (com.sequenceiq.it.cloudbreak.log.Log)1 IOException (java.io.IOException)1 Collection (java.util.Collection)1