Skip to content

Commit

Permalink
Move assertIsValid in external MelangeTestHelper
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Degueule authored and François Boschet committed Aug 26, 2015
1 parent 76fa73d commit 75f5387
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
package fr.inria.diverse.melange.tests

import fr.inria.diverse.melange.resource.MelangeResourceException
import org.eclipse.emf.common.util.Diagnostic
import fr.inria.diverse.melange.tests.common.MelangeTestHelper
import org.eclipse.emf.common.util.URI
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.resource.ResourceSet
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl
import org.eclipse.emf.ecore.util.Diagnostician
import org.junit.Before
import org.junit.Test
import simplefsm.StandaloneSetup
Expand All @@ -15,6 +14,7 @@ import static org.junit.Assert.*

class ResourceTest
{
extension MelangeTestHelper = new MelangeTestHelper
ResourceSet rs

@Before
Expand Down Expand Up @@ -101,12 +101,4 @@ class ResourceTest
res.allContents.forall[class.interfaces.exists[package.name == "simplefsm.timedfsmmt"]]
)
}

private def assertIsValid(Resource res) {
val diagnostic = Diagnostician.INSTANCE.validate(res.contents.head)
assertTrue(
diagnostic.toString,
diagnostic.severity == Diagnostic.OK
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@ import fr.inria.diverse.melange.metamodel.melange.Transformation
import java.io.IOException
import java.util.List
import javax.inject.Inject
import org.eclipse.emf.common.util.Diagnostic
import org.eclipse.emf.ecore.EObject
import org.eclipse.emf.ecore.ETypedElement
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.emf.ecore.util.Diagnostician
import org.eclipse.xtext.util.IAcceptor
import org.eclipse.xtext.xbase.compiler.CompilationTestHelper
import org.eclipse.xtext.xbase.compiler.CompilationTestHelper.Result
Expand Down Expand Up @@ -81,6 +84,18 @@ class MelangeTestHelper
Assert.assertTrue(l.implements.contains(mt))
}

def dispatch void assertIsValid(Resource res) {
assertIsValid(res.contents.head)
}

def dispatch void assertIsValid(EObject obj) {
val diagnostic = Diagnostician.INSTANCE.validate(obj)
Assert.assertTrue(
diagnostic.toString,
diagnostic.severity == Diagnostic.OK
)
}

def EObject getEObject(ModelingElement m, String path) {
val segments = path.split("/")
val pkg_ = segments.get(0)
Expand Down

0 comments on commit 75f5387

Please sign in to comment.