Java Code Examples for org.eclipse.emf.mwe.core.WorkflowContext#get()
The following examples show how to use
org.eclipse.emf.mwe.core.WorkflowContext#get() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractReaderTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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()); }
Example 2
Source File: AbstractReaderTest.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@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()); }
Example 3
Source File: ResourceSetBasedSlotEntryReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example 4
Source File: ResourceSetBasedSlotEntryReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@SuppressWarnings("unchecked") @Test public void testLoadFileElements() throws Exception { Reader reader = getReader(); reader.addPath(pathTo("emptyFolder")); reader.addPath(pathTo("nonemptyFolder")); reader.addRegister(new IndexTestLanguageStandaloneSetup()); SlotEntry entry = createSlotEntry(); entry.setType("File"); reader.addLoad(entry); WorkflowContext ctx = ctx(); reader.invoke(ctx, monitor(), issues()); List<EObject> elements = (List<EObject>) ctx.get("model"); assertEquals(2,elements.size()); }
Example 5
Source File: AbstractReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example 6
Source File: AbstractReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example 7
Source File: AbstractReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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()); }
Example 8
Source File: UriBasedReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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()); } } }
Example 9
Source File: ReaderTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@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(8,elements.size()); }
Example 10
Source File: ReaderTest.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@SuppressWarnings("unchecked") @Test public void testShadowingPathes() throws Exception { Reader reader = getReader(); // also test adding multiple paths as comma-separated list, see bug#356750 reader.addPath( pathTo("shadowingtest/folder 1") +"," +pathTo("shadowingtest/folder 2") +" , "+pathTo("shadowingtest/folder 3")); reader.addRegister(new IndexTestLanguageStandaloneSetup()); SlotEntry entry = createSlotEntry(); entry.setType("Entity"); reader.addLoad(entry); SlotEntry entry2 = createSlotEntry(); entry2.setType("Datatype"); entry2.setSlot("stringTypes"); entry2.setName("String"); reader.addLoad(entry2); SlotEntry entry3 = createSlotEntry(); entry3.setType("Datatype"); entry3.setSlot("booleanTypes"); entry3.setName("Boolean"); reader.addLoad(entry3); WorkflowContext ctx = ctx(); Issues issues = issues(); try { reader.invoke(ctx, monitor(), issues); } catch (Exception e) { System.out.println(issues); throw e; } List<Entity> entities = (List<Entity>) ctx.get(entry.getSlot()); List<Datatype> stringTypes = (List<Datatype>) ctx.get(entry2.getSlot()); List<Datatype> booleanTypes = (List<Datatype>) ctx.get(entry3.getSlot()); assertEquals(3,entities.size()); assertEquals(2,stringTypes.size()); assertEquals(2,booleanTypes.size()); Entity ent1 = Iterables.find(entities, getPredicate("1")); Entity ent2 = Iterables.find(entities, getPredicate("2")); Entity ent3 = Iterables.find(entities, getPredicate("3")); Datatype string2 = Iterables.find(stringTypes, getPredicate("2")); Datatype string3 = Iterables.find(stringTypes, getPredicate("3")); Datatype bool1 = Iterables.find(booleanTypes, getPredicate("1")); Datatype bool2 = Iterables.find(booleanTypes, getPredicate("2")); assertEquals(string2,ent1.getProperties().get(0).getType()); assertEquals(bool1, ent1.getProperties().get(1).getType()); assertEquals(ent1,ent1.getProperties().get(2).getType()); assertEquals(string2,ent2.getProperties().get(0).getType()); assertEquals(bool2, ent2.getProperties().get(1).getType()); assertEquals(ent2,ent2.getProperties().get(2).getType()); assertEquals(string3,ent3.getProperties().get(0).getType()); assertEquals(bool1, ent3.getProperties().get(1).getType()); assertEquals(ent3,ent3.getProperties().get(2).getType()); }