use of org.eclipse.winery.model.tosca.TNodeTypeImplementation in project winery by eclipse.
the class EnhancementUtilsTestWithGitBackedRepository method mergeFeatureNodeTypeUbuntu.
@Test
void mergeFeatureNodeTypeUbuntu() throws Exception {
this.setRevisionTo("origin/plain");
Map<QName, TExtensibleElements> previousListOfNodeTypes = this.repository.getQNameToElementMapping(NodeTypeId.class);
String testingFeatureName = "Testing";
String freezeFeatureName = "Freeze and Defrost";
String nodeTemplateId = "myId";
Map<QName, String> ubuntuFeatures = new HashMap<>();
ubuntuFeatures.put(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes}Ubuntu_16.04-testable-w1"), testingFeatureName);
ubuntuFeatures.put(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes}Ubuntu_16.04-freezable-w1"), freezeFeatureName);
TNodeTemplate nodeTemplate = new TNodeTemplate();
nodeTemplate.setType(QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes}Ubuntu_16.04-w1"));
nodeTemplate.setId(nodeTemplateId);
TNodeType generatedFeatureEnrichedNodeType = EnhancementUtils.createFeatureNodeType(nodeTemplate, ubuntuFeatures);
Map<QName, TExtensibleElements> listOfNodeTypes = this.repository.getQNameToElementMapping(NodeTypeId.class);
QName expectedMergedUbuntuQName = QName.valueOf("{http://opentosca.org/add/management/to/instances/nodetypes" + EnhancementUtils.GENERATED_NS_SUFFIX + "}Ubuntu_16.04-w1-" + nodeTemplateId + "-" + "Testing-Freeze_and_Defrost" + WineryVersion.WINERY_VERSION_SEPARATOR + WineryVersion.WINERY_VERSION_PREFIX + "1");
assertEquals(1, listOfNodeTypes.size() - previousListOfNodeTypes.size());
assertEquals(expectedMergedUbuntuQName, generatedFeatureEnrichedNodeType.getQName());
assertNotNull(generatedFeatureEnrichedNodeType.getWinerysPropertiesDefinition());
assertEquals(9, generatedFeatureEnrichedNodeType.getWinerysPropertiesDefinition().getPropertyDefinitions().size());
TNodeTypeImplementation generatedUbuntuImpl = this.repository.getElement(new ArrayList<>(this.repository.getAllElementsReferencingGivenType(NodeTypeImplementationId.class, expectedMergedUbuntuQName)).get(0));
assertNotNull(generatedUbuntuImpl);
assertNotNull(generatedUbuntuImpl.getImplementationArtifacts());
assertEquals(3, generatedUbuntuImpl.getImplementationArtifacts().size());
}
use of org.eclipse.winery.model.tosca.TNodeTypeImplementation in project winery by eclipse.
the class DASpecification method getSuitableConcreteDA.
public static TDeploymentArtifact getSuitableConcreteDA(TDeploymentArtifact abstractDeploymentArtifact, TNodeTemplate nodeTemplate) {
TDeploymentArtifact concreteDA = null;
if (nodeTemplate.getDeploymentArtifacts() != null) {
List<TDeploymentArtifact> concreteDeploymentArtifacts = nodeTemplate.getDeploymentArtifacts();
concreteDA = getConcreteDA(abstractDeploymentArtifact, concreteDeploymentArtifacts);
}
if (concreteDA == null) {
List<TNodeTypeImplementation> nodeTypeImplementations = getMatchingNodeTypeImplementations(nodeTemplate.getType());
for (TNodeTypeImplementation nodeTypeImplementation : nodeTypeImplementations) {
if (nodeTypeImplementation.getDeploymentArtifacts() != null) {
List<TDeploymentArtifact> deploymentArtifacts = nodeTypeImplementation.getDeploymentArtifacts();
concreteDA = getConcreteDA(abstractDeploymentArtifact, deploymentArtifacts);
if (concreteDA != null) {
return concreteDA;
}
}
}
} else {
return concreteDA;
}
return null;
}
Aggregations