use of org.eclipse.winery.compliance.TOSCAModelHelper.TEST_TARGET_NAMESPACE in project winery by eclipse.
the class TOSCAGraphIsomorphismTest method testServiceTemplateAndComplianceRuleAssociation.
@Test
public void testServiceTemplateAndComplianceRuleAssociation() throws IOException {
HashMap<DefinitionsChildId, TExtensibleElements> allEntities = new HashMap<>();
String dirABC = "/ABC";
String dirBCD = "/BCD";
ServiceTemplateId stId = new ServiceTemplateId(new QName(TEST_TARGET_NAMESPACE + dirABC + dirBCD, "test1"));
TServiceTemplate tServiceTemplate = createTServiceTemplate("ServiceTemplateTestId", TEST_TARGET_NAMESPACE + dirABC + dirBCD);
allEntities.put(stId, tServiceTemplate);
ComplianceRuleId crId1 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE, "test1"));
ComplianceRuleId crId2 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE + dirABC, "test2"));
ComplianceRuleId crId3 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE + dirABC, "test3"));
ComplianceRuleId crId4 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE + dirBCD, "test4"));
TComplianceRule ruleOne = createTComplianceRule(crId1);
allEntities.put(crId1, ruleOne);
TComplianceRule ruleTwo = createTComplianceRule(crId2);
allEntities.put(crId2, ruleTwo);
TComplianceRule ruleThree = createTComplianceRule(crId3);
allEntities.put(crId3, ruleThree);
TComplianceRule ruleFour = createTComplianceRule(crId4);
allEntities.put(crId4, ruleFour);
persist(allEntities);
ServiceTemplateComplianceRuleRuleChecker checker = new ServiceTemplateComplianceRuleRuleChecker(tServiceTemplate);
List<ComplianceRuleId> ruleIds = checker.getRuleIds(tServiceTemplate);
assertTrue(ruleIds.stream().filter(id -> id.equals(crId1)).findFirst().isPresent());
assertTrue(ruleIds.stream().filter(id -> id.equals(crId2)).findFirst().isPresent());
assertTrue(ruleIds.stream().filter(id -> id.equals(crId3)).findFirst().isPresent());
assertFalse(ruleIds.stream().filter(id -> id.equals(crId4)).findFirst().isPresent());
}
use of org.eclipse.winery.compliance.TOSCAModelHelper.TEST_TARGET_NAMESPACE in project winery by eclipse.
the class ToscaGraphIsomorphismTest method testServiceTemplateAndComplianceRuleAssociation.
@Test
public void testServiceTemplateAndComplianceRuleAssociation() throws IOException {
HashMap<DefinitionsChildId, TExtensibleElements> allEntities = new HashMap<>();
String dirABC = "/ABC";
String dirBCD = "/BCD";
ServiceTemplateId stId = new ServiceTemplateId(new QName(TEST_TARGET_NAMESPACE + dirABC + dirBCD, "test1"));
TServiceTemplate tServiceTemplate = createTServiceTemplate("ServiceTemplateTestId", TEST_TARGET_NAMESPACE + dirABC + dirBCD);
allEntities.put(stId, tServiceTemplate);
ComplianceRuleId crId1 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE, "test1"));
ComplianceRuleId crId2 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE + dirABC, "test2"));
ComplianceRuleId crId3 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE + dirABC, "test3"));
ComplianceRuleId crId4 = new ComplianceRuleId(new QName(TEST_TARGET_NAMESPACE + dirBCD, "test4"));
OTComplianceRule ruleOne = createTComplianceRule(crId1);
allEntities.put(crId1, ruleOne);
OTComplianceRule ruleTwo = createTComplianceRule(crId2);
allEntities.put(crId2, ruleTwo);
OTComplianceRule ruleThree = createTComplianceRule(crId3);
allEntities.put(crId3, ruleThree);
OTComplianceRule ruleFour = createTComplianceRule(crId4);
allEntities.put(crId4, ruleFour);
persist(allEntities);
ServiceTemplateComplianceRuleRuleChecker checker = new ServiceTemplateComplianceRuleRuleChecker(tServiceTemplate);
List<ComplianceRuleId> ruleIds = checker.getRuleIds(tServiceTemplate);
assertTrue(ruleIds.stream().anyMatch(id -> id.equals(crId1)));
assertTrue(ruleIds.stream().anyMatch(id -> id.equals(crId2)));
assertTrue(ruleIds.stream().anyMatch(id -> id.equals(crId3)));
assertFalse(ruleIds.stream().anyMatch(id -> id.equals(crId4)));
}
Aggregations