-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Each element should return a map instead of JSON string where possible
to make accessing the JSON easier in MVEL elements. No two elements should have two names.
- Loading branch information
1 parent
886b787
commit 6d88ca7
Showing
11 changed files
with
339 additions
and
21 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
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
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
41 changes: 41 additions & 0 deletions
41
yard-core/src/test/java/org/kie/yard/core/DublicateElementNameTest.java
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,41 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.kie.yard.core; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class DublicateElementNameTest | ||
extends TestBase { | ||
|
||
private static final String FILE_NAME = "/two-elements-with-duplicate-name.yml"; | ||
|
||
@Test | ||
public void testNoDublicateNames() throws Exception { | ||
final String CTX = """ | ||
{ | ||
"Age": 10 | ||
} | ||
"""; | ||
assertThrows(IllegalArgumentException.class, () -> | ||
evaluate(CTX, FILE_NAME) | ||
); | ||
} | ||
} |
59 changes: 59 additions & 0 deletions
59
yard-core/src/test/java/org/kie/yard/core/MVELJSONTest.java
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,59 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
package org.kie.yard.core; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
public class MVELJSONTest | ||
extends TestBase { | ||
|
||
private static final String FILE_NAME = "/mvel-json-dot-access.yml"; | ||
|
||
@Test | ||
public void testMVELManagesJSONMaps() throws Exception { | ||
final String CTX = """ | ||
{ | ||
"Work Address":true | ||
} | ||
"""; | ||
final Map<String, Object> output = evaluate(CTX, FILE_NAME); | ||
|
||
final Map mailingAddress = (Map) output.get("Mailing Address"); | ||
assertEquals("Work Street", mailingAddress.get("Street")); | ||
assertEquals(23, mailingAddress.get("Number")); | ||
|
||
final List deliveryItemNames = (List) output.get("Delivery Item Names"); | ||
assertEquals(3, deliveryItemNames.size()); | ||
assertTrue(deliveryItemNames.contains("Work Shoes")); | ||
assertTrue(deliveryItemNames.contains("Work Hat")); | ||
assertTrue(deliveryItemNames.contains("Work Shirt")); | ||
|
||
final Map JSONTest= (Map) output.get("JSON Test"); | ||
assertEquals("Best Company LTD", JSONTest.get("Company")); | ||
|
||
final Map mapTest = (Map) output.get("Map Test"); | ||
assertEquals("Hello", mapTest.get("Map")); | ||
} | ||
} |
Oops, something went wrong.