Search in sources :

Example 11 with WorkflowContext

use of org.eclipse.emf.mwe.core.WorkflowContext in project xtext-core by eclipse.

the class AbstractReaderTest method testLoadMatchAll.

@Test
public void testLoadMatchAll() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Type");
    reader.addLoad(entry);
    reader.setUriFilter(new UriFilter() {

        @Override
        public boolean matches(URI uri) {
            return true;
        }
    });
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    Collection<?> slotContent = (Collection<?>) ctx.get("model");
    assertNotNull(slotContent);
    // Foo, Person, String
    assertEquals(3, slotContent.size());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) Collection(java.util.Collection) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Example 12 with WorkflowContext

use of org.eclipse.emf.mwe.core.WorkflowContext in project xtext-core by eclipse.

the class AbstractReaderTest method testLoadMatchNone.

@Test
public void testLoadMatchNone() throws Exception {
    final Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Type");
    reader.addLoad(entry);
    reader.setUriFilter(new UriFilter() {

        @Override
        public boolean matches(URI uri) {
            return false;
        }
    });
    final WorkflowContext ctx = ctx();
    LoggingTester.captureLogging(Level.WARN, SlotEntry.class, new Runnable() {

        @Override
        public void run() {
            reader.invoke(ctx, monitor(), issues());
        }
    }).assertLogEntry("Could not find any exported element of type 'Type' -> Slot 'model' is empty.");
    Collection<?> slotContent = (Collection<?>) ctx.get("model");
    assertNotNull(slotContent);
    assertTrue(slotContent.isEmpty());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) Collection(java.util.Collection) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) URI(org.eclipse.emf.common.util.URI) Test(org.junit.Test)

Example 13 with WorkflowContext

use of org.eclipse.emf.mwe.core.WorkflowContext in project xtext-core by eclipse.

the class ResourceSetBasedSlotEntryReaderTest method testLoadAll.

@SuppressWarnings("unchecked")
@Test
public void testLoadAll() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    reader.addLoad(entry);
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    List<EObject> elements = (List<EObject>) ctx.get("model");
    assertEquals(11, elements.size());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) EObject(org.eclipse.emf.ecore.EObject) List(java.util.List) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 14 with WorkflowContext

use of org.eclipse.emf.mwe.core.WorkflowContext in project xtext-core by eclipse.

the class UriBasedReaderTest method testTransitiveReferences.

@SuppressWarnings("unchecked")
@Test
public void testTransitiveReferences() throws Exception {
    UriBasedReader reader = new UriBasedReader();
    reader.addRegister(new ImportUriTestLanguageStandaloneSetup());
    reader.addUri(pathTo2("importUriSubfolder/Start.importuritestlanguage"));
    SlotEntry slotEntry = new SlotEntry();
    slotEntry.setType("Type");
    reader.addLoad(slotEntry);
    WorkflowContext ctx = new WorkflowContextDefaultImpl();
    IssuesImpl issues = new IssuesImpl();
    reader.checkConfiguration(issues);
    try {
        reader.invoke(ctx, new NullProgressMonitor(), issues);
    } catch (Exception e) {
        System.out.println(issues);
        throw e;
    }
    List<Type> types = (List<Type>) ctx.get(slotEntry.getSlot());
    assertEquals(3, types.size());
    for (Type type : types) {
        if (type.getName().equals("Foo")) {
            assertEquals("Bar", type.getExtends().getName());
        } else if (type.getName().equals("Bar")) {
            assertEquals("Baz", type.getExtends().getName());
        } else {
            assertNull(type.getExtends());
        }
    }
}
Also used : NullProgressMonitor(org.eclipse.emf.mwe.core.monitor.NullProgressMonitor) Type(org.eclipse.xtext.linking.importedURI.Type) ImportUriTestLanguageStandaloneSetup(org.eclipse.xtext.linking.ImportUriTestLanguageStandaloneSetup) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) WorkflowContextDefaultImpl(org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl) IssuesImpl(org.eclipse.emf.mwe.core.issues.IssuesImpl) List(java.util.List) Test(org.junit.Test)

Aggregations

WorkflowContext (org.eclipse.emf.mwe.core.WorkflowContext)14 Test (org.junit.Test)14 IndexTestLanguageStandaloneSetup (org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup)13 List (java.util.List)8 Entity (org.eclipse.xtext.index.indexTestLanguage.Entity)4 EObject (org.eclipse.emf.ecore.EObject)3 Collection (java.util.Collection)2 URI (org.eclipse.emf.common.util.URI)2 Issues (org.eclipse.emf.mwe.core.issues.Issues)2 WorkflowContextDefaultImpl (org.eclipse.emf.mwe.core.WorkflowContextDefaultImpl)1 WorkflowInterruptedException (org.eclipse.emf.mwe.core.WorkflowInterruptedException)1 IssuesImpl (org.eclipse.emf.mwe.core.issues.IssuesImpl)1 NullProgressMonitor (org.eclipse.emf.mwe.core.monitor.NullProgressMonitor)1 Datatype (org.eclipse.xtext.index.indexTestLanguage.Datatype)1 ImportUriTestLanguageStandaloneSetup (org.eclipse.xtext.linking.ImportUriTestLanguageStandaloneSetup)1 Type (org.eclipse.xtext.linking.importedURI.Type)1