From 3a7ad041f6ecc27ae47804ba2db806e92793224f Mon Sep 17 00:00:00 2001 From: xuelianhan007 Date: Thu, 12 Dec 2024 18:02:53 +0800 Subject: [PATCH] added unit tests --- .../MappingMatrixCheckerActionRunnerTest.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java b/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java index d79078d7..31d508a7 100644 --- a/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java +++ b/kraken-java-sdk/kraken-java-sdk-gateway/src/test/java/com/consoleconnect/kraken/operator/gateway/runner/MappingMatrixCheckerActionRunnerTest.java @@ -3,6 +3,7 @@ import static com.consoleconnect.kraken.operator.gateway.runner.ResponseCodeTransform.TARGET_KEY_NOT_FOUND; import com.consoleconnect.kraken.operator.core.enums.ExpectTypeEnum; +import com.consoleconnect.kraken.operator.core.enums.MappingTypeEnum; import com.consoleconnect.kraken.operator.core.exception.KrakenException; import com.consoleconnect.kraken.operator.core.toolkit.JsonToolkit; import com.consoleconnect.kraken.operator.gateway.CustomConfig; @@ -11,6 +12,7 @@ import com.consoleconnect.kraken.operator.test.MockIntegrationTest; import java.io.IOException; import java.util.HashMap; +import java.util.List; import java.util.Map; import lombok.SneakyThrows; import org.hamcrest.MatcherAssert; @@ -233,4 +235,22 @@ void givenCheckPath_whenCheckExpect_thenReturnException() { Assertions.assertThrowsExactly( KrakenException.class, () -> mappingMatrixCheckerActionRunner.checkExpect(pathCheck6, "")); } + + @Test + void givenNonDiscreteString_whenValidating_thenThrowsException() { + Assertions.assertThrowsExactly( + KrakenException.class, + () -> + mappingMatrixCheckerActionRunner.validateDiscreteString( + 123, "x", MappingTypeEnum.DISCRETE_STR.getKind())); + } + + @Test + void givenValueList_whenValueNotIn_thenThrowsException() { + Assertions.assertThrowsExactly( + KrakenException.class, + () -> + mappingMatrixCheckerActionRunner.validateEnumOrDiscreteString( + "4", "x", List.of("1", "2", "3"), MappingTypeEnum.DISCRETE_STR.getKind())); + } }