Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[incubator-kie-issues#1627] Change log level from error to debug inside ImportDMNResolverUtil #6172

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ public static <T> Either<String, T> resolveImportDMN(Import importElement, Colle
"Importing a DMN model with namespace={} name={} locationURI={}, modelName={}",
importerDMNName, importerDMNNamespace, importNamespace, importName, importLocationURI, importModelName);

if (dmns.isEmpty()) {
return Either.ofLeft("Impossible to resolve an import against an empty DMN collection");
}

List<T> matchingDMNList = dmns.stream()
.filter(m -> idExtractor.apply(m).getNamespaceURI().equals(importNamespace))
.toList();
Expand All @@ -64,7 +68,7 @@ public static <T> Either<String, T> resolveImportDMN(Import importElement, Colle
importerDMNName, importerDMNNamespace, importNamespace, importName, importLocationURI, importModelName);
return Either.ofRight(located);
} else {
LOGGER.debug("DMN Model with name={} and namespace={} can't import a DMN with namespace={}, name={}, modelName={}, " +
LOGGER.error("DMN Model with name={} and namespace={} can't import a DMN with namespace={}, name={}, modelName={}, " +
"located within namespace only {} but does not match for the actual modelName",
importerDMNName, importerDMNNamespace, importNamespace, importName, importModelName, idExtractor.apply(located));
return Either.ofLeft(String.format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.kie.dmn.core.compiler;

import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -156,7 +157,6 @@ void locateInNSnoModelNameWithAlias2() {

@Test
void locateInNSAliasedBadScenario() {
// this is a BAD scenario are in namespace `nsA` there are 2 models with the same name.
final Import i = makeImport("nsA", "aliased", "mA");
final List<QName> available = Arrays.asList(new QName("nsA", "mA"),
new QName("nsA", "mA"),
Expand All @@ -165,6 +165,13 @@ void locateInNSAliasedBadScenario() {
assertThat(result.isLeft()).isTrue();
}

@Test
void emptyDMNCollection() {
final Import i = makeImport("nsA", "aliased", "mA");
final Either<String, QName> result = ImportDMNResolverUtil.resolveImportDMN(i, Collections.emptyList(), Function.identity());
assertThat(result.isLeft()).isTrue();
}

private Import makeImport(final String namespace, final String name, final String modelName) {
final Import i = new TImport();
i.setNamespace(namespace);
Expand Down