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());
}
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());
}
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());
}
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();
}
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;
}
Aggregations