Search in sources :

Example 36 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithAwsEncryption.

@Test
public void convertWithAwsEncryption() {
    InstanceTemplateV4Request source = getSampleAwsRequest();
    Template result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.convert(source));
    assertAwsEncryptionConvertResult(source, result);
    assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isEqualTo("myKey");
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Example 37 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithGcpEncryptionWithNullKey.

@Test
public void convertWithGcpEncryptionWithNullKey() {
    InstanceTemplateV4Request source = getSampleGcpRequest();
    source.getGcp().getEncryption().setKey(null);
    Template result = underTest.convert(source);
    assertGcpEncryptionConvertResult(source, result);
    assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isNull();
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Example 38 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithGcpEncryption.

@Test
public void convertWithGcpEncryption() {
    InstanceTemplateV4Request source = getSampleGcpRequest();
    Template result = underTest.convert(source);
    assertGcpEncryptionConvertResult(source, result);
    assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isEqualTo("myKey");
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Example 39 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class InstanceTemplateV4RequestToTemplateConverterTest method convertWithAwsEncryptionWithNullKey.

@Test
public void convertWithAwsEncryptionWithNullKey() {
    InstanceTemplateV4Request source = getSampleAwsRequest();
    source.getAws().getEncryption().setKey(null);
    Template result = ThreadBasedUserCrnProvider.doAs(USER_CRN, () -> underTest.convert(source));
    assertAwsEncryptionConvertResult(source, result);
    assertThat(new Json(result.getSecretAttributes()).getMap().get(InstanceTemplate.VOLUME_ENCRYPTION_KEY_ID)).isNull();
}
Also used : InstanceTemplateV4Request(com.sequenceiq.cloudbreak.api.endpoint.v4.stacks.request.instancegroup.template.InstanceTemplateV4Request) Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceTemplate(com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate) Template(com.sequenceiq.cloudbreak.domain.Template) Test(org.junit.jupiter.api.Test)

Example 40 with Json

use of com.sequenceiq.cloudbreak.common.json.Json in project cloudbreak by hortonworks.

the class CloudResourceToResourceConverterTest method convert.

@Test
void convert() throws JsonProcessingException {
    Map<String, Object> parameters = Map.of("key", "test");
    Json attributes = new Json(parameters);
    Resource convertedResource = underTest.convert(CloudResource.builder().type(ResourceType.AWS_ENCRYPTED_AMI).status(CommonStatus.REQUESTED).name("ami-01231h231").group("group").instanceId("id").params(Map.of(CloudResource.ATTRIBUTES, Map.of("key", "test"))).reference("ref").build());
    assertEquals(ResourceType.AWS_ENCRYPTED_AMI, convertedResource.getResourceType());
    assertEquals(CommonStatus.REQUESTED, convertedResource.getResourceStatus());
    assertEquals("ami-01231h231", convertedResource.getResourceName());
    assertEquals("ref", convertedResource.getResourceReference());
    assertEquals("group", convertedResource.getInstanceGroup());
    assertEquals("id", convertedResource.getInstanceId());
    assertEquals(attributes.getValue(), convertedResource.getAttributes().getValue());
}
Also used : Resource(com.sequenceiq.cloudbreak.domain.Resource) CloudResource(com.sequenceiq.cloudbreak.cloud.model.CloudResource) Json(com.sequenceiq.cloudbreak.common.json.Json) Test(org.junit.jupiter.api.Test)

Aggregations

Json (com.sequenceiq.cloudbreak.common.json.Json)266 Test (org.junit.jupiter.api.Test)95 HashMap (java.util.HashMap)49 InstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.InstanceTemplate)31 Template (com.sequenceiq.freeipa.entity.Template)26 AwsInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AwsInstanceTemplate)25 List (java.util.List)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)24 AzureInstanceTemplate (com.sequenceiq.cloudbreak.cloud.model.instance.AzureInstanceTemplate)23 Map (java.util.Map)22 Stack (com.sequenceiq.cloudbreak.domain.stack.Stack)21 InstanceMetaData (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceMetaData)21 ArrayList (java.util.ArrayList)21 Test (org.junit.Test)21 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)20 IOException (java.io.IOException)20 Cluster (com.sequenceiq.cloudbreak.domain.stack.cluster.Cluster)18 RestRequestDetails (com.sequenceiq.cloudbreak.structuredevent.event.rest.RestRequestDetails)16 DetailedEnvironmentResponse (com.sequenceiq.environment.api.v1.environment.model.response.DetailedEnvironmentResponse)16 BadRequestException (com.sequenceiq.cloudbreak.common.exception.BadRequestException)14