Package com.sequenceiq.cloudbreak.controller.json

Examples of com.sequenceiq.cloudbreak.controller.json.BlueprintJson


    private JsonHelper jsonHelper;

    @Override
    public BlueprintJson convert(Blueprint entity) {
        MDCBuilder.buildMdcContext(entity);
        BlueprintJson blueprintJson = new BlueprintJson();
        blueprintJson.setId(String.valueOf(entity.getId()));
        blueprintJson.setBlueprintName(entity.getBlueprintName());
        blueprintJson.setName(entity.getName());
        blueprintJson.setDescription(entity.getDescription() == null ? "" : entity.getDescription());
        blueprintJson.setHostGroupCount(entity.getHostGroupCount());
        try {
            blueprintJson.setAmbariBlueprint(jsonHelper.createJsonFromString(entity.getBlueprintText()));
        } catch (Exception e) {
            LOGGER.error("Blueprint cannot be converted to JSON.", e);
            blueprintJson.setAmbariBlueprint(new TextNode(e.getMessage()));
        }
        return blueprintJson;
    }
View Full Code Here


    public Set<BlueprintJson> convertAllToIdList(Collection<Blueprint> entityList) {
        return FluentIterable.from(entityList).transform(new Function<Blueprint, BlueprintJson>() {
            @Override
            public BlueprintJson apply(Blueprint e) {
                BlueprintJson blueprintJson = new BlueprintJson();
                blueprintJson.setName(e.getName());
                blueprintJson.setBlueprintName(e.getBlueprintName());
                blueprintJson.setId(String.valueOf(e.getId()));
                return convert(e);
            }
        }).toSet();
    }
View Full Code Here

        Set<Blueprint> blueprints = new HashSet<>();
        for (String blueprintName : blueprintArray) {
            MDCBuilder.buildMdcContext();
            LOGGER.info("Adding default blueprint '{}' for user '{}'", blueprintName, user.getUsername());
            try {
                BlueprintJson blueprintJson = new BlueprintJson();
                blueprintJson.setBlueprintName(blueprintName);
                blueprintJson.setName(blueprintName);
                blueprintJson.setDescription(blueprintName);
                blueprintJson.setAmbariBlueprint(
                        jsonHelper.createJsonFromString(FileReaderUtils.readFileFromClasspath(String.format("blueprints/%s.bp", blueprintName))));

                Blueprint bp = blueprintConverter.convert(blueprintJson);
                MDCBuilder.buildMdcContext(bp);
                bp.setOwner(user.getUserId());
View Full Code Here

    @Test
    public void testConvertBlueprintEntityToJsonWhenCouldNotConvertJson() {
        // GIVEN
        given(jsonHelper.createJsonFromString(anyString())).willThrow(new IllegalStateException(ERROR_MSG));
        // WHEN
        BlueprintJson blueprintJson = underTest.convert(blueprint);
        // THEN
        assertEquals(blueprintJson.getAmbariBlueprint(), "\"" + ERROR_MSG + "\"");
    }
View Full Code Here

        // THEN
        assertEquals(result.getBlueprintText(), blueprintJson.getAmbariBlueprint());
    }

    private BlueprintJson createBlueprintJson() {
        BlueprintJson blueprintJson = new BlueprintJson();
        blueprintJson.setBlueprintName(DUMMY_NAME);
        blueprintJson.setId(DUMMY_ID);
        blueprintJson.setAmbariBlueprint(jsonNode);
        blueprintJson.setUrl(DUMMY_URL);
        blueprintJson.setDescription(DUMMY_DESCRIPTION);
        return blueprintJson;
    }
View Full Code Here

TOP

Related Classes of com.sequenceiq.cloudbreak.controller.json.BlueprintJson

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.