Skip to content

Commit 63d4f25

Browse files
committed
test: check that gated works with prefixed names
1 parent d9a0881 commit 63d4f25

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
app.hypermedia.testing.dsl.tests.generator.hydra.PropertyConstraintTest.gatedClass_whenPropertyPrefixedUri=[
2+
{
3+
"map": {
4+
"steps": {
5+
"myArrayList": [
6+
{
7+
"map": {
8+
"children": {
9+
"myArrayList": [ ],
10+
"empty": true
11+
},
12+
"classId": "http://example.comFoo",
13+
"constraints": {
14+
"myArrayList": [
15+
{
16+
"map": {
17+
"constrain": "Property",
18+
"left": "http://example.com/bar",
19+
"negated": false,
20+
"operator": "eq",
21+
"right": "some text"
22+
},
23+
"empty": false
24+
}
25+
],
26+
"empty": false
27+
},
28+
"type": "Class"
29+
},
30+
"empty": false
31+
}
32+
],
33+
"empty": false
34+
}
35+
},
36+
"empty": false
37+
}
38+
]
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package app.hypermedia.testing.dsl.tests.generator.hydra
2+
3+
import org.eclipse.xtext.generator.InMemoryFileSystemAccess
4+
import org.junit.jupiter.api.^extension.ExtendWith
5+
import org.eclipse.xtext.testing.extensions.InjectionExtension
6+
import org.eclipse.xtext.testing.InjectWith
7+
import com.google.inject.Inject
8+
import org.eclipse.xtext.testing.util.ParseHelper
9+
import app.hypermedia.testing.dsl.hydra.HydraScenario
10+
import org.junit.jupiter.api.Test
11+
import static io.github.jsonSnapshot.SnapshotMatcher.*
12+
import org.eclipse.xtext.generator.IGenerator2
13+
import org.junit.jupiter.api.BeforeAll
14+
import org.junit.jupiter.api.AfterAll
15+
import org.json.JSONObject
16+
import app.hypermedia.testing.dsl.tests.HydraInjectorProvider
17+
import org.eclipse.xtext.generator.GeneratorContext
18+
19+
@ExtendWith(InjectionExtension)
20+
@InjectWith(HydraInjectorProvider)
21+
class PropertyConstraintTest {
22+
@Inject IGenerator2 generator
23+
@Inject ParseHelper<HydraScenario> parseHelper
24+
@BeforeAll
25+
static def beforeAll() {
26+
start()
27+
}
28+
29+
@AfterAll
30+
static def afterAll() {
31+
validateSnapshots();
32+
}
33+
34+
@Test
35+
def gatedClass_whenPropertyPrefixedUri() {
36+
// given
37+
val model = parseHelper.parse('''
38+
PREFIX ex: <http://example.com/>
39+
40+
With Class ex:Foo {
41+
When Property ex:bar Equals "some text"
42+
}
43+
''')
44+
45+
// when
46+
val fsa = new InMemoryFileSystemAccess()
47+
generator.doGenerate(model.eResource, fsa, new GeneratorContext())
48+
println(fsa.textFiles)
49+
50+
// then
51+
val file = new JSONObject(fsa.textFiles.values.get(0).toString)
52+
expect(file).toMatchSnapshot()
53+
}
54+
}

0 commit comments

Comments
 (0)