Search in sources :

Example 1 with RequirementServices

use of org.obeonetwork.requirement.m2doc.services.RequirementServices in project InformationSystem by ObeoNetwork.

the class RequiremelntServicesTest method testService.

@Test
public void testService() {
    Repository repo = (Repository) EcoreUtil.create(RequirementPackage.Literals.REPOSITORY);
    Category cat = (Category) EcoreUtil.create(RequirementPackage.Literals.CATEGORY);
    repo.getMainCategories().add(cat);
    Requirement req1 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
    Requirement req2 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
    Requirement req3 = (Requirement) EcoreUtil.create(RequirementPackage.Literals.REQUIREMENT);
    cat.getRequirements().add(req1);
    cat.getRequirements().add(req2);
    cat.getRequirements().add(req3);
    Repository repo2 = (Repository) EcoreUtil.create(RequirementPackage.Literals.REPOSITORY);
    ResourceSet rs = new ResourceSetImpl();
    Resource resource = new XMLResourceImpl();
    rs.getResources().add(resource);
    resource.getContents().add(repo);
    resource.getContents().add(repo2);
    req1.getReferencedObject().add(repo2);
    req2.getReferencedObject().add(repo2);
    req3.getReferencedObject().add(repo2);
    List<Requirement> reqs = new RequirementServices().relatedRequirements(repo2);
    assertTrue(reqs.contains(req1));
    assertTrue(reqs.contains(req2));
    assertTrue(reqs.contains(req3));
}
Also used : XMLResourceImpl(org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl) Requirement(org.obeonetwork.dsl.requirement.Requirement) Repository(org.obeonetwork.dsl.requirement.Repository) Category(org.obeonetwork.dsl.requirement.Category) ResourceSetImpl(org.eclipse.emf.ecore.resource.impl.ResourceSetImpl) Resource(org.eclipse.emf.ecore.resource.Resource) RequirementServices(org.obeonetwork.requirement.m2doc.services.RequirementServices) ResourceSet(org.eclipse.emf.ecore.resource.ResourceSet) Test(org.junit.Test)

Aggregations

Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)1 XMLResourceImpl (org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl)1 Test (org.junit.Test)1 Category (org.obeonetwork.dsl.requirement.Category)1 Repository (org.obeonetwork.dsl.requirement.Repository)1 Requirement (org.obeonetwork.dsl.requirement.Requirement)1 RequirementServices (org.obeonetwork.requirement.m2doc.services.RequirementServices)1