Search in sources :

Example 21 with NodeTemplate

use of org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.

the class FunctionEvaluatorTest method nodeGetConcatProp.

@Test
public void nodeGetConcatProp() {
    FunctionEvaluatorContext context = getEvaluationContext();
    NodeTemplate template = context.getTopology().getNodeTemplates().get("my_node");
    PropertyValue resolved = resolveValue(context, template, template.getProperties(), template.getProperties().get("get_concat_prop"));
    Assert.assertNotNull(resolved);
    Assert.assertEquals(ScalarPropertyValue.class, resolved.getClass());
    Assert.assertEquals("input is: scalar input value property is: scalar value", resolved.getValue());
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) ComplexPropertyValue(org.alien4cloud.tosca.model.definitions.ComplexPropertyValue) ScalarPropertyValue(org.alien4cloud.tosca.model.definitions.ScalarPropertyValue) ConcatPropertyValue(org.alien4cloud.tosca.model.definitions.ConcatPropertyValue) PropertyValue(org.alien4cloud.tosca.model.definitions.PropertyValue) AbstractPropertyValue(org.alien4cloud.tosca.model.definitions.AbstractPropertyValue) FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) Test(org.junit.Test)

Example 22 with NodeTemplate

use of org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.

the class FunctionEvaluatorTest method nodeGetInputProp.

@Test
public void nodeGetInputProp() {
    FunctionEvaluatorContext context = getEvaluationContext();
    NodeTemplate template = context.getTopology().getNodeTemplates().get("my_node");
    PropertyValue resolved = resolveValue(context, template, template.getProperties(), template.getProperties().get("get_input_prop"));
    Assert.assertNotNull(resolved);
    Assert.assertEquals(ScalarPropertyValue.class, resolved.getClass());
    Assert.assertEquals("scalar input value", resolved.getValue());
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) ComplexPropertyValue(org.alien4cloud.tosca.model.definitions.ComplexPropertyValue) ScalarPropertyValue(org.alien4cloud.tosca.model.definitions.ScalarPropertyValue) ConcatPropertyValue(org.alien4cloud.tosca.model.definitions.ConcatPropertyValue) PropertyValue(org.alien4cloud.tosca.model.definitions.PropertyValue) AbstractPropertyValue(org.alien4cloud.tosca.model.definitions.AbstractPropertyValue) FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) Test(org.junit.Test)

Example 23 with NodeTemplate

use of org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.

the class FunctionEvaluatorTest method nodeConcatProp.

@Test
public void nodeConcatProp() {
    FunctionEvaluatorContext context = getEvaluationContext();
    NodeTemplate template = context.getTopology().getNodeTemplates().get("my_node");
    PropertyValue resolved = resolveValue(context, template, template.getProperties(), template.getProperties().get("concat_prop"));
    Assert.assertNotNull(resolved);
    Assert.assertEquals(ScalarPropertyValue.class, resolved.getClass());
    Assert.assertEquals("input is: scalar input value property is: scalar value", resolved.getValue());
}
Also used : NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) ComplexPropertyValue(org.alien4cloud.tosca.model.definitions.ComplexPropertyValue) ScalarPropertyValue(org.alien4cloud.tosca.model.definitions.ScalarPropertyValue) ConcatPropertyValue(org.alien4cloud.tosca.model.definitions.ConcatPropertyValue) PropertyValue(org.alien4cloud.tosca.model.definitions.PropertyValue) AbstractPropertyValue(org.alien4cloud.tosca.model.definitions.AbstractPropertyValue) FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) Test(org.junit.Test)

Example 24 with NodeTemplate

use of org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.

the class PaaSUtilsTest method buildFakeNodeTemplate.

private NodeTemplate buildFakeNodeTemplate(Map<String, Capability> capabilities) {
    Map<String, AbstractPropertyValue> props = Maps.newHashMap();
    props.put(fake1, new ScalarPropertyValue("1_from_nodeTemplate"));
    props.put(fake2, null);
    props.put(fake3, new ComplexPropertyValue(MapUtil.newHashMap(new String[] { "toto" }, new String[] { "tata" })));
    props.put(fake5, new ScalarPropertyValue("5_from_nodeTemplate"));
    NodeTemplate fakeTemplate = Mockito.mock(NodeTemplate.class);
    Mockito.when(fakeTemplate.getProperties()).thenReturn(props);
    Mockito.when(fakeTemplate.getCapabilities()).thenReturn(capabilities);
    return fakeTemplate;
}
Also used : PaaSNodeTemplate(alien4cloud.paas.model.PaaSNodeTemplate) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate)

Example 25 with NodeTemplate

use of org.alien4cloud.tosca.model.templates.NodeTemplate in project alien4cloud by alien4cloud.

the class PaaSUtilsTest method buildPaaSNodeTemplate.

private PaaSNodeTemplate buildPaaSNodeTemplate() {
    Map<String, Capability> capabilities = Maps.newHashMap();
    capabilities.put(fakeCapa1, buildFakeCapability());
    NodeTemplate nodeTemplate = buildFakeNodeTemplate(capabilities);
    Map<String, Operation> operations = Maps.newHashMap();
    operations.put(operation1, buildFakeOperation());
    Map<String, Interface> interfaces = Maps.newHashMap();
    interfaces.put(interface1, buildFakeInterface(operations));
    return buildFakePaaSNodeTemplate(nodeTemplate, interfaces);
}
Also used : PaaSNodeTemplate(alien4cloud.paas.model.PaaSNodeTemplate) NodeTemplate(org.alien4cloud.tosca.model.templates.NodeTemplate) Capability(org.alien4cloud.tosca.model.templates.Capability)

Aggregations

NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)162 NodeType (org.alien4cloud.tosca.model.types.NodeType)52 Map (java.util.Map)40 RelationshipTemplate (org.alien4cloud.tosca.model.templates.RelationshipTemplate)37 Test (org.junit.Test)32 Capability (org.alien4cloud.tosca.model.templates.Capability)27 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)25 Topology (org.alien4cloud.tosca.model.templates.Topology)22 NotFoundException (alien4cloud.exception.NotFoundException)17 Then (cucumber.api.java.en.Then)15 ScalarPropertyValue (org.alien4cloud.tosca.model.definitions.ScalarPropertyValue)15 HashMap (java.util.HashMap)14 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)13 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)13 TopologyDTO (alien4cloud.topology.TopologyDTO)12 ComplexPropertyValue (org.alien4cloud.tosca.model.definitions.ComplexPropertyValue)12 LocationResourceTemplate (alien4cloud.model.orchestrators.locations.LocationResourceTemplate)11 PaaSNodeTemplate (alien4cloud.paas.model.PaaSNodeTemplate)11 DeploymentArtifact (org.alien4cloud.tosca.model.definitions.DeploymentArtifact)10 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)10