Search in sources :

Example 1 with JsonToString

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

the class StackStopRestrictionServiceTest method infrastructureShouldBeStoppableForValidInstanceGroups.

@Test
public void infrastructureShouldBeStoppableForValidInstanceGroups() {
    Set<InstanceGroup> groups = new HashSet<>();
    groups.add(createGroup(List.of("ebs"), temporaryStorage, "worker"));
    InstanceGroup master = createGroup(List.of("ebs"), temporaryStorage, "master");
    master.getTemplate().setAttributes(new JsonToString().convertToEntityAttribute("{\"sshLocation\":\"0.0.0.0/0\",\"encrypted\":false}"));
    groups.add(master);
    when(componentConfigProviderService.getCloudbreakDetails(any())).thenReturn(new CloudbreakDetails("2.47.0-bXX"));
    Assertions.assertEquals(StopRestrictionReason.NONE, underTest.isInfrastructureStoppable(createStack("AWS", groups)));
    when(componentConfigProviderService.getCloudbreakDetails(any())).thenReturn(new CloudbreakDetails("2.48.0-bXX"));
    Assertions.assertEquals(StopRestrictionReason.NONE, underTest.isInfrastructureStoppable(createStack("AWS", groups)));
}
Also used : JsonToString(com.sequenceiq.cloudbreak.common.json.JsonToString) CloudbreakDetails(com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails) InstanceGroup(com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup) HashSet(java.util.HashSet) Test(org.junit.jupiter.api.Test)

Example 2 with JsonToString

use of com.sequenceiq.cloudbreak.common.json.JsonToString 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)

Aggregations

JsonToString (com.sequenceiq.cloudbreak.common.json.JsonToString)2 BlueprintV4Response (com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.responses.BlueprintV4Response)1 CloudbreakDetails (com.sequenceiq.cloudbreak.cloud.model.CloudbreakDetails)1 AbstractEntityConverterTest (com.sequenceiq.cloudbreak.converter.AbstractEntityConverterTest)1 Blueprint (com.sequenceiq.cloudbreak.domain.Blueprint)1 InstanceGroup (com.sequenceiq.cloudbreak.domain.stack.instance.InstanceGroup)1 HashSet (java.util.HashSet)1 Test (org.junit.Test)1 Test (org.junit.jupiter.api.Test)1