FunctionEvaluator { public static String evaluateGetPropertyFunction(FunctionPropertyValue functionParam, IPaaSTemplate<? extends AbstractInheritableToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates) { AbstractPropertyValue propertyValue = processGetPropertyFunction(functionParam, basePaaSTemplate, builtPaaSTemplates); if (propertyValue == null) { return null; } else if (!(propertyValue instanceof PropertyValue)) { throw new NotSupportedException("Not a property value " + propertyValue); } else { return PropertyUtil.serializePropertyValue(propertyValue); } }  static String parseAttribute(String attributeId, IValue attributeValue, Topology topology,
            Map<String, Map<String, InstanceInformation>> runtimeInformations, String currentInstance,
            IPaaSTemplate<? extends AbstractToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates); static List<? extends IPaaSTemplate> getPaaSTemplatesFromKeyword(IPaaSTemplate<? extends AbstractToscaType> basePaaSTemplate, String keyword,
            Map<String, PaaSNodeTemplate> builtPaaSTemplates); static String evaluateGetPropertyFunction(FunctionPropertyValue functionParam,
            IPaaSTemplate<? extends AbstractInheritableToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates); static AbstractPropertyValue processGetPropertyFunction(FunctionPropertyValue functionParam,
            IPaaSTemplate<? extends AbstractInheritableToscaType> basePaaSTemplate, Map<String, PaaSNodeTemplate> builtPaaSTemplates); static Map<String, String> getScalarValues(Map<String, AbstractPropertyValue> propertyValues); static boolean isGetAttribute(FunctionPropertyValue function); static boolean isGetOperationOutput(FunctionPropertyValue function); static boolean isGetInput(AbstractPropertyValue propertyValue); static boolean isGetInput(FunctionPropertyValue function); static boolean isGetSecret(AbstractPropertyValue propertyValue); static boolean isGetSecret(FunctionPropertyValue function);  }
@Test(expected = BadUsageKeywordException.class) public void getPropertyWrongDefOrUSageTest() throws Throwable { String computeName = "comp_tomcat_war"; PaaSNodeTemplate computePaaS = builtPaaSNodeTemplates.get(computeName); Operation configOp = computePaaS.getIndexedToscaElement().getInterfaces().get(ToscaNodeLifecycleConstants.STANDARD).getOperations() .get(ToscaNodeLifecycleConstants.CONFIGURE); IValue param = configOp.getInputParameters().get("keywordSourceBadUsage"); try { FunctionEvaluator.evaluateGetPropertyFunction((FunctionPropertyValue) param, computePaaS, builtPaaSNodeTemplates); } catch (BadUsageKeywordException e) { param = configOp.getInputParameters().get("KeywordTargetBadUsage"); FunctionEvaluator.evaluateGetPropertyFunction((FunctionPropertyValue) param, computePaaS, builtPaaSNodeTemplates); } }
@Test public void parseComplexProperty() { String complexPropName = "complex_prop"; PaaSNodeTemplate complexPropNode = builtPaaSNodeTemplates.get(complexPropName); Operation configOp = complexPropNode.getIndexedToscaElement().getInterfaces().get(ToscaNodeLifecycleConstants.STANDARD).getOperations() .get(ToscaNodeLifecycleConstants.CREATE); Assert.assertEquals( "{\n" + " \"nested_map\" : {\n" + " \"tutu\" : \"tata\",\n" + " \"toctoc\" : \"tactac\"\n" + " },\n" + " \"nested\" : \"toto\",\n" + " \"nested_array\" : [ \"titi\", \"tuctuc\" ]\n" + "}", FunctionEvaluator.evaluateGetPropertyFunction((FunctionPropertyValue) configOp.getInputParameters().get("COMPLEX"), complexPropNode, builtPaaSNodeTemplates)); Assert.assertEquals("toto", FunctionEvaluator.evaluateGetPropertyFunction((FunctionPropertyValue) configOp.getInputParameters().get("NESTED"), complexPropNode, builtPaaSNodeTemplates)); Assert.assertEquals("titi", FunctionEvaluator.evaluateGetPropertyFunction( (FunctionPropertyValue) configOp.getInputParameters().get("NESTED_ARRAY_ELEMENT"), complexPropNode, builtPaaSNodeTemplates)); Assert.assertEquals("tata", FunctionEvaluator.evaluateGetPropertyFunction( (FunctionPropertyValue) configOp.getInputParameters().get("NESTED_MAP_ELEMENT"), complexPropNode, builtPaaSNodeTemplates)); }