Other tests for EmfParsleyDslPluginXmlGenerator
Change-Id: Ia8e623be3a17a802cfe18cee2c09df748cfebe9e
Signed-off-by: Lorenzo Bettini <lorenzo.bettini@gmail.com>
diff --git a/dsl/org.eclipse.emf.parsley.dsl.tests/src/org/eclipse/emf/parsley/dsl/tests/EmfParsleyDslPluginXmlGeneratorTest.xtend b/dsl/org.eclipse.emf.parsley.dsl.tests/src/org/eclipse/emf/parsley/dsl/tests/EmfParsleyDslPluginXmlGeneratorTest.xtend
index 874b660..79d9282 100644
--- a/dsl/org.eclipse.emf.parsley.dsl.tests/src/org/eclipse/emf/parsley/dsl/tests/EmfParsleyDslPluginXmlGeneratorTest.xtend
+++ b/dsl/org.eclipse.emf.parsley.dsl.tests/src/org/eclipse/emf/parsley/dsl/tests/EmfParsleyDslPluginXmlGeneratorTest.xtend
@@ -20,6 +20,9 @@
import org.eclipse.xtext.testing.XtextRunner
import org.junit.Test
import org.junit.runner.RunWith
+import org.eclipse.emf.parsley.dsl.model.ModelFactory
+
+import static extension org.junit.Assert.*
@RunWith(XtextRunner)
@InjectWith(EmfParsleyDslInjectorProvider)
@@ -62,6 +65,11 @@
}
@Test
+ def void testNoViewSpecification2() {
+ inputs.emptyModule.assertNoPluginXmlGeneration
+ }
+
+ @Test
def void testSingleViewSpecification() {
inputs.nonEmptyViewsSpecifications.module.assertPluginXmlContents(
'''
@@ -142,6 +150,12 @@
)
}
+ @Test
+ def void testGenerateExtensionPointWithPartSpecificationNotViewSpecification() {
+ pluginXmlGenerator.generateExtensionPoint(ModelFactory.eINSTANCE.createPartSpecification)
+ .assertNull
+ }
+
def private void assertPluginXmlGeneration(CharSequence input, CharSequence expected) {
val access = new InMemoryFileSystemAccess();
val parsed = input.parseAndAssertNoError
@@ -158,6 +172,15 @@
)
}
+ def private void assertNoPluginXmlGeneration(CharSequence input) {
+ val access = new InMemoryFileSystemAccess();
+ val parsed = input.parseAndAssertNoError
+ pluginXmlGenerator.doGenerate(parsed.eResource(), access);
+ val textFiles = access.getTextFiles()
+ val entrySet = textFiles.entrySet()
+ assertEqualsStrings(0, entrySet.size)
+ }
+
def private void assertPluginXmlContents(Module module, CharSequence expected) {
assertEqualsStrings(expected, pluginXmlGenerator.generatePluginXml(module))
}
diff --git a/dsl/org.eclipse.emf.parsley.dsl/src/org/eclipse/emf/parsley/dsl/generator/EmfParsleyDslPluginXmlGenerator.xtend b/dsl/org.eclipse.emf.parsley.dsl/src/org/eclipse/emf/parsley/dsl/generator/EmfParsleyDslPluginXmlGenerator.xtend
index 5b91f52..e8a3c59 100644
--- a/dsl/org.eclipse.emf.parsley.dsl/src/org/eclipse/emf/parsley/dsl/generator/EmfParsleyDslPluginXmlGenerator.xtend
+++ b/dsl/org.eclipse.emf.parsley.dsl/src/org/eclipse/emf/parsley/dsl/generator/EmfParsleyDslPluginXmlGenerator.xtend
@@ -42,7 +42,7 @@
if (!module.shouldGenerateExtensions) {
return ''''''
} else {
-'''
+ '''
<extension
point="org.eclipse.ui.views">
«module.partsSpecifications.parts.map[generateExtensionPoint].join("")»
@@ -51,25 +51,24 @@
}
}
- def dispatch generateExtensionPoint(PartSpecification partSpecification) {
- }
-
- def dispatch generateExtensionPoint(ViewSpecification viewSpecification) {
+ def CharSequence generateExtensionPoint(PartSpecification partSpecification) {
+ if (partSpecification instanceof ViewSpecification) {
'''
<view
- category="«if (viewSpecification.category === null || viewSpecification.category.empty)
+ category="«if (partSpecification.category.nullOrEmpty)
"org.eclipse.emf.parsley" else
- viewSpecification.category»"
- class="«executableExtensionFactoryQN(viewSpecification)»:«viewSpecification.type.identifier»"
- id="«viewSpecification.id»"
- name="«viewSpecification.viewName»"
+ partSpecification.category»"
+ class="«executableExtensionFactoryQN(partSpecification)»:«partSpecification.type.identifier»"
+ id="«partSpecification.id»"
+ name="«partSpecification.viewName»"
restorable="true">
</view>
'''
+ }
}
def generatePluginXml(CharSequence contents) {
-'''
+ '''
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
@@ -77,4 +76,4 @@
</plugin>
'''
}
-}
\ No newline at end of file
+}