use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class DefaulBlueprintCacheTest method testOnlyReleasedBps.
@Test
public void testOnlyReleasedBps() throws IOException {
// GIVEN
Blueprint bp1 = new Blueprint();
bp1.setName("bp1");
bp1.setBlueprintText("txt");
bp1.setStackName("stckn");
bp1.setStackType("stckt");
bp1.setStackVersion("stckv");
String bp1JsonString = "{\"inputs\":[],\"blueprint\":{\"Blueprints\":{\"blueprint_name\":\"bp1\"}}}";
JsonNode bpText1 = JsonUtil.readTree(bp1JsonString);
when(blueprintUtils.convertStringToJsonNode(any())).thenReturn(bpText1);
Blueprint bp2 = new Blueprint();
bp2.setName("bp2");
bp2.setBlueprintText("txt");
bp2.setStackName("stckn");
bp2.setStackType("stckt");
bp2.setStackVersion("stckv");
String bp2JsonString = "{\"inputs\":[],\"blueprint\":{\"Blueprints\":{\"blueprint_name\":\"bp2\"}}}";
JsonNode bpText2 = JsonUtil.readTree(bp2JsonString);
when(blueprintUtils.convertStringToJsonNode(any())).thenReturn(bpText2);
when(blueprintUtils.isBlueprintNamePreConfigured(anyString(), any())).thenReturn(true);
when(blueprintEntities.getDefaults()).thenReturn(Map.of("7.0.2", "Description2=bp2;Description1=bp1"));
when(converter.convert(any(BlueprintV4Request.class))).thenAnswer(invocation -> {
BlueprintV4Request request = invocation.getArgument(0);
if ("Description1".equalsIgnoreCase(request.getName())) {
return bp1;
}
return bp2;
});
// WHEN
underTest.loadBlueprintsFromFile();
Map<String, BlueprintFile> defaultBlueprints = underTest.defaultBlueprints();
// WHEN
assertEquals(2L, defaultBlueprints.size());
assertEquals("Description1", defaultBlueprints.get("bp1").getDescription());
assertEquals("Description2", defaultBlueprints.get("bp2").getDescription());
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class BlueprintV4RequestToBlueprintConverterTest method rejectsBuiltinWithoutContent.
@Test
public void rejectsBuiltinWithoutContent() {
BlueprintV4Request request = new BlueprintV4Request();
request.setBlueprint("{ \"blueprint\": {}");
thrown.expect(BadRequestException.class);
thrown.expectMessage("Invalid cluster template: Failed to parse JSON.");
underTest.convert(request);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class BlueprintV4RequestToBlueprintConverterTest method testConvertShouldThrowExceptionWhenTheBlueprintJsonIsInvalid.
@Test(expected = BadRequestException.class)
public void testConvertShouldThrowExceptionWhenTheBlueprintJsonIsInvalid() {
BlueprintV4Request request = new BlueprintV4Request();
String blueprint = "{}";
request.setBlueprint(blueprint);
when(jsonHelper.createJsonFromString(blueprint)).thenThrow(new CloudbreakApiException("Invalid Json"));
underTest.convert(request);
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class BlueprintToBlueprintV4RequestConverter method convert.
public BlueprintV4Request convert(Blueprint source) {
BlueprintV4Request blueprintV4Request = new BlueprintV4Request();
blueprintV4Request.setName(source.getName());
blueprintV4Request.setDescription(source.getDescription());
blueprintV4Request.setBlueprint(source.getBlueprintText());
blueprintV4Request.setDescription(source.getDescription());
return blueprintV4Request;
}
use of com.sequenceiq.cloudbreak.api.endpoint.v4.blueprint.requests.BlueprintV4Request in project cloudbreak by hortonworks.
the class DefaulBlueprintCacheTest method testLoadBlueprintsFromFileWithUpgradeOptions.
@Test
public void testLoadBlueprintsFromFileWithUpgradeOptions() throws IOException {
// GIVEN
Blueprint bp1 = new Blueprint();
bp1.setName("bp1");
bp1.setBlueprintText("txt");
bp1.setStackName("stckn");
bp1.setStackType("stckt");
bp1.setStackVersion("stckv");
String bp1JsonString = "{\"description\":\"7.2.10 - Data Engineering\",\"blueprint\":{\"cdhVersion\":\"7.2.10\",\"displayName\":\"dataengineering\"," + "\"blueprintUpgradeOption\":\"DISABLED\"}}";
JsonNode bpText1 = JsonUtil.readTree(bp1JsonString);
when(blueprintUtils.convertStringToJsonNode(any())).thenReturn(bpText1);
when(blueprintEntities.getDefaults()).thenReturn(Map.of("7.2.10", "Description1=bp1"));
when(blueprintUtils.isBlueprintNamePreConfigured(anyString(), any())).thenReturn(true);
when(converter.convert(any(BlueprintV4Request.class))).thenAnswer(invocation -> {
BlueprintV4Request request = invocation.getArgument(0);
return bp1;
});
underTest.loadBlueprintsFromFile();
Map<String, BlueprintFile> defaultBlueprints = underTest.defaultBlueprints();
assertEquals(1L, defaultBlueprints.size());
assertEquals("7.2.10 - Data Engineering", defaultBlueprints.get("bp1").getDescription());
assertEquals(BlueprintUpgradeOption.DISABLED, defaultBlueprints.get("bp1").getBlueprintUpgradeOption());
}
Aggregations