diff options
author | 2025-01-28 14:22:22 +0530 | |
---|---|---|
committer | 2025-01-28 14:42:29 +0530 | |
commit | 82abee1332fa7c76079f470a220987b6a7d37d79 (patch) | |
tree | 9a611ad0b29ab27e3019682e044946fc6ea22f41 | |
parent | fcab8a73c875f9fd86823c8060ee66444e3efa61 (diff) |
[AAI] Improve test coverage for A&AI component aai-schema-service
- to Improve test coverage for aai-schema-service <=80% add more classes
Issue-ID: AAI-4107
Change-Id: I56110ab2c4f997e325503534e0796c8dc2cca81b
Signed-off-by: nisha.gangore <nisha.gangore@accenture.com>
5 files changed, 593 insertions, 0 deletions
diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/SchemaVersionTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/SchemaVersionTest.java new file mode 100644 index 0000000..8778fc6 --- /dev/null +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/SchemaVersionTest.java @@ -0,0 +1,100 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2025 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.schemaservice.nodeschema; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.onap.aai.schemaservice.nodeschema.validation.AAISchemaValidationException; +import static org.junit.jupiter.api.Assertions.*; + +class SchemaVersionTest { + + private SchemaVersion version1; + private SchemaVersion version2; + private SchemaVersion version3; + private SchemaVersion versionNull; + + @BeforeEach + void setUp() { + version1 = new SchemaVersion("v1"); + version2 = new SchemaVersion("v2"); + version3 = new SchemaVersion("v10"); + versionNull = null; + } + + @Test + void testConstructorValidVersion() { + assertDoesNotThrow(() -> new SchemaVersion("v1")); + assertDoesNotThrow(() -> new SchemaVersion("v100")); + } + + @Test + void testConstructorInvalidVersion() { + assertThrows(AAISchemaValidationException.class, () -> new SchemaVersion("1")); + assertThrows(AAISchemaValidationException.class, () -> new SchemaVersion("v0")); + assertThrows(AAISchemaValidationException.class, () -> new SchemaVersion("vabc")); + assertThrows(AAISchemaValidationException.class, () -> new SchemaVersion("version1")); + } + + @Test + void testEquals() { + SchemaVersion versionA = new SchemaVersion("v1"); + SchemaVersion versionB = new SchemaVersion("v1"); + SchemaVersion versionC = new SchemaVersion("v2"); + + assertTrue(versionA.equals(versionA)); + assertEquals(versionA, versionB); + assertNotEquals(versionA, versionC); + assertNotEquals(versionA, versionNull); + assertNotEquals(versionA, "v1"); + } + + @Test + void testHashCode() { + SchemaVersion versionA = new SchemaVersion("v1"); + SchemaVersion versionB = new SchemaVersion("v1"); + SchemaVersion versionC = new SchemaVersion("v2"); + + assertEquals(versionA.hashCode(), versionB.hashCode()); + assertNotEquals(versionA.hashCode(), versionC.hashCode()); + } + + @Test + void testToString() { + SchemaVersion versionA = new SchemaVersion("v1"); + SchemaVersion versionB = new SchemaVersion("v10"); + + assertEquals("v1", versionA.toString()); + assertEquals("v10", versionB.toString()); + } + + @Test + void testCompareTo() { + assertTrue(version1.compareTo(version2) < 0); + assertTrue(version2.compareTo(version1) > 0); + assertTrue(version1.compareTo(version1) == 0); + assertTrue(version2.compareTo(version3) < 0); + } + + @Test + void testCompareToWithNull() { + assertEquals(-1, version1.compareTo(null)); + } +} diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/SchemaVersionsTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/SchemaVersionsTest.java new file mode 100644 index 0000000..cc5be12 --- /dev/null +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/SchemaVersionsTest.java @@ -0,0 +1,169 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2025 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.schemaservice.nodeschema; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.InjectMocks; +import org.mockito.junit.jupiter.MockitoExtension; +import org.onap.aai.schemaservice.nodeschema.validation.AAISchemaValidationException; +import org.springframework.test.util.ReflectionTestUtils; +import java.util.Arrays; +import java.util.List; +import static org.junit.jupiter.api.Assertions.*; + +@ExtendWith(MockitoExtension.class) +class SchemaVersionsTest { + + @InjectMocks + private SchemaVersions schemaVersions; + + private List<String> mockApiVersions; + private String mockDefaultVersion = "v1"; + private String mockEdgeLabelVersion = "v2"; + private String mockDepthVersion = "v3"; + private String mockAppRootVersion = "v4"; + private String mockRelatedLinkVersion = "v5"; + private String mockNamespaceChangeVersion = "v6"; + + @BeforeEach + void setUp() { + mockApiVersions = Arrays.asList("v1", "v2", "v3", "v4", "v5", "v6", "v7", "v8"); + + ReflectionTestUtils.setField(schemaVersions, "apiVersions", mockApiVersions); + ReflectionTestUtils.setField(schemaVersions, "defaultApiVersion", mockDefaultVersion); + ReflectionTestUtils.setField(schemaVersions, "edgeLabelStartVersion", mockEdgeLabelVersion); + ReflectionTestUtils.setField(schemaVersions, "depthStartVersion", mockDepthVersion); + ReflectionTestUtils.setField(schemaVersions, "appRootStartVersion", mockAppRootVersion); + ReflectionTestUtils.setField(schemaVersions, "relatedLinkStartVersion", mockRelatedLinkVersion); + ReflectionTestUtils.setField(schemaVersions, "namespaceChangeStartVersion", mockNamespaceChangeVersion); + } + + @Test + void testInitializeShouldNotThrowExceptionWhenValidVersions() { + assertDoesNotThrow(() -> schemaVersions.initialize()); + } + + @Test + void testInitializeShouldThrowExceptionWhenRelatedLinkVersionIsInvalid() { + mockApiVersions = Arrays.asList("v1", "v2", "v3", "v4", "v6"); + ReflectionTestUtils.setField(schemaVersions, "apiVersions", mockApiVersions); + assertThrows(AAISchemaValidationException.class, () -> schemaVersions.initialize(), + "Invalid, related link version is not in the api versions list"); + } + + @Test + void testInitializeShouldThrowExceptionWhenNamespaceChangeVersionIsInvalid() { + mockApiVersions = Arrays.asList("v1", "v2", "v3", "v4", "v5"); + ReflectionTestUtils.setField(schemaVersions, "apiVersions", mockApiVersions); + assertThrows(AAISchemaValidationException.class, () -> schemaVersions.initialize(), + "Invalid, namespace change start version is not in the api versions list"); + } + + @Test + void testInitializeShouldThrowExceptionWhenDefaultVersionIsInvalid() { + mockApiVersions = Arrays.asList("v2", "v3", "v4", "v5", "v6"); + ReflectionTestUtils.setField(schemaVersions, "apiVersions", mockApiVersions); + assertThrows(AAISchemaValidationException.class, () -> schemaVersions.initialize(), + "Invalid, default version is not in the api versions list"); + } + + @Test + void testInitializeShouldThrowExceptionWhenDepthVersionIsInvalid() { + mockApiVersions = Arrays.asList("v1", "v2", "v4", "v5", "v6"); + ReflectionTestUtils.setField(schemaVersions, "apiVersions", mockApiVersions); + assertThrows(AAISchemaValidationException.class, () -> schemaVersions.initialize(), + "Invalid, depth version is not in the api versions list"); + } + + @Test + void testGetVersionsReturnsCorrectVersions() { + schemaVersions.initialize(); + List<SchemaVersion> versions = schemaVersions.getVersions(); + assertNotNull(versions); + assertEquals(8, versions.size()); + assertEquals("v1", versions.get(0).toString()); + assertEquals("v2", versions.get(1).toString()); + assertEquals("v3", versions.get(2).toString()); + assertEquals("v4", versions.get(3).toString()); + assertEquals("v5", versions.get(4).toString()); + assertEquals("v6", versions.get(5).toString()); + } + + @Test + void testGetEdgeLabelVersion() { + schemaVersions.initialize(); + assertEquals(mockEdgeLabelVersion, schemaVersions.getEdgeLabelVersion().toString()); + } + + @Test + void testGetDefaultVersion() { + schemaVersions.initialize(); + assertEquals(mockDefaultVersion, schemaVersions.getDefaultVersion().toString()); + } + + @Test + void testGetDepthVersion() { + schemaVersions.initialize(); + assertEquals(mockDepthVersion, schemaVersions.getDepthVersion().toString()); + } + + @Test + void testGetAppRootVersion() { + schemaVersions.initialize(); + assertEquals(mockAppRootVersion, schemaVersions.getAppRootVersion().toString()); + } + + @Test + void testGetRelatedLinkVersion() { + schemaVersions.initialize(); + assertEquals(mockRelatedLinkVersion, schemaVersions.getRelatedLinkVersion().toString()); + } + + @Test + void testGetNamespaceChangeVersion() { + schemaVersions.initialize(); + assertEquals(mockNamespaceChangeVersion, schemaVersions.getNamespaceChangeVersion().toString()); + } + + @Test + void testSetNamespaceChangeVersion() { + SchemaVersion newNamespaceChangeVersion = new SchemaVersion("v7"); + schemaVersions.setNamespaceChangeVersion(newNamespaceChangeVersion); + assertEquals("v7", schemaVersions.getNamespaceChangeVersion().toString()); + } + + @Test + void testInitializeShouldThrowExceptionWhenEdgeLabelVersionIsInvalid() { + mockApiVersions = Arrays.asList("v1", "v3", "v4", "v5", "v6"); + ReflectionTestUtils.setField(schemaVersions, "apiVersions", mockApiVersions); + assertThrows(AAISchemaValidationException.class, () -> schemaVersions.initialize(), + "Invalid, edge label version is not in the api versions list"); + } + + @Test + void testInitializeShouldThrowExceptionWhenAppRootVersionIsInvalid() { + mockApiVersions = Arrays.asList("v1", "v2", "v3", "v5", "v6"); + ReflectionTestUtils.setField(schemaVersions, "apiVersions", mockApiVersions); + assertThrows(AAISchemaValidationException.class, () -> schemaVersions.initialize(), + "Invalid, app root version is not in the api versions list"); + } +} diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategyTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategyTest.java new file mode 100644 index 0000000..374dbfc --- /dev/null +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/CheckEverythingStrategyTest.java @@ -0,0 +1,79 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2025 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.schemaservice.nodeschema.validation; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class CheckEverythingStrategyTest { + + private CheckEverythingStrategy strategy; + + @BeforeEach + void setUp() { + strategy = new CheckEverythingStrategy(); + } + + @Test + void testIsOKInitially() { + assertTrue(strategy.isOK()); + } + + @Test + void testGetErrorMsgWhenNoErrors() { + assertEquals("No errors found.", strategy.getErrorMsg()); + } + + @Test + void testIsOKAfterError() { + strategy.notifyOnError("Error 1"); + assertFalse(strategy.isOK()); + } + + @Test + void testGetErrorMsgAfterOneError() { + strategy.notifyOnError("Error 1"); + assertEquals("Error 1", strategy.getErrorMsg()); + } + + @Test + void testGetErrorMsgAfterMultipleErrors() { + strategy.notifyOnError("Error 1"); + strategy.notifyOnError("Error 2"); + assertEquals("Error 1\nError 2", strategy.getErrorMsg()); + } + + @Test + void testNotifyOnErrorShouldChangeState() { + strategy.notifyOnError("First error"); + assertFalse(strategy.isOK()); + + strategy.notifyOnError("Second error"); + assertFalse(strategy.isOK()); + } + + @Test + void testNotifyOnErrorWithEmptyMessage() { + strategy.notifyOnError(""); + assertFalse(strategy.isOK()); + assertEquals("", strategy.getErrorMsg()); + } +} diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModuleTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModuleTest.java new file mode 100644 index 0000000..ffce3a2 --- /dev/null +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultDuplicateNodeDefinitionValidationModuleTest.java @@ -0,0 +1,101 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2025 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.schemaservice.nodeschema.validation; + +import com.google.common.collect.ArrayListMultimap; +import com.google.common.collect.Multimap; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.aai.schemaservice.nodeschema.SchemaVersion; +import javax.xml.parsers.DocumentBuilder; +import java.io.IOException; +import java.io.InputStream; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +class DefaultDuplicateNodeDefinitionValidationModuleTest { + + private DefaultDuplicateNodeDefinitionValidationModule validationModule; + + @Mock + private SchemaVersion mockSchemaVersion; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + validationModule = new DefaultDuplicateNodeDefinitionValidationModule(); + } + + @Test + void testFindDuplicates_ShouldHandleEmptyFileList() throws Exception { + List<String> files = Collections.emptyList(); + when(mockSchemaVersion.toString()).thenReturn("v1"); + + String result = validationModule.findDuplicates(files, mockSchemaVersion); + + assertEquals("", result); + } + + @Test + void testBuildErrorMsg() throws Exception { + Multimap<String, String> types = ArrayListMultimap.create(); + types.put("nodeType1", "file1.xml"); + types.put("nodeType1", "file2.xml"); + types.put("nodeType2", "file3.xml"); + + when(mockSchemaVersion.toString()).thenReturn("v1"); + + Method buildErrorMsgMethod = DefaultDuplicateNodeDefinitionValidationModule.class + .getDeclaredMethod("buildErrorMsg", Multimap.class, SchemaVersion.class); + buildErrorMsgMethod.setAccessible(true); + + String result = (String) buildErrorMsgMethod.invoke(validationModule, types, mockSchemaVersion); + + String expected = "Duplicates found in version v1. nodeType1 has definitions in file1.xml file2.xml "; + assertEquals(expected, result); + } + + @Test + void testFindDuplicatesCatchPart() throws Exception { + List<String> files = new ArrayList<>(); + files.add("Java"); + files.add("abc"); + + when(mockSchemaVersion.toString()).thenReturn("v1"); + + InputStream inputStreamThatThrowsIOException = mock(InputStream.class); + when(inputStreamThatThrowsIOException.read()).thenThrow(new IOException("The system cannot find the file specified")); + + DocumentBuilder mockDocBuilder = mock(DocumentBuilder.class); + when(mockDocBuilder.parse(inputStreamThatThrowsIOException)).thenThrow(new IOException("The system cannot find the file specified")); + + String result = validationModule.findDuplicates(files, mockSchemaVersion); + + assertEquals("Java (No such file or directory)", result); + } + +} diff --git a/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModuleTest.java b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModuleTest.java new file mode 100644 index 0000000..324bdee --- /dev/null +++ b/aai-schema-service/src/test/java/org/onap/aai/schemaservice/nodeschema/validation/DefaultVersionValidationModuleTest.java @@ -0,0 +1,144 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2025 Deutsche Telekom. All rights reserved. + * ================================================================================ + * Licensed 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. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.schemaservice.nodeschema.validation; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.MockitoAnnotations; +import org.onap.aai.schemaservice.config.ConfigTranslator; +import org.onap.aai.schemaservice.nodeschema.SchemaVersion; +import org.onap.aai.schemaservice.nodeschema.SchemaVersions; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.assertEquals; + +class DefaultVersionValidationModuleTest { + + @Mock + private ConfigTranslator configTranslator; + + @Mock + private SchemaVersions schemaVersions; + + @InjectMocks + private DefaultVersionValidationModule validationModule; + + @BeforeEach + void setUp() { + MockitoAnnotations.openMocks(this); + } + + @Test + void testValidate_AllSchemasPresent() { + SchemaVersion version1 = new SchemaVersion("v1"); + SchemaVersion version2 = new SchemaVersion("v2"); + + Map<SchemaVersion, List<String>> nodeFiles = new HashMap<>(); + nodeFiles.put(version1, Arrays.asList("nodeFile1")); + nodeFiles.put(version2, Arrays.asList("nodeFile2")); + + Map<SchemaVersion, List<String>> edgeFiles = new HashMap<>(); + edgeFiles.put(version1, Arrays.asList("edgeFile1")); + edgeFiles.put(version2, Arrays.asList("edgeFile2")); + + when(configTranslator.getNodeFiles()).thenReturn(nodeFiles); + when(configTranslator.getEdgeFiles()).thenReturn(edgeFiles); + when(configTranslator.getSchemaVersions()).thenReturn(schemaVersions); + when(schemaVersions.getVersions()).thenReturn(Arrays.asList(version1, version2)); + + String result = validationModule.validate(); + + assertEquals("", result, "There should be no missing schemas."); + } + + @Test + void testValidate_NodeSchemaMissing() { + SchemaVersion version1 = new SchemaVersion("v1"); + SchemaVersion version2 = new SchemaVersion("v2"); + + Map<SchemaVersion, List<String>> nodeFiles = new HashMap<>(); + nodeFiles.put(version1, Arrays.asList("nodeFile1")); + nodeFiles.put(version2, null); + + Map<SchemaVersion, List<String>> edgeFiles = new HashMap<>(); + edgeFiles.put(version1, Arrays.asList("edgeFile1")); + edgeFiles.put(version2, Arrays.asList("edgeFile2")); + + when(configTranslator.getNodeFiles()).thenReturn(nodeFiles); + when(configTranslator.getEdgeFiles()).thenReturn(edgeFiles); + when(configTranslator.getSchemaVersions()).thenReturn(schemaVersions); + when(schemaVersions.getVersions()).thenReturn(Arrays.asList(version1, version2)); + + String result = validationModule.validate(); + + assertEquals("Missing schema for the following versions: v2 has no OXM configured. ", result); + } + + @Test + void testValidate_EdgeSchemaMissing() { + SchemaVersion version1 = new SchemaVersion("v1"); + SchemaVersion version2 = new SchemaVersion("v2"); + + Map<SchemaVersion, List<String>> nodeFiles = new HashMap<>(); + nodeFiles.put(version1, Arrays.asList("nodeFile1")); + nodeFiles.put(version2, Arrays.asList("nodeFile2")); + + Map<SchemaVersion, List<String>> edgeFiles = new HashMap<>(); + edgeFiles.put(version1, Arrays.asList("edgeFile1")); + edgeFiles.put(version2, null); + + when(configTranslator.getNodeFiles()).thenReturn(nodeFiles); + when(configTranslator.getEdgeFiles()).thenReturn(edgeFiles); + when(configTranslator.getSchemaVersions()).thenReturn(schemaVersions); + when(schemaVersions.getVersions()).thenReturn(Arrays.asList(version1, version2)); + + String result = validationModule.validate(); + + assertEquals("Missing schema for the following versions: v2 has no edge rules configured. ", result); + } + + @Test + void testValidate_BothNodeAndEdgeSchemasMissing() { + SchemaVersion version1 = new SchemaVersion("v1"); + SchemaVersion version2 = new SchemaVersion("v2"); + + Map<SchemaVersion, List<String>> nodeFiles = new HashMap<>(); + nodeFiles.put(version1, Arrays.asList("nodeFile1")); + nodeFiles.put(version2, null); + + Map<SchemaVersion, List<String>> edgeFiles = new HashMap<>(); + edgeFiles.put(version1, Arrays.asList("edgeFile1")); + edgeFiles.put(version2, null); + + when(configTranslator.getNodeFiles()).thenReturn(nodeFiles); + when(configTranslator.getEdgeFiles()).thenReturn(edgeFiles); + when(configTranslator.getSchemaVersions()).thenReturn(schemaVersions); + when(schemaVersions.getVersions()).thenReturn(Arrays.asList(version1, version2)); + + String result = validationModule.validate(); + + assertEquals("Missing schema for the following versions: v2 has no OXM configured. v2 has no edge rules configured. ", result); + } +} |