use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method createJsonTreeWithUnknownComponent.
private JsonNode createJsonTreeWithUnknownComponent() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode rootNode = jsonNodeFactory.objectNode();
ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
addHostGroup(hostGroupsNode, GROUP1, MA_MIN1_MAX1);
addHostGroup(hostGroupsNode, GROUP2, MA_MIN1_MAX5);
addHostGroup(hostGroupsNode, GROUP3, UNKNOWN);
return rootNode;
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method createJsonTreeWithTooMuchGroup.
private JsonNode createJsonTreeWithTooMuchGroup() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode rootNode = jsonNodeFactory.objectNode();
ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
addHostGroup(hostGroupsNode, GROUP1, MA_MIN1_MAX1);
addHostGroup(hostGroupsNode, GROUP2, MA_MIN1_MAX5);
addHostGroup(hostGroupsNode, GROUP3, MA_MIN1_MAX3);
addHostGroup(hostGroupsNode, GROUP4, SL_MIN0_MAX3);
return rootNode;
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method testKnoxWithKerberosButNoKnoxInTheBlueprintForAllNodes.
@Test
public void testKnoxWithKerberosButNoKnoxInTheBlueprintForAllNodes() throws IOException {
// GIVEN
Blueprint blueprint = createBlueprint();
Set<InstanceGroup> instanceGroups = new HashSet<>();
instanceGroups.add(createInstanceGroup("gateway1", 1, InstanceGroupType.GATEWAY));
instanceGroups.add(createInstanceGroup("gateway2", 1, InstanceGroupType.GATEWAY));
instanceGroups.add(createInstanceGroup("master", 1, InstanceGroupType.CORE));
Set<HostGroup> hostGroups = createHostGroups(instanceGroups);
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode rootNode = jsonNodeFactory.objectNode();
ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
addHostGroup(hostGroupsNode, "gateway1", SL_MIN0_MAX3, MA_MIN1_MAX1);
addHostGroup(hostGroupsNode, "gateway2", SL_MIN0_MAX3, MA_MIN1_MAX3);
addHostGroup(hostGroupsNode, "master", SL_MIN0_MAX3, MA_MIN1_MAX5);
BDDMockito.given(objectMapper.readTree(BLUEPRINT_STRING)).willReturn(rootNode);
Cluster cluster = new Cluster();
cluster.setSecure(true);
Gateway gateway = new Gateway();
gateway.setEnableGateway(true);
cluster.setGateway(gateway);
thrown.expect(BlueprintValidationException.class);
thrown.expectMessage("In case of Knox and Kerberos each 'Ambari Server' node must include the 'KNOX_GATEWAY' service. " + "The following host groups are missing the service: gateway1,gateway2");
// WHEN
underTest.validateBlueprintForStack(cluster, blueprint, hostGroups, instanceGroups);
// THEN exception thrown
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project cloudbreak by hortonworks.
the class BlueprintValidatorTest method createJsonTreeWithComponentIsLess.
private JsonNode createJsonTreeWithComponentIsLess() {
JsonNodeFactory jsonNodeFactory = JsonNodeFactory.instance;
ObjectNode rootNode = jsonNodeFactory.objectNode();
ArrayNode hostGroupsNode = rootNode.putArray("host_groups");
addHostGroup(hostGroupsNode, GROUP1, MA_MIN1_MAX1);
addHostGroup(hostGroupsNode, GROUP2, MA_MIN1_MAX3);
addHostGroup(hostGroupsNode, GROUP3, SL_MIN5_MAX6);
return rootNode;
}
use of com.fasterxml.jackson.databind.node.JsonNodeFactory in project cu-kfs by CU-CommunityApps.
the class MockServiceEndpointBase method buildJsonTextFromNode.
protected String buildJsonTextFromNode(Consumer<ObjectNode> jsonNodeConfigurer) {
String jsonText = null;
try {
ObjectMapper objectMapper = new ObjectMapper();
JsonNodeFactory nodeFactory = JsonNodeFactory.instance;
ObjectNode rootNode = nodeFactory.objectNode();
jsonNodeConfigurer.accept(rootNode);
jsonText = objectMapper.writeValueAsString(rootNode);
} catch (JsonProcessingException e) {
fail("Unexpected error when preparing JSON output: " + e.getMessage());
}
return jsonText;
}
Aggregations