-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
219 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...a.testing.dsl/src/test/java/app/hypermedia/testing/dsl/tests/hydra/ClassParsingTest.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* generated by Xtext 2.18.0 | ||
*/ | ||
package app.hypermedia.testing.dsl.tests.hydra | ||
|
||
import app.hypermedia.testing.dsl.core.CorePackage | ||
import app.hypermedia.testing.dsl.hydra.HydraScenario | ||
import app.hypermedia.testing.dsl.tests.HydraInjectorProvider | ||
import com.google.inject.Inject | ||
import org.eclipse.xtext.testing.InjectWith | ||
import org.eclipse.xtext.testing.extensions.InjectionExtension | ||
import org.eclipse.xtext.testing.util.ParseHelper | ||
import org.eclipse.xtext.testing.validation.ValidationTestHelper | ||
import org.junit.jupiter.api.^extension.ExtendWith | ||
import org.junit.jupiter.params.ParameterizedTest | ||
import org.junit.jupiter.params.provider.MethodSource | ||
|
||
@ExtendWith(InjectionExtension) | ||
@InjectWith(HydraInjectorProvider) | ||
class ClassParsingTest { | ||
@Inject extension ParseHelper<HydraScenario> | ||
@Inject extension ValidationTestHelper | ||
|
||
@ParameterizedTest | ||
@MethodSource("app.hypermedia.testing.dsl.tests.hydra.TestCases#invalidUris") | ||
def void classWithInvalidUri_failsValidation(String id) { | ||
// when | ||
val result = ''' | ||
With Class <«id»> { } | ||
'''.parse | ||
|
||
// then | ||
result.assertError( | ||
CorePackage.Literals.CLASS_BLOCK, | ||
null, | ||
"Value is not a valid URI" | ||
) | ||
} | ||
|
||
@ParameterizedTest | ||
@MethodSource("app.hypermedia.testing.dsl.tests.hydra.TestCases#validUris") | ||
def void classWithValidUri_passesValidation(String id) { | ||
// when | ||
val result = ''' | ||
With Class <«id»> { } | ||
'''.parse | ||
|
||
// then | ||
result.assertNoIssues() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...permedia.testing.dsl/src/test/java/app/hypermedia/testing/dsl/tests/hydra/TestCases.xtend
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package app.hypermedia.testing.dsl.tests.hydra | ||
|
||
class TestCases { | ||
static def validUris() { | ||
return #[ | ||
"http://xmlns.com/foaf/0.1/", | ||
"urn:valid:urn", | ||
"mailto:dsl@example.com" | ||
] | ||
} | ||
|
||
static def invalidUris() { | ||
return #[ | ||
"not-a-URI", | ||
"12345" | ||
] | ||
} | ||
} |