Fixed issue in isSubset

This commit is contained in:
Andreas Isler
2025-12-05 09:19:33 +01:00
parent b105c63c7e
commit bbaacfb439
2 changed files with 3 additions and 9 deletions
@@ -6,8 +6,6 @@ import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource; import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
@@ -23,8 +21,6 @@ class FlowableExcelMapperTest {
@Autowired @Autowired
private FlowableExcelMapper flowableExcelMapper; private FlowableExcelMapper flowableExcelMapper;
protected static final Logger logger = LoggerFactory.getLogger(FlowableExcelMapperTest.class);
public boolean isSubset(JsonNode root, JsonNode test) { public boolean isSubset(JsonNode root, JsonNode test) {
// If test is null, it is always a subset of root // If test is null, it is always a subset of root
@@ -71,7 +67,7 @@ class FlowableExcelMapperTest {
rootValue = root.get(fieldName); rootValue = root.get(fieldName);
} }
if (testValue.isTextual() && "__N_A".equals(testValue.asText())) { if (testValue.isTextual() && "__N_A".equals(testValue.asText())) {
if (rootValue != null && !rootValue.isNull()) { if (root != null && root.has(fieldName)) {
return false; return false;
} }
continue; continue;
@@ -105,9 +101,8 @@ class FlowableExcelMapperTest {
public void excelMapperTestOk(JsonNode row) { public void excelMapperTestOk(JsonNode row) {
JsonNode root = row.get("root"); JsonNode root = row.get("root");
JsonNode test = row.get("test"); JsonNode test = row.get("test");
logger.info("{}root={}{}test={}", System.lineSeparator(), root, System.lineSeparator(), test);
Assertions.assertThat(isSubset(root, test)) Assertions.assertThat(isSubset(root, test))
.withFailMessage(System.lineSeparator() + "root=" + root + System.lineSeparator() + "test=" + test).isTrue(); .withFailMessage(System.lineSeparator() + "test :" + test + System.lineSeparator() + "root :" + root).isTrue();
} }
protected Stream<Arguments> excelMapperTestFail() { protected Stream<Arguments> excelMapperTestFail() {
@@ -118,8 +113,7 @@ class FlowableExcelMapperTest {
public void excelMapperTestFail(JsonNode row) { public void excelMapperTestFail(JsonNode row) {
JsonNode root = row.get("root"); JsonNode root = row.get("root");
JsonNode test = row.get("test"); JsonNode test = row.get("test");
logger.info("{}root={}{}test={}", System.lineSeparator(), root, System.lineSeparator(), test);
Assertions.assertThat(isSubset(root, test)) Assertions.assertThat(isSubset(root, test))
.withFailMessage(System.lineSeparator() + "root=" + root + System.lineSeparator() + "test=" + test).isFalse(); .withFailMessage(System.lineSeparator() + "test :" + test + System.lineSeparator() + "root :" + root).isFalse();
} }
} }