summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/aai/babel/TestApplication.java4
-rw-r--r--src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java4
-rw-r--r--src/test/java/org/onap/aai/babel/TestMicroServiceAuth.java15
-rw-r--r--src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java2
-rw-r--r--src/test/java/org/onap/aai/babel/logging/TestApplicationLogger.java12
-rw-r--r--src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java2
-rw-r--r--src/test/java/org/onap/aai/babel/service/TestCsarToXmlConverter.java4
-rw-r--r--src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java1
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/TestModelGenerator.java2
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java2
-rw-r--r--src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java6
11 files changed, 29 insertions, 25 deletions
diff --git a/src/test/java/org/onap/aai/babel/TestApplication.java b/src/test/java/org/onap/aai/babel/TestApplication.java
index bb43b40..200b0e2 100644
--- a/src/test/java/org/onap/aai/babel/TestApplication.java
+++ b/src/test/java/org/onap/aai/babel/TestApplication.java
@@ -47,14 +47,14 @@ public class TestApplication {
System.setProperty("server.ssl.key-store", "src/test/resources/auth/keystore.jks");
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testApplicationStarts() {
System.setProperty("KEY_STORE_PASSWORD", "password");
BabelApplication.main(new String[] {});
BabelApplication.exit();
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testApplicationStartsWithObfuscatedPassword() {
System.setProperty("KEY_STORE_PASSWORD", Password.obfuscate("password"));
BabelApplication.main(new String[] {});
diff --git a/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java b/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java
index 4efb03e..15278e5 100644
--- a/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java
+++ b/src/test/java/org/onap/aai/babel/TestAuthFileWatcher.java
@@ -50,12 +50,12 @@ public class TestAuthFileWatcher {
task = new AuthFileWatcher(mockFile);
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testOnChangeDoesNotRun() {
task.run();
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testOnChangeDoesRun() throws IOException, AAIAuthException {
System.setProperty("CONFIG_HOME", "src/test/resources");
BabelAuthConfig babelServiceAuthConfig = new BabelAuthConfig();
diff --git a/src/test/java/org/onap/aai/babel/TestMicroServiceAuth.java b/src/test/java/org/onap/aai/babel/TestMicroServiceAuth.java
index 431d01f..7375d29 100644
--- a/src/test/java/org/onap/aai/babel/TestMicroServiceAuth.java
+++ b/src/test/java/org/onap/aai/babel/TestMicroServiceAuth.java
@@ -23,6 +23,7 @@ package org.onap.aai.babel;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
+import static org.junit.Assert.assertTrue;
import java.io.File;
import java.io.FileWriter;
@@ -31,6 +32,7 @@ import java.util.concurrent.TimeUnit;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.onap.aai.auth.AAIAuthException;
@@ -117,12 +119,17 @@ public class TestMicroServiceAuth {
* @throws IOException
* for I/O failures, e.g. when creating the temporary auth policy file
*/
- @Test(expected = AAIAuthException.class)
+ @Test
public void testReloadDeletedFile() throws AAIAuthException, JSONException, IOException {
File file = createTestPolicyFile();
AAIMicroServiceAuthCore.init(file.getAbsolutePath());
assertThat(file.delete(), is(true));
- AAIMicroServiceAuthCore.reloadUsers();
+ try {
+ AAIMicroServiceAuthCore.reloadUsers();
+ Assert.fail("Expected an AAIAuthException to be thrown");
+ } catch (AAIAuthException e) {
+ assertTrue(true);
+ }
}
/**
@@ -172,7 +179,7 @@ public class TestMicroServiceAuth {
* @throws InterruptedException
* if interrupted while sleeping
*/
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void createLocalAuthFileOnChange()
throws JSONException, AAIAuthException, IOException, InterruptedException {
File file = createTestPolicyFile();
@@ -212,7 +219,7 @@ public class TestMicroServiceAuth {
* @throws AAIAuthException
* if the Auth Policy cannot be loaded
*/
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void createAuthFromDefaultFileAppHome() throws AAIAuthException {
System.clearProperty("CONFIG_HOME");
System.setProperty("APP_HOME", "src/test/resources");
diff --git a/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java b/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java
index 20c3434..8e9fb3d 100644
--- a/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java
+++ b/src/test/java/org/onap/aai/babel/csar/extractor/YamlExtractorTest.java
@@ -107,7 +107,7 @@ public class YamlExtractorTest {
}
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testArchiveContainsOnlyTheExpectedYmlFilesFromSdWanService()
throws IOException, InvalidArchiveException {
final List<Artifact> ymlFiles = CsarTest.SD_WAN_CSAR_FILE.extractArtifacts();
diff --git a/src/test/java/org/onap/aai/babel/logging/TestApplicationLogger.java b/src/test/java/org/onap/aai/babel/logging/TestApplicationLogger.java
index 9b4375d..127b77d 100644
--- a/src/test/java/org/onap/aai/babel/logging/TestApplicationLogger.java
+++ b/src/test/java/org/onap/aai/babel/logging/TestApplicationLogger.java
@@ -120,7 +120,7 @@ public class TestApplicationLogger {
/**
* Call logAuditError() for code coverage stats.
*/
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void logAuditError() {
LogHelper.INSTANCE.logAuditError(new Exception("test"));
EELFManager.getInstance().getAuditLogger().setLevel(Level.OFF);
@@ -198,7 +198,7 @@ public class TestApplicationLogger {
assertThat("audit message content", str, containsString("foo"));
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void setDefaultContextValue() {
LogHelper logger = LogHelper.INSTANCE;
logger.setDefaultContextValue("key", "value");
@@ -271,12 +271,8 @@ public class TestApplicationLogger {
*/
private void callUnsupportedOperationMethod(TriConsumer<Enum<?>, LogFields, String[]> logMethod,
ApplicationMsgs dummyMsg) {
- try {
- logMethod.accept(dummyMsg, new LogFields(), new String[] {""});
- org.junit.Assert.fail("method should have thrown execption"); // NOSONAR as code not reached
- } catch (UnsupportedOperationException e) {
- // Expected to reach here
- }
+ logMethod.accept(dummyMsg, new LogFields(), new String[] {""});
+ org.junit.Assert.fail("method should have thrown execption"); // NOSONAR as code not reached
}
/**
diff --git a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
index 65ec4c3..3fac6cb 100644
--- a/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
+++ b/src/test/java/org/onap/aai/babel/parser/TestArtifactGeneratorToscaParser.java
@@ -171,7 +171,7 @@ public class TestArtifactGeneratorToscaParser {
* @throws XmlArtifactGenerationException
* if there is no configuration defined for the test resource's widget type
*/
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testAddWidgetToService() throws IOException, XmlArtifactGenerationException {
ArtifactTestUtils testUtils = new ArtifactTestUtils();
testUtils.loadWidgetMappings();
diff --git a/src/test/java/org/onap/aai/babel/service/TestCsarToXmlConverter.java b/src/test/java/org/onap/aai/babel/service/TestCsarToXmlConverter.java
index ef3fb28..19eeb22 100644
--- a/src/test/java/org/onap/aai/babel/service/TestCsarToXmlConverter.java
+++ b/src/test/java/org/onap/aai/babel/service/TestCsarToXmlConverter.java
@@ -120,9 +120,9 @@ public class TestCsarToXmlConverter {
SERVICE_VERSION);
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testServiceMetadataMissing()
- throws IOException, XmlArtifactGenerationException, CsarConverterException {
+ throws IOException, CsarConverterException {
converter.generateXmlFromCsar(CsarTest.MISSING_METADATA_CSAR.getContent(),
CsarTest.MISSING_METADATA_CSAR.getName(), SERVICE_VERSION);
}
diff --git a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
index 66db20a..a76b296 100644
--- a/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
+++ b/src/test/java/org/onap/aai/babel/service/TestGenerateArtifactsServiceImpl.java
@@ -44,6 +44,7 @@ import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
import org.mockito.Mockito;
import org.onap.aai.auth.AAIAuthException;
import org.onap.aai.auth.AAIMicroServiceAuth;
diff --git a/src/test/java/org/onap/aai/babel/xml/generator/TestModelGenerator.java b/src/test/java/org/onap/aai/babel/xml/generator/TestModelGenerator.java
index 168f237..43f49a0 100644
--- a/src/test/java/org/onap/aai/babel/xml/generator/TestModelGenerator.java
+++ b/src/test/java/org/onap/aai/babel/xml/generator/TestModelGenerator.java
@@ -48,7 +48,7 @@ public class TestModelGenerator {
new ArtifactTestUtils().setGeneratorSystemProperties();
}
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testDefaultServiceVersion() throws XmlArtifactGenerationException, IOException {
Artifact ymlFile = new Artifact(null, null, null, null);
new ModelGenerator().generateArtifacts(CsarTest.SD_WAN_CSAR_FILE.getContent(),
diff --git a/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java b/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
index 9fc5928..700cf38 100644
--- a/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
+++ b/src/test/java/org/onap/aai/babel/xml/generator/model/TestModel.java
@@ -74,7 +74,7 @@ public class TestModel {
/**
* Test that there is no exception if processing a Model that has no metadata properties.
*/
- @Test
+ @Test(expected = Test.None.class /* no exception expected */)
public void testNullIdentProperties() {
createTestModel().populateModelIdentificationInformation(null);
}
diff --git a/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java b/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java
index ebefa9f..35319d6 100644
--- a/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java
+++ b/src/test/java/org/onap/aai/babel/xml/generator/model/TestWidget.java
@@ -190,19 +190,19 @@ public class TestWidget {
@Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
public void testGetModelNameVersionIdIsUnsupported() throws XmlArtifactGenerationException {
Widget widgetModel = Widget.createWidget("OAM_NETWORK");
- assertThat(widgetModel.getModelNameVersionId(), is(nullValue()));
+ widgetModel.getModelNameVersionId();
}
@Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
public void testGetModelTypeNameIsUnsupported() throws XmlArtifactGenerationException {
Widget widgetModel = Widget.createWidget("OAM_NETWORK");
- assertThat(widgetModel.getModelTypeName(), is(nullValue()));
+ widgetModel.getModelTypeName();
}
@Test(expected = org.onap.aai.babel.xml.generator.error.IllegalAccessException.class)
public void testGetModelIdIsUnsupported() throws XmlArtifactGenerationException {
Widget widgetModel = Widget.createWidget("OAM_NETWORK");
- assertThat(widgetModel.getModelId(), is(nullValue()));
+ widgetModel.getModelId();
}
}