Search in sources :

Example 31 with FunctionPropertyValue

use of org.alien4cloud.tosca.model.definitions.FunctionPropertyValue in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method theDeploymentTopologyShouldHaveAnInputPropertyWithTheFollowingParameters.

@And("^The deployment topology should have an input property \"([^\"]*)\" with the following parameters$")
public void theDeploymentTopologyShouldHaveAnInputPropertyWithTheFollowingParameters(String propertyName, Map<String, String> parameters) throws Throwable {
    DeploymentTopologyDTO dto = getDeploymentTopologyDTO();
    FunctionPropertyValue functionPropertyValue = (FunctionPropertyValue) safe(dto.getTopology().getAllInputProperties()).get(propertyName);
    Assert.assertEquals(functionPropertyValue.getFunction(), parameters.get("functionName"));
    Assert.assertEquals(functionPropertyValue.getParameters().get(0), parameters.get("secretPath"));
}
Also used : FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) DeploymentTopologyDTO(alien4cloud.deployment.DeploymentTopologyDTO) And(cucumber.api.java.en.And)

Example 32 with FunctionPropertyValue

use of org.alien4cloud.tosca.model.definitions.FunctionPropertyValue in project alien4cloud by alien4cloud.

the class OrchestrationLocationResourceSteps method iUpdateThePropertyToASecretPathForTheResourceNamedRelatedToTheLocation.

@And("^I update the property \"([^\"]*)\" to get_secret function with a secret path \"([^\"]*)\" for the resource named \"([^\"]*)\" related to the location \"([^\"]*)\"/\"([^\"]*)\"$")
public void iUpdateThePropertyToASecretPathForTheResourceNamedRelatedToTheLocation(String propertyName, String secretPath, String resourceName, String orchestratorName, String locationName) throws Throwable {
    FunctionPropertyValue propertyValue = new FunctionPropertyValue();
    propertyValue.setFunction(ToscaFunctionConstants.GET_SECRET);
    propertyValue.setParameters(Arrays.asList(secretPath));
    updatePropertyValue(orchestratorName, locationName, resourceName, propertyName, propertyValue, getUpdatePropertyUrlFormat());
}
Also used : FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) And(cucumber.api.java.en.And)

Example 33 with FunctionPropertyValue

use of org.alien4cloud.tosca.model.definitions.FunctionPropertyValue in project alien4cloud by alien4cloud.

the class DeploymentTopologyStepDefinitions method iUpdateThePropertyToASecretWithASecretPathForTheSubtitutedNode.

@When("^I update the property \"([^\"]*)\" to a secret with a secret path \"([^\"]*)\" for the subtituted node \"([^\"]*)\"$")
public void iUpdateThePropertyToASecretWithASecretPathForTheSubtitutedNode(String propertyName, String secretPath, String nodeName) throws Throwable {
    FunctionPropertyValue functionPropertyValue = new FunctionPropertyValue();
    functionPropertyValue.setFunction(ToscaFunctionConstants.GET_SECRET);
    functionPropertyValue.setParameters(Arrays.asList(secretPath));
    updateProperty(propertyName, functionPropertyValue, nodeName, "/rest/v1/applications/%s/environments/%s/deployment-topology/substitutions/%s/properties");
}
Also used : FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) When(cucumber.api.java.en.When)

Example 34 with FunctionPropertyValue

use of org.alien4cloud.tosca.model.definitions.FunctionPropertyValue in project alien4cloud by alien4cloud.

the class ToscaParserSimpleProfileAlien130Test method testGetOperationOutputFunction.

@Test
@SuppressWarnings("unchecked")
public void testGetOperationOutputFunction() throws Throwable {
    Csar csar = new Csar("tosca-normative-types", "1.0.0-SNAPSHOT-wd03");
    // Mockito.when(csarRepositorySearchService.getArchive(csar.getId())).thenReturn(csar);
    NodeType mockedResult = Mockito.mock(NodeType.class);
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(NodeType.class), Mockito.eq("tosca.nodes.SoftwareComponent"), Mockito.any(Set.class))).thenReturn(mockedResult);
    Mockito.when(mockedResult.getDerivedFrom()).thenReturn(Lists.newArrayList("tosca.nodes.Root"));
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(NodeType.class), Mockito.eq("tosca.nodes.Root"), Mockito.any(Set.class))).thenReturn(mockedResult);
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(NodeType.class), Mockito.eq("tosca.nodes.Compute"), Mockito.any(Set.class))).thenReturn(mockedResult);
    CapabilityType mockedCapabilityResult = Mockito.mock(CapabilityType.class);
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(CapabilityType.class), Mockito.eq("mytypes.mycapabilities.MyCapabilityTypeName"), Mockito.any(Set.class))).thenReturn(mockedCapabilityResult);
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(CapabilityType.class), Mockito.eq("tosca.capabilities.Container"), Mockito.any(Set.class))).thenReturn(mockedCapabilityResult);
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(CapabilityType.class), Mockito.eq("tosca.capabilities.Endpoint"), Mockito.any(Set.class))).thenReturn(mockedCapabilityResult);
    RelationshipType hostedOn = new RelationshipType();
    Mockito.when(csarRepositorySearchService.getElementInDependencies(Mockito.eq(RelationshipType.class), Mockito.eq("tosca.relationships.HostedOn"), Mockito.any(Set.class))).thenReturn(hostedOn);
    ParsingResult<ArchiveRoot> parsingResult = parser.parseFile(Paths.get(getRootDirectory(), "tosca-functions.yml"));
    Mockito.verify(csarRepositorySearchService).getArchive(csar.getName(), csar.getVersion());
    assertNoBlocker(parsingResult);
    ArchiveRoot archiveRoot = parsingResult.getResult();
    assertNotNull(archiveRoot.getArchive());
    Assert.assertEquals(getToscaVersion(), archiveRoot.getArchive().getToscaDefinitionsVersion());
    // check nodetype elements
    Entry<String, NodeType> entry = archiveRoot.getNodeTypes().entrySet().iterator().next();
    Assert.assertEquals("my_company.my_types.MyAppNodeType", entry.getKey());
    NodeType nodeType = entry.getValue();
    // on input level
    Map<String, Interface> interfaces = nodeType.getInterfaces();
    Interface customInterface = interfaces.get("custom");
    Map<String, IValue> doSomethingInputs = customInterface.getOperations().get("do_something").getInputParameters();
    assertNotNull(doSomethingInputs);
    Assert.assertFalse(doSomethingInputs.isEmpty());
    IValue operationOutput_input = doSomethingInputs.get("operationOutput_input");
    assertTrue(operationOutput_input instanceof FunctionPropertyValue);
    FunctionPropertyValue function = (FunctionPropertyValue) operationOutput_input;
    Assert.assertEquals("get_operation_output", function.getFunction());
    Assert.assertEquals(4, function.getParameters().size());
    Map<String, IValue> attributes = nodeType.getAttributes();
    IValue operationOutputAttr = attributes.get("url");
    // check attributes types
    assertTrue(operationOutputAttr instanceof FunctionPropertyValue);
    function = (FunctionPropertyValue) operationOutputAttr;
    Assert.assertEquals("get_operation_output", function.getFunction());
    Assert.assertEquals(4, function.getParameters().size());
}
Also used : Csar(org.alien4cloud.tosca.model.Csar) CapabilityType(org.alien4cloud.tosca.model.types.CapabilityType) Set(java.util.Set) RelationshipType(org.alien4cloud.tosca.model.types.RelationshipType) ArchiveRoot(alien4cloud.tosca.model.ArchiveRoot) IValue(org.alien4cloud.tosca.model.definitions.IValue) NodeType(org.alien4cloud.tosca.model.types.NodeType) FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue) Interface(org.alien4cloud.tosca.model.definitions.Interface) Test(org.junit.Test)

Example 35 with FunctionPropertyValue

use of org.alien4cloud.tosca.model.definitions.FunctionPropertyValue in project alien4cloud by alien4cloud.

the class PropertyUtils method toFunctionValue.

/**
 * Transform a json property string to a FunctionProperty object
 * @param jsonProperty
 * @return
 */
public static FunctionPropertyValue toFunctionValue(String jsonProperty) throws IOException {
    Map<String, Object> propertyMap = JsonUtil.toMap(jsonProperty);
    FunctionPropertyValue propertyValue = new FunctionPropertyValue();
    propertyValue.setFunction(propertyMap.get("function").toString());
    propertyValue.setParameters((List<String>) propertyMap.get("parameters"));
    return propertyValue;
}
Also used : FunctionPropertyValue(org.alien4cloud.tosca.model.definitions.FunctionPropertyValue)

Aggregations

FunctionPropertyValue (org.alien4cloud.tosca.model.definitions.FunctionPropertyValue)37 AbstractPropertyValue (org.alien4cloud.tosca.model.definitions.AbstractPropertyValue)12 PropertyDefinition (org.alien4cloud.tosca.model.definitions.PropertyDefinition)10 Map (java.util.Map)7 ScalarPropertyValue (org.alien4cloud.tosca.model.definitions.ScalarPropertyValue)6 And (cucumber.api.java.en.And)5 ConcatPropertyValue (org.alien4cloud.tosca.model.definitions.ConcatPropertyValue)5 When (cucumber.api.java.en.When)4 RestResponse (alien4cloud.rest.model.RestResponse)3 TopologyDTO (alien4cloud.topology.TopologyDTO)3 JavaType (com.fasterxml.jackson.databind.JavaType)3 PropertyValue (org.alien4cloud.tosca.model.definitions.PropertyValue)3 Capability (org.alien4cloud.tosca.model.templates.Capability)3 NodeTemplate (org.alien4cloud.tosca.model.templates.NodeTemplate)3 CapabilityType (org.alien4cloud.tosca.model.types.CapabilityType)3 RelationshipType (org.alien4cloud.tosca.model.types.RelationshipType)3 DeploymentTopologyDTO (alien4cloud.deployment.DeploymentTopologyDTO)2 NotFoundException (alien4cloud.exception.NotFoundException)2 ParsingError (alien4cloud.tosca.parser.ParsingError)2 ConstraintValueDoNotMatchPropertyTypeException (org.alien4cloud.tosca.exceptions.ConstraintValueDoNotMatchPropertyTypeException)2