Search in sources :

Example 1 with WorkflowContext

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

the class AbstractReaderTest method testLoadByType_withNsURI.

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

Example 2 with WorkflowContext

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

the class AbstractReaderTest method testLoadBySuperType.

@SuppressWarnings("unchecked")
@Test
public void testLoadBySuperType() 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);
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    List<Entity> entities = (List<Entity>) ctx.get("model");
    assertEquals(3, entities.size());
}
Also used : Entity(org.eclipse.xtext.index.indexTestLanguage.Entity) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) List(java.util.List) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 3 with WorkflowContext

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

the class AbstractReaderTest method testLoadByType.

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

Example 4 with WorkflowContext

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

the class AbstractReaderTest method testLoadByType_withUnkownNsURI.

@Test
public void testLoadByType_withUnkownNsURI() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Entity");
    entry.setNsURI("unknown ns uri");
    reader.addLoad(entry);
    WorkflowContext ctx = ctx();
    try {
        reader.invoke(ctx, monitor(), issues());
        fail("workflow interuption expected.");
    } catch (WorkflowInterruptedException e) {
    // expected
    }
}
Also used : WorkflowInterruptedException(org.eclipse.emf.mwe.core.WorkflowInterruptedException) WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) Test(org.junit.Test)

Example 5 with WorkflowContext

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

the class AbstractReaderTest method testLoadByType_FirstOnly.

@Test
public void testLoadByType_FirstOnly() throws Exception {
    Reader reader = getReader();
    reader.addPath(pathTo("emptyFolder"));
    reader.addPath(pathTo("nonemptyFolder"));
    reader.addRegister(new IndexTestLanguageStandaloneSetup());
    SlotEntry entry = createSlotEntry();
    entry.setType("Entity");
    entry.setFirstOnly(true);
    reader.addLoad(entry);
    WorkflowContext ctx = ctx();
    reader.invoke(ctx, monitor(), issues());
    assertEquals("Person", ((Entity) ctx.get("model")).getName());
}
Also used : WorkflowContext(org.eclipse.emf.mwe.core.WorkflowContext) IndexTestLanguageStandaloneSetup(org.eclipse.xtext.index.IndexTestLanguageStandaloneSetup) 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