File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
main/java/at/ac/uibk/dps/cirrina/io/parsing
test/java/at/ac/uibk/dps/cirrina/io/parsing Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,29 @@ object CsmParser {
8686 }
8787 }
8888
89+ /* *
90+ * Parse a service implementation bindings Pkl module at a URI. Returns an instance of
91+ * ServiceImplementationBindings upon success. Any errors will result in an
92+ * IllegalArgumentException being thrown.
93+ *
94+ * @param serviceImplementationBindingsModuleUri Main Pkl module URI.
95+ * @return Csml model.
96+ * @throws IllegalArgumentException If an error occurs.
97+ */
98+ fun parseServiceImplementationBindings (
99+ serviceImplementationBindingsModuleUri : URI
100+ ): ServiceImplementationBindings {
101+ try {
102+ evaluator().use { evaluator ->
103+ return evaluator
104+ .evaluate(ModuleSource .uri(serviceImplementationBindingsModuleUri))
105+ .`as `(ServiceImplementationBindings ::class .java)
106+ }
107+ } catch (e: Exception ) {
108+ throw IllegalArgumentException (" Parsing error" , e)
109+ }
110+ }
111+
89112 /* *
90113 * Parse a service implementation bindings Pkl module at a path. Returns an instance of
91114 * ServiceImplementationBindings upon success. Any errors will result in an
Original file line number Diff line number Diff line change @@ -33,6 +33,17 @@ class CsmParserTest {
3333 }
3434 }
3535
36+ @Test
37+ fun loadServiceImplementationBindingsUri () {
38+ Assertions .assertDoesNotThrow {
39+ CsmParser .parseServiceImplementationBindings(
40+ URI .create(
41+ " https://raw.githubusercontent.com/CollaborativeStateMachines/Cirrina/refs/heads/develop/src/test/resources/pkl/serviceImplementation/services.pkl"
42+ )
43+ )
44+ }
45+ }
46+
3647 @Test
3748 fun loadServiceImplementationBindings () {
3849 assertDoesNotThrow {
You can’t perform that action at this time.
0 commit comments