From 8468aed817dda1299d02cd1a503fa31ec4436a5f Mon Sep 17 00:00:00 2001 From: Madalin Ilie Date: Mon, 9 Sep 2024 23:09:05 +0300 Subject: [PATCH] chore: Add unit test for additional branches --- .../endava/cats/args/FilesArgumentsTest.java | 1 + .../cats/factory/FuzzingDataFactoryTest.java | 2 +- .../endava/cats/util/CatsModeLUtilsTest.java | 22 +++++++++++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 src/test/java/com/endava/cats/util/CatsModeLUtilsTest.java diff --git a/src/test/java/com/endava/cats/args/FilesArgumentsTest.java b/src/test/java/com/endava/cats/args/FilesArgumentsTest.java index d0ff7d8c7..5f1b43548 100644 --- a/src/test/java/com/endava/cats/args/FilesArgumentsTest.java +++ b/src/test/java/com/endava/cats/args/FilesArgumentsTest.java @@ -215,6 +215,7 @@ void shouldLoadPathsOrder() throws Exception { void shouldLoadMutators() throws Exception { FilesArguments filesArguments = new FilesArguments(); filesArguments.setMutatorsFolder(new File("src/test/resources/mutators")); + filesArguments.loadMutators(); org.assertj.core.api.Assertions.assertThat(filesArguments.getMutatorsFolder()).isDirectory(); } diff --git a/src/test/java/com/endava/cats/factory/FuzzingDataFactoryTest.java b/src/test/java/com/endava/cats/factory/FuzzingDataFactoryTest.java index ddcc7c035..aeeba3490 100644 --- a/src/test/java/com/endava/cats/factory/FuzzingDataFactoryTest.java +++ b/src/test/java/com/endava/cats/factory/FuzzingDataFactoryTest.java @@ -746,7 +746,7 @@ void shouldRecordErrorWhenParamRefDoesNotExist() throws Exception { } @Test - void shouldExtractMultiLevelExamples() throws Exception { + void shouldExtractMultiLevelExamples() { ObjectMapper objectMapper = new ObjectMapper(); ObjectNode exampleMapObject = objectMapper.createObjectNode(); exampleMapObject.set("WORKER_COMPENSATION_PAYRATE_POST_PATCH", objectMapper.createObjectNode().put("value", "catsIsCool")); diff --git a/src/test/java/com/endava/cats/util/CatsModeLUtilsTest.java b/src/test/java/com/endava/cats/util/CatsModeLUtilsTest.java new file mode 100644 index 000000000..1a9ea6268 --- /dev/null +++ b/src/test/java/com/endava/cats/util/CatsModeLUtilsTest.java @@ -0,0 +1,22 @@ +package com.endava.cats.util; + +import io.quarkus.test.junit.QuarkusTest; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +@QuarkusTest +class CatsModeLUtilsTest { + + @ParameterizedTest + @CsvSource(value = { + "#/components/schemas/SomeSchema, SomeSchema", + "#/components/schemas/AnotherSchema, AnotherSchema", + "#/components/schemas/YetAnotherSchema, YetAnotherSchema", + "null,null", "#/paths/path1,#/paths/path1"}, nullValues = "null") + void shouldReturnSimpleReference(String ref, String expected) { + String result = CatsModelUtils.getSimpleRef(ref); + + Assertions.assertThat(result).isEqualTo(expected); + } +}