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"));
}
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());
}
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");
}
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());
}
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;
}
Aggregations