Search in sources :

Example 16 with OTPermutationMapping

use of org.eclipse.winery.model.tosca.extensions.OTPermutationMapping in project winery by eclipse.

the class PermutationHelper method addAllPermutationMappings.

static void addAllPermutationMappings(OTPatternRefinementModel refinementModel) {
    addSomePermutationMappings(refinementModel);
    OTPermutationMapping relation1to2_to_relation12to14 = new OTPermutationMapping.Builder("pm-1-2--14").setDetectorElement(refinementModel.getDetector().getRelationshipTemplate("con-1--2")).setRefinementElement(refinementModel.getRefinementStructure().getNodeTemplate("14")).build();
    refinementModel.getPermutationMappings().add(relation1to2_to_relation12to14);
}
Also used : OTPermutationMapping(org.eclipse.winery.model.tosca.extensions.OTPermutationMapping)

Example 17 with OTPermutationMapping

use of org.eclipse.winery.model.tosca.extensions.OTPermutationMapping in project winery by eclipse.

the class PermutationGeneratorTest method checkMutabilityOfPrmWithAutomaticallyDeterminableComplexRelationMapping.

@Test
void checkMutabilityOfPrmWithAutomaticallyDeterminableComplexRelationMapping() {
    OTPatternRefinementModel refinementModel = generatePrmWithComplexRelationMaps();
    PermutationGenerator permutationGenerator = new PermutationGenerator();
    assertTrue(permutationGenerator.checkMutability(refinementModel));
    assertEquals(2, refinementModel.getPermutationOptions().size());
    List<OTPermutationMapping> mappings = refinementModel.getPermutationMappings();
    assertEquals(5, mappings.size());
    assertTrue(refinementModel.getPermutationMappings().removeIf(permutationMap -> permutationMap.getDetectorElement().getId().equals("1") && permutationMap.getRefinementElement().getId().equals("11")));
    assertTrue(refinementModel.getPermutationMappings().removeIf(permutationMap -> permutationMap.getDetectorElement().getId().equals("1") && permutationMap.getRefinementElement().getId().equals("12")));
    assertTrue(refinementModel.getPermutationMappings().removeIf(permutationMap -> permutationMap.getDetectorElement().getId().equals("2") && permutationMap.getRefinementElement().getId().equals("13")));
    assertTrue(refinementModel.getPermutationMappings().removeIf(permutationMap -> permutationMap.getDetectorElement().getId().equals("2") && permutationMap.getRefinementElement().getId().equals("14")));
    assertTrue(refinementModel.getPermutationMappings().removeIf(permutationMap -> permutationMap.getDetectorElement().getId().equals("con-1--2") && permutationMap.getRefinementElement().getId().equals("13")));
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) PermutationHelper.generatePrmWithoutPermutationMaps(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithoutPermutationMaps) PermutationHelper.addSomePermutationMappings(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.addSomePermutationMappings) PermutationHelper.generatePrmWithComplexRelationMaps2(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithComplexRelationMaps2) PermutationHelper.addAllPermutationMappings(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.addAllPermutationMappings) OTTopologyFragmentRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTopologyFragmentRefinementModel) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel) Test(org.junit.jupiter.api.Test) List(java.util.List) PermutationHelper.generateComplexPrmWithPatternSet(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generateComplexPrmWithPatternSet) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) OTPermutationMapping(org.eclipse.winery.model.tosca.extensions.OTPermutationMapping) PermutationHelper.generatePrmWithTwoPatternsHostedOnAThird(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithTwoPatternsHostedOnAThird) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PermutationHelper.generatePrmWithComplexRelationMaps(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithComplexRelationMaps) PermutationHelper.generatePrmWithStayMapping(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithStayMapping) OTStringList(org.eclipse.winery.model.tosca.extensions.OTStringList) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel) OTPermutationMapping(org.eclipse.winery.model.tosca.extensions.OTPermutationMapping) Test(org.junit.jupiter.api.Test)

Example 18 with OTPermutationMapping

use of org.eclipse.winery.model.tosca.extensions.OTPermutationMapping in project winery by eclipse.

the class PermutationGeneratorTest method checkMutabilityOfPrmWithTwoPatternsHostedOnOne.

@Test
void checkMutabilityOfPrmWithTwoPatternsHostedOnOne() {
    OTPatternRefinementModel refinementModel = generatePrmWithTwoPatternsHostedOnAThird();
    PermutationGenerator permutationGenerator = new PermutationGenerator();
    assertTrue(permutationGenerator.checkMutability(refinementModel));
    List<OTPermutationMapping> permutationMappings = refinementModel.getPermutationMappings();
    assertEquals(7, permutationMappings.size());
    assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("1") && mapping.getRefinementElement().getId().equals("11")));
    assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("3") && mapping.getRefinementElement().getId().equals("12")));
    assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("2") && mapping.getRefinementElement().getId().equals("13")));
    assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("2") && mapping.getRefinementElement().getId().equals("14")));
    assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("con-1--3") && mapping.getRefinementElement().getId().equals("12")));
    assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("con-1--2") && mapping.getRefinementElement().getId().equals("13")));
    assertTrue(permutationMappings.removeIf(mapping -> mapping.getDetectorElement().getId().equals("con-3--2") && mapping.getRefinementElement().getId().equals("13")));
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Arrays(java.util.Arrays) PermutationHelper.generatePrmWithoutPermutationMaps(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithoutPermutationMaps) PermutationHelper.addSomePermutationMappings(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.addSomePermutationMappings) PermutationHelper.generatePrmWithComplexRelationMaps2(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithComplexRelationMaps2) PermutationHelper.addAllPermutationMappings(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.addAllPermutationMappings) OTTopologyFragmentRefinementModel(org.eclipse.winery.model.tosca.extensions.OTTopologyFragmentRefinementModel) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel) Test(org.junit.jupiter.api.Test) List(java.util.List) PermutationHelper.generateComplexPrmWithPatternSet(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generateComplexPrmWithPatternSet) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) OTPermutationMapping(org.eclipse.winery.model.tosca.extensions.OTPermutationMapping) PermutationHelper.generatePrmWithTwoPatternsHostedOnAThird(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithTwoPatternsHostedOnAThird) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) PermutationHelper.generatePrmWithComplexRelationMaps(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithComplexRelationMaps) PermutationHelper.generatePrmWithStayMapping(org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithStayMapping) OTStringList(org.eclipse.winery.model.tosca.extensions.OTStringList) OTPatternRefinementModel(org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel) OTPermutationMapping(org.eclipse.winery.model.tosca.extensions.OTPermutationMapping) Test(org.junit.jupiter.api.Test)

Aggregations

OTPermutationMapping (org.eclipse.winery.model.tosca.extensions.OTPermutationMapping)18 TNodeTemplate (org.eclipse.winery.model.tosca.TNodeTemplate)12 ArrayList (java.util.ArrayList)11 OTPatternRefinementModel (org.eclipse.winery.model.tosca.extensions.OTPatternRefinementModel)10 TRelationshipTemplate (org.eclipse.winery.model.tosca.TRelationshipTemplate)9 TTopologyTemplate (org.eclipse.winery.model.tosca.TTopologyTemplate)9 OTStayMapping (org.eclipse.winery.model.tosca.extensions.OTStayMapping)7 OTRelationMapping (org.eclipse.winery.model.tosca.extensions.OTRelationMapping)6 Test (org.junit.jupiter.api.Test)6 List (java.util.List)5 OTAttributeMapping (org.eclipse.winery.model.tosca.extensions.OTAttributeMapping)5 Arrays (java.util.Arrays)4 QName (javax.xml.namespace.QName)4 OTStringList (org.eclipse.winery.model.tosca.extensions.OTStringList)4 OTTopologyFragmentRefinementModel (org.eclipse.winery.model.tosca.extensions.OTTopologyFragmentRefinementModel)4 LinkedHashMap (java.util.LinkedHashMap)3 PermutationHelper.addAllPermutationMappings (org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.addAllPermutationMappings)3 PermutationHelper.addSomePermutationMappings (org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.addSomePermutationMappings)3 PermutationHelper.generateComplexPrmWithPatternSet (org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generateComplexPrmWithPatternSet)3 PermutationHelper.generatePrmWithComplexRelationMaps (org.eclipse.winery.model.adaptation.substitution.refinement.PermutationHelper.generatePrmWithComplexRelationMaps)3