</properties>
<dependencies>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.junit.jupiter</groupId>
+ <artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
package org.onap.aai.annotations;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+
public class AnnotationsTest {
public AnnotationsTest() {
}
+ @Test
@Metadata(
isKey = false,
description = "",
maximumDepth = "",
crossEntityReference = "")
public void testAnnotation() {
+ assertTrue(true);
}
}
<version>2.7.14</version>
</dependency>
<dependency>
- <groupId>org.springframework.kafka</groupId>
- <artifactId>spring-kafka-test</artifactId>
- <scope>test</scope>
- </dependency>
+ <groupId>org.springframework.kafka</groupId>
+ <artifactId>spring-kafka-test</artifactId>
+ <scope>test</scope>
+ </dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.aspectj</groupId>
- <artifactId>aspectjrt</artifactId>
- <version>1.9.1</version>
</dependency>
</dependencies>
</project>
Please don't upgrade to 2.3.0 or above for nexus iq or security scans
as it could potentially break our code
-->
- <spring.boot.version>2.5.15</spring.boot.version>
- <spring.version>5.3.39</spring.version>
- <spring.test.version>${spring.version}</spring.test.version>
+ <spring.boot.version>2.6.15</spring.boot.version>
<json.path.version>2.2.0</json.path.version>
<json.version>20190722</json.version>
<junit.version>4.12</junit.version>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-framework-bom</artifactId>
- <version>${spring.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
</dependency>
<dependency>
- <groupId>io.swagger</groupId>
+ <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-core</artifactId>
- <version>${io.swagger.version}</version>
+ <version>2.2.25</version>
</dependency>
<dependency>
</dependency>
<dependency>
- <groupId>io.swagger</groupId>
+ <groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-annotations</artifactId>
- <version>${io.swagger.version}</version>
+ <version>2.2.25</version>
</dependency>
<dependency>
package org.onap.aai.restclient;
-public class RestClientTest {
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import org.junit.jupiter.api.Test;
+public class RestClientTest {
+ @Test
+ public void test() {
+ assertTrue(true);
+ }
}
<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>
<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>
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;
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;
JsonSchemaProviderConfig config = new JsonSchemaProviderConfig();
- @Before
+ @BeforeEach
public void init() {
config.setSchemaServiceBaseUrl("https://testurl.com:8443");
config.setSchemaServiceCertFile("/c/certfile");
}
}
- @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 {
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
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;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.setup.Translator;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class OxmSchemaServiceSetup {
@Mock
private OxmEdgeRulesLoader edgeLoader;
private OxmSchemaLoader vertexLoader;
- @Before
+ @BeforeEach
public void schemaBeanMockSetup() throws Exception {
schemaVersionList.add(new SchemaVersion("v13"));
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <!-- TODO: Migrate tests to junit 5 and remove this dependency -->
- <dependency>
- <groupId>org.junit.vintage</groupId>
- <artifactId>junit-vintage-engine</artifactId>
- <scope>test</scope>
- <exclusions>
- <exclusion>
- <groupId>org.hamcrest</groupId>
- <artifactId>hamcrest-core</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
+ <dependency>
+ <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>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
import org.onap.aai.setup.Translator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
private Set<Translator> translators;
- @Autowired
public EdgeIngestor(Set<Translator> translatorSet) {
this.translators = translatorSet;
}
import org.onap.aai.setup.Translator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.w3c.dom.Document;
* @param translatorSet
*/
- @Autowired
public NodeIngestor(Set<Translator> translatorSet) {
this.translators = translatorSet;
this.caseFormatStore = new CaseFormatStore();
import org.onap.aai.edges.JsonIngestor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
/**
* Converts the contents of the schema config file
protected SchemaLocationsBean schemaLocationsBean;
- @Autowired
public ConfigTranslator(SchemaLocationsBean schemaLocationsBean, SchemaConfigVersions schemaConfigVersions) {
super(schemaConfigVersions);
this.schemaLocationsBean = schemaLocationsBean;
import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
private ConfigTranslator config;
- @Autowired
public DefaultVersionValidationModule(ConfigTranslator config) {
this.config = config;
package org.onap.aai.validation;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
private SchemaErrorStrategy strat;
private VersionValidationModule verMod;
- @Autowired
public VersionValidator(SchemaErrorStrategy strategy, VersionValidationModule verMod) {
this.strat = strategy;
this.verMod = verMod;
import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.validation.SchemaErrorStrategy;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
protected final CousinDefaultingValidationModule defaultsValidator;
protected final NodeTypesValidationModule typeValidator;
- @Autowired
public EdgeRuleValidator(ConfigTranslator config, SchemaErrorStrategy strat,
EdgeFieldsValidationModule fieldValidator, UniqueLabelValidationModule labelValidator,
SingleContainmentValidationModule containsValidator, CousinDefaultingValidationModule defaultsValidator,
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaVersion;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
public class NodeTypesValidationModule {
private NodeIngestor ni;
- @Autowired
public NodeTypesValidationModule(NodeIngestor ni) {
this.ni = ni;
}
import org.onap.aai.setup.ConfigTranslator;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.validation.SchemaErrorStrategy;
-import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;
private SchemaErrorStrategy strat;
private DuplicateNodeDefinitionValidationModule dupChecker;
- @Autowired
public NodeValidator(ConfigTranslator translator, SchemaErrorStrategy strategy,
DuplicateNodeDefinitionValidationModule dupChecker) {
this.translator = translator;
package org.onap.aai.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.google.common.collect.Multimap;
import java.util.Collection;
import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.EdgesConfiguration;
import org.onap.aai.edges.enums.AAIDirection;
import org.onap.aai.edges.enums.MultiplicityRule;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {EdgesConfiguration.class, TestUtilConfigTranslator.class})
@TestPropertySource(
properties = {
@Autowired
EdgeIngestor edgeIngestor;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void getRulesTest1() throws EdgeRuleNotFoundException {
EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
}
@Test
- public void getRulesNoneFound() throws EdgeRuleNotFoundException {
- thrown.expect(EdgeRuleNotFoundException.class);
- thrown.expectMessage("No rules found for");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").build();
- edgeIngestor.getRules(q);
+ public void getRulesNoneFound() {
+ Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface").build();
+ edgeIngestor.getRules(q);
+ });
+ assertTrue(exception.getMessage().contains("No rules found for"));
}
@Test
// }
@Test
- public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- thrown.expect(EdgeRuleNotFoundException.class);
- thrown.expectMessage("No rule found for");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
- edgeIngestor.getRule(q);
+ public void getRuleNoneFoundTest() {
+ Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
+ edgeIngestor.getRule(q);
+ });
+ assertTrue(exception.getMessage().contains("No rule found for"));
}
// @Test
// }
@Test
- public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- thrown.expect(AmbiguousRuleChoiceException.class);
- thrown.expectMessage("Multiple defaults found.");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
- edgeIngestor.getRule(q);
+ public void getRuleAmbiguousDefaultTest() {
+ Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
+ edgeIngestor.getRule(q);
+ });
+ assertTrue(exception.getMessage().contains("Multiple defaults found."));
}
@Test
- public void getRuleNoDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- thrown.expect(AmbiguousRuleChoiceException.class);
- thrown.expectMessage("No default found.");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
- edgeIngestor.getRule(q);
+ public void getRuleNoDefaultTest() {
+ Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
+ edgeIngestor.getRule(q);
+ });
+ assertTrue(exception.getMessage().contains("No default found."));
}
// @Test
// }
@Test
- public void getAllRulesTest() throws EdgeRuleNotFoundException {
- Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
- assertTrue(res.size() == 4);
- assertTrue(res.containsKey("bar|foo"));
- assertTrue(res.get("bar|foo").size() == 2);
- assertTrue(res.containsKey("baz|foo"));
- assertTrue(res.containsKey("foo|quux"));
-
- thrown.expect(EdgeRuleNotFoundException.class);
- thrown.expectMessage("No rules found for version v9.");
- edgeIngestor.getAllRules(new SchemaVersion("v9"));
+ public void getAllRulesTest() {
+ Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+ Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
+ assertTrue(res.size() == 4);
+ assertTrue(res.containsKey("bar|foo"));
+ assertTrue(res.get("bar|foo").size() == 2);
+ assertTrue(res.containsKey("baz|foo"));
+ assertTrue(res.containsKey("foo|quux"));
+ edgeIngestor.getAllRules(new SchemaVersion("v9"));
+ });
+ assertTrue(exception.getMessage().contains("No rules found for version v9."));
}
}
package org.onap.aai.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.google.common.collect.Multimap;
import java.util.Collection;
import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.EdgesConfiguration;
import org.onap.aai.edges.enums.AAIDirection;
import org.onap.aai.edges.enums.MultiplicityRule;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {MockProvider.class, EdgesConfiguration.class})
@TestPropertySource(
properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test.properties",
@Autowired
EdgeIngestor edgeIngestor;
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void getRulesTest1() throws EdgeRuleNotFoundException {
EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
}
@Test
- public void getRulesNoneFound() throws EdgeRuleNotFoundException {
- thrown.expect(EdgeRuleNotFoundException.class);
- thrown.expectMessage("No rules found for");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("bogus-value").build();
- edgeIngestor.getRules(q);
+ public void getRulesNoneFound() {
+ Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("bogus-value").build();
+ edgeIngestor.getRules(q);
+ });
+ assertTrue(exception.getMessage().contains("No rules found for"));
}
@Test
}
@Test
- public void getRuleNoneFoundTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- thrown.expect(EdgeRuleNotFoundException.class);
- thrown.expectMessage("No rule found for");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
- edgeIngestor.getRule(q);
+ public void getRuleNoneFoundTest() {
+ Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("l-interface", "nonexistent").build();
+ edgeIngestor.getRule(q);
+ });
+ assertTrue(exception.getMessage().contains("No rule found for"));
}
@Test
- public void getRuleTooManyPairsTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- thrown.expect(AmbiguousRuleChoiceException.class);
- thrown.expectMessage("No way to select single rule from these pairs:");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
- edgeIngestor.getRule(q);
+ public void getRuleTooManyPairsTest() {
+ Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("foo").build();
+ edgeIngestor.getRule(q);
+ });
+ assertTrue(exception.getMessage().contains("No way to select single rule from these pairs:"));
}
@Test
- public void getRuleAmbiguousDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- thrown.expect(AmbiguousRuleChoiceException.class);
- thrown.expectMessage("Multiple defaults found.");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
- edgeIngestor.getRule(q);
+ public void getRuleAmbiguousDefaultTest() {
+ Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("seed", "plant").version(new SchemaVersion("v11")).build();
+ edgeIngestor.getRule(q);
+ });
+ assertTrue(exception.getMessage().contains("Multiple defaults found."));
}
@Test
- public void getRuleNoDefaultTest() throws EdgeRuleNotFoundException, AmbiguousRuleChoiceException {
- thrown.expect(AmbiguousRuleChoiceException.class);
- thrown.expectMessage("No default found.");
- EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
- edgeIngestor.getRule(q);
+ public void getRuleNoDefaultTest() {
+ Throwable exception = assertThrows(AmbiguousRuleChoiceException.class, () -> {
+ EdgeRuleQuery q = new EdgeRuleQuery.Builder("apple", "orange").version(new SchemaVersion("v11")).build();
+ edgeIngestor.getRule(q);
+ });
+ assertTrue(exception.getMessage().contains("No default found."));
}
@Test
}
@Test
- public void getAllRulesTest() throws EdgeRuleNotFoundException {
- Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
- assertTrue(res.size() == 4);
- assertTrue(res.containsKey("bar|foo"));
- assertTrue(res.get("bar|foo").size() == 2);
- assertTrue(res.containsKey("baz|foo"));
- assertTrue(res.containsKey("foo|quux"));
-
- thrown.expect(EdgeRuleNotFoundException.class);
- thrown.expectMessage("No rules found for version v9.");
- edgeIngestor.getAllRules(new SchemaVersion("v9"));
+ public void getAllRulesTest() {
+ Throwable exception = assertThrows(EdgeRuleNotFoundException.class, () -> {
+ Multimap<String, EdgeRule> res = edgeIngestor.getAllRules(new SchemaVersion("v10"));
+ assertTrue(res.size() == 4);
+ assertTrue(res.containsKey("bar|foo"));
+ assertTrue(res.get("bar|foo").size() == 2);
+ assertTrue(res.containsKey("baz|foo"));
+ assertTrue(res.containsKey("foo|quux"));
+ edgeIngestor.getAllRules(new SchemaVersion("v9"));
+ });
+ assertTrue(exception.getMessage().contains("No rules found for version v9."));
}
}
package org.onap.aai.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.google.common.collect.Multimap;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.EdgesConfiguration;
import org.onap.aai.edges.exceptions.EdgeRuleNotFoundException;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {EdgesConfiguration.class, ConfigTranslatorForWiringTest.class})
@TestPropertySource(
properties = {
package org.onap.aai.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import java.util.List;
import java.util.Scanner;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.onap.aai.edges.enums.EdgeType;
public class EdgeRuleQueryTest {
private String readStart = "$.rules.[?]";
/* **** DATA SETUP **** */
- @Before
+ @BeforeEach
public void setup() {
InputStream is = getClass().getResourceAsStream("/edgeRules/test.json");
package org.onap.aai.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
import org.apache.tinkerpop.gremlin.structure.Direction;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class EdgeRuleTest {
import static com.jayway.jsonpath.Criteria.where;
import static com.jayway.jsonpath.Filter.filter;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.Filter;
+import org.junit.jupiter.api.Test;
import java.util.*;
-import org.junit.Test;
import org.onap.aai.setup.SchemaVersion;
public class JsonIngestorTest {
package org.onap.aai.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class TypeAlphabetizerTest {
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.TestUtilConfigTranslator;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringRunner;
import org.w3c.dom.Document;
-@RunWith(SpringRunner.class)
@TestPropertySource(
properties = {
"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local-node.properties"})
@SpringBootTest
public class NodeIngestorLocalTest {
-
- // set thrown.expect to whatever a specific test needs
- // this establishes a default of expecting no exceptions to be thrown
- @Rule
- public ExpectedException thrown = ExpectedException.none();
@Autowired
NodeIngestor nodeIngestor;
@Test
public void testGetContextForVersion11() {
- DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
-
- // should work bc Foo is valid in test_network_v10 schema
- DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
-
- foo10.set("fooId", "bar");
- assertEquals("bar", foo10.get("fooId"));
-
- // should work bc Bar is valid in test_business_v10 schema
- DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
- bar10.set("barId", "bar2");
- assertEquals("bar2", bar10.get("barId"));
- XSDOutputResolver outputResolver10 = new XSDOutputResolver();
- ctx10.generateSchema(outputResolver10);
-
- DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
-
- // should work bc Foo.quantity is valid in test_network_v11 schema
- DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
- foo11.set("quantity", "12");
- assertEquals("12", foo11.get("quantity"));
-
- DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
- quux11.set("qManagerName", "some guy");
- assertEquals("some guy", quux11.get("qManagerName"));
- XSDOutputResolver outputResolver11 = new XSDOutputResolver();
- ctx11.generateSchema(outputResolver11);
-
- thrown.expect(IllegalArgumentException.class);
- // should fail bc Quux not in v10 test schema
- ctx10.newDynamicEntity("Quux");
+ assertThrows(IllegalArgumentException.class, () -> {
+ DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
+
+ // should work bc Foo is valid in test_network_v10 schema
+ DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
+
+ foo10.set("fooId", "bar");
+ assertEquals("bar", foo10.get("fooId"));
+
+ // should work bc Bar is valid in test_business_v10 schema
+ DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
+ bar10.set("barId", "bar2");
+ assertEquals("bar2", bar10.get("barId"));
+ XSDOutputResolver outputResolver10 = new XSDOutputResolver();
+ ctx10.generateSchema(outputResolver10);
+
+ DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
+
+ // should work bc Foo.quantity is valid in test_network_v11 schema
+ DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
+ foo11.set("quantity", "12");
+ assertEquals("12", foo11.get("quantity"));
+
+ DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
+ quux11.set("qManagerName", "some guy");
+ assertEquals("some guy", quux11.get("qManagerName"));
+ XSDOutputResolver outputResolver11 = new XSDOutputResolver();
+ ctx11.generateSchema(outputResolver11);
+ // should fail bc Quux not in v10 test schema
+ ctx10.newDynamicEntity("Quux");
+ });
}
@Test
import static java.nio.charset.StandardCharsets.UTF_8;
import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.jupiter.api.Assertions.*;
import java.io.ByteArrayOutputStream;
import java.io.File;
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.restclient.MockProvider;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Document;
-@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(
properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties",
"spring.main.allow-bean-definition-overriding=true"})
@Autowired
NodeIngestor nodeIngestor;
- // set thrown.expect to whatever a specific test needs
- // this establishes a default of expecting no exceptions to be thrown
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void testGetContextForVersion() {
- DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
-
- // should work bc Foo is valid in test_network_v10 schema
- DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
-
- foo10.set("fooId", "bar");
- assertEquals("bar", foo10.get("fooId"));
-
- // should work bc Bar is valid in test_business_v10 schema
- DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
- bar10.set("barId", "bar2");
- assertEquals("bar2", bar10.get("barId"));
- XSDOutputResolver outputResolver10 = new XSDOutputResolver();
- ctx10.generateSchema(outputResolver10);
-
- DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
-
- // should work bc Foo.quantity is valid in test_network_v11 schema
- DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
- foo11.set("quantity", "12");
- assertEquals("12", foo11.get("quantity"));
-
- DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
- quux11.set("qManagerName", "some guy");
- assertEquals("some guy", quux11.get("qManagerName"));
- XSDOutputResolver outputResolver11 = new XSDOutputResolver();
- ctx11.generateSchema(outputResolver11);
-
- thrown.expect(IllegalArgumentException.class);
- // should fail bc Quux not in v10 test schema
- ctx10.newDynamicEntity("Quux");
+ assertThrows(IllegalArgumentException.class, () -> {
+ DynamicJAXBContext ctx10 = nodeIngestor.getContextForVersion(new SchemaVersion("v10"));
+
+ // should work bc Foo is valid in test_network_v10 schema
+ DynamicEntity foo10 = ctx10.newDynamicEntity("Foo");
+
+ foo10.set("fooId", "bar");
+ assertEquals("bar", foo10.get("fooId"));
+
+ // should work bc Bar is valid in test_business_v10 schema
+ DynamicEntity bar10 = ctx10.newDynamicEntity("Bar");
+ bar10.set("barId", "bar2");
+ assertEquals("bar2", bar10.get("barId"));
+ XSDOutputResolver outputResolver10 = new XSDOutputResolver();
+ ctx10.generateSchema(outputResolver10);
+
+ DynamicJAXBContext ctx11 = nodeIngestor.getContextForVersion(new SchemaVersion("v11"));
+
+ // should work bc Foo.quantity is valid in test_network_v11 schema
+ DynamicEntity foo11 = ctx11.newDynamicEntity("Foo");
+ foo11.set("quantity", "12");
+ assertEquals("12", foo11.get("quantity"));
+
+ DynamicEntity quux11 = ctx11.newDynamicEntity("Quux");
+ quux11.set("qManagerName", "some guy");
+ assertEquals("some guy", quux11.get("qManagerName"));
+ XSDOutputResolver outputResolver11 = new XSDOutputResolver();
+ ctx11.generateSchema(outputResolver11);
+ // should fail bc Quux not in v10 test schema
+ ctx10.newDynamicEntity("Quux");
+ });
}
@Test
package org.onap.aai.nodes;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import org.eclipse.persistence.dynamic.DynamicEntity;
import org.eclipse.persistence.jaxb.dynamic.DynamicJAXBContext;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {ConfigTranslatorForWiringTest.class, NodesConfiguration.class})
@TestPropertySource(
properties = {
package org.onap.aai.restclient;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.content;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
String result = IOUtils.toString(inputStream, StandardCharsets.UTF_8);
String message = String.format("Unable to find the %s in src/test/resources", filename);
- assertNotNull(message, inputStream);
+ assertNotNull(inputStream, message);
JsonObject payload = JsonParser.parseString(result).getAsJsonObject();
return payload;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@Ignore
-@RunWith(SpringJUnit4ClassRunner.class)
+@Disabled
@TestPropertySource(locations = "/schemaService/schema-service-rest.properties")
@ContextConfiguration(
classes = {RestClientFactoryConfiguration.class, SchemaServiceRestClient.class, RestClientFactory.class,
package org.onap.aai.setup;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.List;
import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.testutils.ConfigTranslatorForWiringTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {SchemaLocationsBean.class, SchemaConfigVersions.class, ConfigTranslatorForWiringTest.class})
@TestPropertySource(
package org.onap.aai.setup;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {SchemaLocationsBean.class})
+@SpringJUnitConfig(classes = {SchemaLocationsBean.class})
public class SchemaLocationsBeanDefaultInjectionTest {
@Autowired
SchemaLocationsBean bean;
package org.onap.aai.setup;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(classes = {SchemaLocationsBean.class})
+@SpringJUnitConfig(classes = {SchemaLocationsBean.class})
@TestPropertySource(properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest2.properties"})
public class SchemaLocationsBeanEnvVarInjectionTest {
@Autowired
package org.onap.aai.setup;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:forWiringTests/testContext.xml"})
+@SpringJUnitConfig(locations = {"classpath:forWiringTests/testContext.xml"})
public class SchemaLocationsBeanXMLSetterTest {
@Autowired
SchemaLocationsBean bean;
package org.onap.aai.setup;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
-@Ignore("Support of schema ingest via context configuration with prop file is removed as it won't work with spring boot 2")
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:forWiringTests/testUsingPropFileContext.xml"})
+@Disabled("Support of schema ingest via context configuration with prop file is removed as it won't work with spring boot 2")
+@SpringJUnitConfig(locations = {"classpath:forWiringTests/testUsingPropFileContext.xml"})
public class SchemaLocationsBeanXMLSetterWithPropFileTest {
@Autowired
SchemaLocationsBean bean;
package org.onap.aai.setup;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.restclient.MockProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(
properties = {
"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-override-test.properties"})
@ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class, SchemaConfigVersions.class})
@SpringBootTest
public class SchemaVersionsBeanOverrideTest {
-
- // set thrown.expect to whatever a specific test needs
- // this establishes a default of expecting no exceptions to be thrown
- @Rule
- public ExpectedException thrown = ExpectedException.none();
@Autowired
SchemaVersionsBean SchemaVersionsBean;
package org.onap.aai.setup;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.io.IOException;
import java.util.List;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.restclient.MockProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@TestPropertySource(
properties = {"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-ss-wiring-test.properties"})
@ContextConfiguration(classes = {MockProvider.class, SchemaVersionsBean.class})
@SpringBootTest
public class SchemaVersionsBeanTest {
-
- // set thrown.expect to whatever a specific test needs
- // this establishes a default of expecting no exceptions to be thrown
- @Rule
- public ExpectedException thrown = ExpectedException.none();
@Autowired
SchemaVersionsBean SchemaVersionsBean;
package org.onap.aai.validation;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
public class CheckEverythingStrategyTest {
-/**
+/**
* ============LICENSE_START=======================================================
* org.onap.aai
* ================================================================================
package org.onap.aai.validation;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
public class FailFastStrategyTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
@Test
public void test() {
- FailFastStrategy strat = new FailFastStrategy();
+ String testError = "hi i'm a problem";
+ Throwable exception = assertThrows(AAISchemaValidationException.class, () -> {
+ FailFastStrategy strat = new FailFastStrategy();
- // simulate no issues found
- assertTrue(strat.isOK());
- assertTrue("No errors found.".equals(strat.getErrorMsg()));
+ // simulate no issues found
+ assertTrue(strat.isOK());
+ assertTrue("No errors found.".equals(strat.getErrorMsg()));
- // simulate an issue found
- String testError = "hi i'm a problem";
- thrown.expect(AAISchemaValidationException.class);
- thrown.expectMessage(testError);
- strat.notifyOnError(testError);
+ // simulate an issue found
+ strat.notifyOnError(testError);
+ });
+ assertTrue(exception.getMessage().contains(testError));
}
}
package org.onap.aai.validation;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.BadNodeConfigForValidationTest;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {NodesConfiguration.class, BadNodeConfigForValidationTest.class, CheckEverythingStrategy.class,
DefaultVersionValidationModule.class, VersionValidator.class})
package org.onap.aai.validation;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
DefaultVersionValidationModule.class, VersionValidator.class})
package org.onap.aai.validation.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.jayway.jsonpath.DocumentContext;
import java.util.List;
import java.util.Map;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.setup.SchemaVersion;
private static List<DocumentContext> ctxs;
private static CousinDefaultingValidationModule validator;
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
Map<SchemaVersion, List<String>> testRules = new HashMap<>();
List<String> testFiles = new ArrayList<>();
package org.onap.aai.validation.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.HashMap;
import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.edges.enums.EdgeField;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {DefaultEdgeFieldsValidationModule.class})
@SpringBootTest
public class DefaultEdgeFieldsValidationModuleTest {
package org.onap.aai.validation.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.testutils.BadEdgeConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {NodesConfiguration.class, BadEdgeConfigForValidationTest.class, CheckEverythingStrategy.class,
DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
package org.onap.aai.validation.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
DefaultEdgeFieldsValidationModule.class, UniqueLabelValidationModule.class,
package org.onap.aai.validation.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import java.util.ArrayList;
import java.util.List;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.setup.SchemaVersion;
import org.onap.aai.testutils.TestUtilConfigTranslator;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {NodesConfiguration.class, TestUtilConfigTranslator.class, NodeTypesValidationModule.class})
@TestPropertySource(
package org.onap.aai.validation.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.jayway.jsonpath.DocumentContext;
import java.util.*;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.setup.SchemaVersion;
private static SingleContainmentValidationModule validator;
public static final SchemaVersion LATEST = new SchemaVersion("v14");
- @BeforeClass
+ @BeforeAll
public static void setUpBeforeClass() {
Map<SchemaVersion, List<String>> testRules = new TreeMap<>();
List<String> testFiles = new ArrayList<>();
package org.onap.aai.validation.edges;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
import com.jayway.jsonpath.DocumentContext;
import java.util.*;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.onap.aai.edges.JsonIngestor;
import org.onap.aai.setup.SchemaVersion;
private static UniqueLabelValidationModule validator;
public static final SchemaVersion LATEST = new SchemaVersion("v14");
- @BeforeClass
+ @BeforeAll
public static void setup() {
Map<SchemaVersion, List<String>> testRules = new TreeMap<>();
List<String> testFiles = new ArrayList<>();
package org.onap.aai.validation.nodes;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.testutils.BadNodeConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {BadNodeConfigForValidationTest.class, NodesConfiguration.class, CheckEverythingStrategy.class,
DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
package org.onap.aai.validation.nodes;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.junit.Ignore;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Disabled;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.nodes.NodeIngestor;
import org.onap.aai.setup.SchemaVersion;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.w3c.dom.Document;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = {SchemaIncompleteTranslator.class, NodesConfiguration.class})
@TestPropertySource(
properties = {
"schema.ingest.file = src/test/resources/forWiringTests/schema-ingest-wiring-test-local.properties"})
@SpringBootTest
-@Ignore
+@Disabled
public class NodeValidatorSchemaIncompleteTest {
@Autowired
NodeIngestor ni;
- // set thrown.expect to whatever a specific test needs
- // this establishes a default of expecting no exceptions to be thrown
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
// Throws a NullPointerException because a JavaType is referenced, but not defined
@Test
- public void testIncompleteCombinedSchema() throws TransformerException, IOException, IllegalStateException {
- thrown.expect(NullPointerException.class);
+ public void testIncompleteCombinedSchema() {
+ assertThrows(NullPointerException.class, () -> {
- // TODO Change for Exception
- ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- printDocument(ni.getSchema(new SchemaVersion("v12")), buffer);
+ // TODO Change for Exception
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ printDocument(ni.getSchema(new SchemaVersion("v12")), buffer);
+ });
}
public static void printDocument(Document doc, OutputStream out) throws IOException, TransformerException {
package org.onap.aai.validation.nodes;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
import org.onap.aai.config.NodesConfiguration;
import org.onap.aai.testutils.GoodConfigForValidationTest;
import org.onap.aai.validation.CheckEverythingStrategy;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(
classes = {NodesConfiguration.class, GoodConfigForValidationTest.class, CheckEverythingStrategy.class,
DefaultDuplicateNodeDefinitionValidationModule.class, NodeValidator.class})
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
+ <dependency>
+ <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>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
package org.onap.aaiutils.oxm;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
import java.util.regex.Pattern;
-import org.junit.Assert;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class OxmModelLoaderTest {
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
@Test
public void shouldLoadOxmModelsWhichMatchToPattern() throws Exception {
OxmModelLoader.loadModels("classpath*:test_aai_oxm*.xml", Pattern.compile("test_aai_oxm_(.*).xml"));
- Assert.assertTrue(OxmModelLoader.getVersionContextMap().size() == 2);
- Assert.assertFalse(OxmModelLoader.getVersionContextMap().containsKey("v7"));
- Assert.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v8"));
- Assert.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v9"));
+ Assertions.assertTrue(OxmModelLoader.getVersionContextMap().size() == 2);
+ Assertions.assertFalse(OxmModelLoader.getVersionContextMap().containsKey("v7"));
+ Assertions.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v8"));
+ Assertions.assertTrue(OxmModelLoader.getVersionContextMap().containsKey("v9"));
}
@Test
- public void shouldReportAnErrorWhenOxmModelsAreNotAvailable() throws Exception {
- thrown.expect(Exception.class);
- thrown.expectMessage("Failed to load schema");
+ public void shouldReportAnErrorWhenOxmModelsAreNotAvailable() {
+ Throwable exception = assertThrows(Exception.class, () ->
- OxmModelLoader.loadModels("classpath*:non_existing_aai_oxm*.xml",
- Pattern.compile("non_existing_aai_oxm_(.*).xml"));
+ OxmModelLoader.loadModels("classpath*:non_existing_aai_oxm*.xml",
+ Pattern.compile("non_existing_aai_oxm_(.*).xml")));
+ assertTrue(exception.getMessage().contains("Failed to load schema"));
}
}