diff options
Diffstat (limited to 'aai-schema-abstraction')
4 files changed, 91 insertions, 71 deletions
diff --git a/aai-schema-abstraction/pom.xml b/aai-schema-abstraction/pom.xml index 140db51c..8384809c 100644 --- a/aai-schema-abstraction/pom.xml +++ b/aai-schema-abstraction/pom.xml @@ -94,8 +94,19 @@ <artifactId>rest-client</artifactId> </dependency> <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> + <groupId>org.hamcrest</groupId> + <artifactId>hamcrest-junit</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>org.junit.jupiter</groupId> + <artifactId>junit-jupiter</artifactId> <scope>test</scope> </dependency> <dependency> @@ -103,6 +114,12 @@ <artifactId>mockito-core</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.mockito</groupId> + <artifactId>mockito-junit-jupiter</artifactId> + <version>5.14.2</version> + <scope>test</scope> + </dependency> </dependencies> <build> <plugins> diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java index a4c7546d..3fb98718 100644 --- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java +++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/json/JsonSchemaProviderTest.java @@ -21,12 +21,7 @@ package org.onap.aai.schemaif.json; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import static org.junit.jupiter.api.Assertions.*; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -39,8 +34,8 @@ import java.util.Set; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import org.junit.Before; -import org.junit.Test; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.onap.aai.schemaif.SchemaProviderException; import org.onap.aai.schemaif.definitions.EdgeSchema; import org.onap.aai.schemaif.definitions.PropertySchema; @@ -59,7 +54,7 @@ public class JsonSchemaProviderTest { JsonSchemaProviderConfig config = new JsonSchemaProviderConfig(); - @Before + @BeforeEach public void init() { config.setSchemaServiceBaseUrl("https://testurl.com:8443"); config.setSchemaServiceCertFile("/c/certfile"); @@ -528,66 +523,74 @@ public class JsonSchemaProviderTest { } } - @Test(expected = SchemaProviderException.class) - public void testSchemaValidateBadEdge() throws SchemaProviderException { - SchemaServiceResponse schema; - - try { - String testSchema = readFile("src/test/resources/json/badEdgeSchema.json"); - schema = SchemaServiceResponse.fromJson(testSchema); - } catch (Exception ex) { - fail(); - return; - } + @Test + public void testSchemaValidateBadEdge() { + assertThrows(SchemaProviderException.class, () -> { + SchemaServiceResponse schema; + + try { + String testSchema = readFile("src/test/resources/json/badEdgeSchema.json"); + schema = SchemaServiceResponse.fromJson(testSchema); + } catch (Exception ex) { + fail(); + return; + } - schema.getData().validate(); + schema.getData().validate(); + }); } - @Test(expected = SchemaProviderException.class) - public void testSchemaValidateBadVertex() throws SchemaProviderException { - SchemaServiceResponse schema; - - try { - String testSchema = readFile("src/test/resources/json/badVertexSchema.json"); - schema = SchemaServiceResponse.fromJson(testSchema); - } catch (Exception ex) { - fail(); - return; - } + @Test + public void testSchemaValidateBadVertex() { + assertThrows(SchemaProviderException.class, () -> { + SchemaServiceResponse schema; + + try { + String testSchema = readFile("src/test/resources/json/badVertexSchema.json"); + schema = SchemaServiceResponse.fromJson(testSchema); + } catch (Exception ex) { + fail(); + return; + } - System.out.println("Validate"); - schema.getData().validate(); - System.out.println("Validate done"); + System.out.println("Validate"); + schema.getData().validate(); + System.out.println("Validate done"); + }); } - @Test(expected = SchemaProviderException.class) - public void testSchemaValidateBadType() throws SchemaProviderException { - SchemaServiceResponse schema; - - try { - String testSchema = readFile("src/test/resources/json/badTypeSchema.json"); - schema = SchemaServiceResponse.fromJson(testSchema); - } catch (Exception ex) { - fail(); - return; - } + @Test + public void testSchemaValidateBadType() { + assertThrows(SchemaProviderException.class, () -> { + SchemaServiceResponse schema; + + try { + String testSchema = readFile("src/test/resources/json/badTypeSchema.json"); + schema = SchemaServiceResponse.fromJson(testSchema); + } catch (Exception ex) { + fail(); + return; + } - schema.getData().validate(); + schema.getData().validate(); + }); } - @Test(expected = SchemaProviderException.class) - public void testSchemaValidateBadProp() throws SchemaProviderException { - SchemaServiceResponse schema; - - try { - String testSchema = readFile("src/test/resources/json/badPropSchema.json"); - schema = SchemaServiceResponse.fromJson(testSchema); - } catch (Exception ex) { - fail(); - return; - } + @Test + public void testSchemaValidateBadProp() { + assertThrows(SchemaProviderException.class, () -> { + SchemaServiceResponse schema; + + try { + String testSchema = readFile("src/test/resources/json/badPropSchema.json"); + schema = SchemaServiceResponse.fromJson(testSchema); + } catch (Exception ex) { + fail(); + return; + } - schema.getData().validate(); + schema.getData().validate(); + }); } static String readFile(String path) throws IOException { diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java index 222be0e9..8d6a744b 100644 --- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java +++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaProviderTest.java @@ -21,22 +21,22 @@ package org.onap.aai.schemaif.oxm; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.PrintWriter; import java.io.StringWriter; import java.util.Set; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.junit.MockitoJUnitRunner; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.aai.schemaif.SchemaProviderException; import org.onap.aai.schemaif.definitions.EdgeSchema; import org.onap.aai.schemaif.definitions.PropertySchema; import org.onap.aai.schemaif.definitions.VertexSchema; import org.onap.aai.schemaif.definitions.types.DataType.Type; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class OxmSchemaProviderTest extends OxmSchemaServiceSetup { @Test diff --git a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java index 08cf880e..701d4e15 100644 --- a/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java +++ b/aai-schema-abstraction/src/test/java/org/onap/aai/schemaif/oxm/OxmSchemaServiceSetup.java @@ -27,11 +27,11 @@ import java.util.HashSet; import java.util.List; import java.util.Set; -import org.junit.Before; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import org.onap.aai.edges.EdgeIngestor; import org.onap.aai.nodes.NodeIngestor; import org.onap.aai.setup.AAIConfigTranslator; @@ -40,7 +40,7 @@ import org.onap.aai.setup.SchemaLocationsBean; import org.onap.aai.setup.SchemaVersion; import org.onap.aai.setup.Translator; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class OxmSchemaServiceSetup { @Mock @@ -56,7 +56,7 @@ public class OxmSchemaServiceSetup { private OxmEdgeRulesLoader edgeLoader; private OxmSchemaLoader vertexLoader; - @Before + @BeforeEach public void schemaBeanMockSetup() throws Exception { schemaVersionList.add(new SchemaVersion("v13")); |