forked from apache/incubator-kie-drools
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from rgdoliveira/sync_main
Sync main branch with Apache main branch
- Loading branch information
Showing
18 changed files
with
1,180 additions
and
271 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
79 changes: 79 additions & 0 deletions
79
kie-dmn/kie-dmn-core/src/test/java/org/kie/dmn/core/compiler/DMNCompilerImplTest.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,79 @@ | ||
/** | ||
* 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.dmn.core.compiler; | ||
|
||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.kie.dmn.model.api.DMNElementReference; | ||
import org.kie.dmn.model.api.Definitions; | ||
import org.kie.dmn.model.api.InformationRequirement; | ||
import org.kie.dmn.model.v1_5.TDMNElementReference; | ||
import org.kie.dmn.model.v1_5.TDefinitions; | ||
import org.kie.dmn.model.v1_5.TInformationRequirement; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class DMNCompilerImplTest { | ||
|
||
private static final String nameSpace = "http://www.montera.com.au/spec/DMN/local-hrefs"; | ||
private static Definitions parent; | ||
|
||
@BeforeAll | ||
static void setup() { | ||
String modelName = "LocalHrefs"; | ||
parent = new TDefinitions(); | ||
parent.setName(modelName); | ||
parent.setNamespace(nameSpace); | ||
} | ||
|
||
@Test | ||
void getId() { | ||
String localPart = "reference"; | ||
DMNElementReference elementReference = new TDMNElementReference(); | ||
elementReference.setHref(String.format("%s#%s", nameSpace, localPart)); | ||
elementReference.setParent(parent); | ||
String retrieved = DMNCompilerImpl.getId(elementReference); | ||
assertThat(retrieved).isNotNull().isEqualTo(localPart); | ||
|
||
String expected = String.format("%s#%s", "http://a-different-namespace", localPart); | ||
elementReference.setHref(expected); | ||
retrieved = DMNCompilerImpl.getId(elementReference); | ||
assertThat(retrieved).isNotNull().isEqualTo(expected); | ||
} | ||
|
||
@Test | ||
void getRootElement() { | ||
String localPart = "reference"; | ||
DMNElementReference elementReference = new TDMNElementReference(); | ||
String href = String.format("%s#%s", nameSpace, localPart); | ||
elementReference.setHref(href); | ||
elementReference.setParent(parent); | ||
Definitions retrieved = DMNCompilerImpl.getRootElement(elementReference); | ||
assertThat(retrieved).isNotNull().isEqualTo(parent); | ||
|
||
InformationRequirement informationRequirement = new TInformationRequirement(); | ||
elementReference.setParent(informationRequirement); | ||
assertThrows(RuntimeException.class, () -> DMNCompilerImpl.getRootElement(elementReference)); | ||
|
||
informationRequirement.setParent(parent); | ||
retrieved = DMNCompilerImpl.getRootElement(elementReference); | ||
assertThat(retrieved).isNotNull().isEqualTo(parent); | ||
} | ||
} |
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
Oops, something went wrong.