use of org.eclipse.winery.model.adaptation.substitution.refinement.DefaultRefinementChooser in project winery by eclipse.
the class PatternDetectionTestWithGitBackedRepository method detectPatterns.
@Test
public void detectPatterns() throws Exception {
this.setRevisionTo("origin/plain");
ServiceTemplateId testTemplateId = new ServiceTemplateId("http://www.example.org/tosca/servicetemplates", "PatternDetectionTest_w1-wip1", false);
PatternDetection detection = new PatternDetection(new DefaultRefinementChooser());
ServiceTemplateId serviceTemplateId = detection.refineServiceTemplate(testTemplateId);
TTopologyTemplate topology = RepositoryFactory.getRepository().getElement(serviceTemplateId).getTopologyTemplate();
assertNotNull(topology);
QName java = QName.valueOf("{http://winery.opentosca.org/test/nodetypes}Java_8-Servelet-w1");
QName firstPattern = QName.valueOf("{http://plain.winery.opentosca.org/patterns}FirstPattern_w1");
QName secondPattern = QName.valueOf("{http://plain.winery.opentosca.org/patterns}SecondPattern_w1");
QName thirdPattern = QName.valueOf("{http://plain.winery.opentosca.org/patterns}ThirdPattern_w1");
QName secureSql = QName.valueOf("{http://www.example.org/tosca/relationshiptypes}Secure-SQL-Con_w1-wip1");
QName hostedOn = QName.valueOf("{http://winery.opentosca.org/test/relationshiptypes}hostedOn");
List<TNodeTemplate> nodeTemplates = topology.getNodeTemplates();
assertEquals(nodeTemplates.size(), 4);
Set<QName> nodeTypes = nodeTemplates.stream().map(TNodeTemplate::getType).collect(Collectors.toSet());
assertEquals(nodeTypes.size(), 4);
assertTrue(nodeTypes.contains(java));
assertTrue(nodeTypes.contains(firstPattern));
assertTrue(nodeTypes.contains(secondPattern));
assertTrue(nodeTypes.contains(thirdPattern));
List<TRelationshipTemplate> relationshipTemplates = topology.getRelationshipTemplates();
assertEquals(relationshipTemplates.size(), 4);
assertTrue(relationshipTemplates.stream().anyMatch(rt -> rt.getType().equals(secureSql) && rt.getSourceElement().getRef().getType().equals(java) && rt.getTargetElement().getRef().getType().equals(secondPattern)));
assertTrue(relationshipTemplates.stream().anyMatch(rt -> rt.getType().equals(hostedOn) && rt.getSourceElement().getRef().getType().equals(java) && rt.getTargetElement().getRef().getType().equals(firstPattern)));
assertTrue(relationshipTemplates.stream().anyMatch(rt -> rt.getType().equals(hostedOn) && rt.getSourceElement().getRef().getType().equals(firstPattern) && rt.getTargetElement().getRef().getType().equals(thirdPattern)));
assertTrue(relationshipTemplates.stream().anyMatch(rt -> rt.getType().equals(hostedOn) && rt.getSourceElement().getRef().getType().equals(secondPattern) && rt.getTargetElement().getRef().getType().equals(thirdPattern)));
}
use of org.eclipse.winery.model.adaptation.substitution.refinement.DefaultRefinementChooser in project winery by eclipse.
the class PatternRefinementTest method testIsApplicable.
// region ********** isApplicable() **********
@ParameterizedTest(name = "{index} => ''{3}''")
@MethodSource("getIsApplicableArguments")
void testIsApplicable(RefinementCandidate refinementCandidate, TTopologyTemplate topologyTemplate, boolean expected, String description) {
PatternRefinement patternRefinement = new PatternRefinement(new DefaultRefinementChooser());
assertEquals(expected, patternRefinement.isApplicable(refinementCandidate, topologyTemplate));
}
Aggregations