Search in sources :

Example 66 with Json

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

the class ComponentConfigProviderServiceTest method replaceImageComponentWithNew.

@Test
public void replaceImageComponentWithNew() {
    Stack stack = new Stack();
    stack.setId(1L);
    Component original = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json("asdf"), stack);
    Component modified = new Component(ComponentType.IMAGE, ComponentType.IMAGE.name(), new Json("fdas"), stack);
    when(componentRepository.findComponentByStackIdComponentTypeName(eq(stack.getId()), eq(original.getComponentType()), eq(original.getName()))).thenReturn(Optional.of(original));
    componentConfigProviderService.replaceImageComponentWithNew(modified);
    ArgumentCaptor<Component> argument = ArgumentCaptor.forClass(Component.class);
    verify(componentRepository).save(argument.capture());
    assertEquals(modified.getAttributes(), argument.getValue().getAttributes());
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json) Component(com.sequenceiq.cloudbreak.domain.stack.Component) Stack(com.sequenceiq.cloudbreak.domain.stack.Stack) Test(org.junit.Test)

Example 67 with Json

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

the class JsonTest method testMembers.

@Test
public void testMembers() throws JsonProcessingException {
    Map<InstanceGroupType, String> userData = new EnumMap<>(InstanceGroupType.class);
    userData.put(InstanceGroupType.CORE, "CORE");
    Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    Json json = new Json(image);
    Assert.assertEquals("{\"imageName\":\"cb-centos66-amb200-2015-05-25\",\"userdata\":{\"CORE\":\"CORE\"},\"os\":\"redhat6\",\"osType\":\"redhat6\"," + "\"imageCatalogUrl\":\"\",\"imageCatalogName\":\"default\",\"imageId\":\"default-id\",\"packageVersions\":{}}", json.getValue());
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 68 with Json

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

the class JsonTest method testMultipleSerialisation.

// The reason for this to check whether serialisetion-deserialisation-serialisation results the same json
@Test
public void testMultipleSerialisation() throws IOException {
    Map<InstanceGroupType, String> userData = new EnumMap<>(InstanceGroupType.class);
    userData.put(InstanceGroupType.CORE, "CORE");
    Image image = new Image("cb-centos66-amb200-2015-05-25", userData, "redhat6", "redhat6", "", "default", "default-id", new HashMap<>());
    Json json = new Json(image);
    String expected = json.getValue();
    Image covertedAgain = json.get(Image.class);
    json = new Json(covertedAgain);
    Assert.assertEquals(expected, json.getValue());
}
Also used : InstanceGroupType(com.sequenceiq.common.api.type.InstanceGroupType) Json(com.sequenceiq.cloudbreak.common.json.Json) Image(com.sequenceiq.cloudbreak.cloud.model.Image) EnumMap(java.util.EnumMap) Test(org.junit.Test)

Example 69 with Json

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

the class GcsFileSystemConfigurator method getPrivateKey.

private String getPrivateKey(Credential credential) {
    Json attibutesFromVault = new Json(credential.getAttributes());
    Object serviceAccountPrivateKey = attibutesFromVault.getMap().get("serviceAccountPrivateKey");
    if (serviceAccountPrivateKey == null) {
        LOGGER.debug("ServiceAccountPrivateKey isn't set.");
        return "";
    }
    return serviceAccountPrivateKey.toString();
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json)

Example 70 with Json

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

the class InstanceGroupToInstanceGroupDetailsConverterTest method createInstanceGroup.

private InstanceGroup createInstanceGroup() {
    InstanceGroup instanceGroup = new InstanceGroup();
    Template template = new Template();
    Map<String, Object> attributes = Map.of("encrypted", Boolean.TRUE, "everything-else", Boolean.TRUE);
    template.setAttributes(new Json(attributes));
    template.setCloudPlatform("AWS");
    instanceGroup.setTemplate(template);
    return instanceGroup;
}
Also used : Json(com.sequenceiq.cloudbreak.common.json.Json) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) Template(com.sequenceiq.cloudbreak.domain.Template)

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