summaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorJakub Zieba <jakub.zieba@nokia.com>2018-09-04 07:23:41 +0200
committerJakub Zieba <jakub.zieba@nokia.com>2018-09-04 12:25:51 +0200
commit4026d98bc9802e41146ff6ef727d349c7ac1e89e (patch)
treec0294dbab65bb12928ccf0d399904ea4cb5c84af /src/test
parentc84e8030f5f53c2f38b11428a545cd6992a6ba02 (diff)
Add protocols to hosts
Add default protocols for Consul hosts Add controller for healt check Fix for merging properties from file and Consul Change-Id: Ifa8c7cdfa333d8ffee175b5eb4446f0c3a986f27 Issue-ID: DCAEGEN2-747 Signed-off-by: Jakub Zieba <jakub.zieba@nokia.com>
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/org/onap/dcae/ApplicationSettingsTest.java69
-rw-r--r--src/test/java/org/onap/dcae/TestingUtilities.java15
-rw-r--r--src/test/java/org/onap/dcae/WiremockBasedTest.java16
-rw-r--r--src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java27
-rw-r--r--src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java17
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java24
-rw-r--r--src/test/java/org/onap/dcae/vestest/TestVESLogger.java75
7 files changed, 120 insertions, 123 deletions
diff --git a/src/test/java/org/onap/dcae/ApplicationSettingsTest.java b/src/test/java/org/onap/dcae/ApplicationSettingsTest.java
index 26b0a68b..67b9cb64 100644
--- a/src/test/java/org/onap/dcae/ApplicationSettingsTest.java
+++ b/src/test/java/org/onap/dcae/ApplicationSettingsTest.java
@@ -23,11 +23,9 @@ package org.onap.dcae;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.fge.jsonschema.core.exceptions.ProcessingException;
-import com.github.fge.jsonschema.core.report.ProcessingReport;
import com.github.fge.jsonschema.main.JsonSchema;
import io.vavr.collection.HashMap;
import io.vavr.collection.Map;
-import org.json.JSONObject;
import org.junit.Test;
import java.io.File;
@@ -62,7 +60,7 @@ public class ApplicationSettingsTest {
@Test
public void shouldMakeApplicationSettingsOutOfCLIArgumentsAndAConfigurationFile()
- throws IOException {
+ throws IOException {
// given
File tempConfFile = File.createTempFile("doesNotMatter", "doesNotMatter");
Files.write(tempConfFile.toPath(), Arrays.asList("section.subSection1=abc", "section.subSection2=zxc"));
@@ -103,7 +101,7 @@ public class ApplicationSettingsTest {
public void shouldReturnHTTPPort() throws IOException {
// when
int applicationPort = fromTemporaryConfiguration("collector.service.port=8090")
- .httpPort();
+ .httpPort();
// then
assertEquals(8090, applicationPort);
@@ -122,7 +120,7 @@ public class ApplicationSettingsTest {
public void shouldReturnIfHTTPSIsEnabled() throws IOException {
// when
boolean httpsEnabled = fromTemporaryConfiguration("collector.service.secure.port=8443")
- .httpsEnabled();
+ .httpsEnabled();
// then
assertTrue(httpsEnabled);
@@ -149,7 +147,7 @@ public class ApplicationSettingsTest {
public void shouldReturnHTTPSPort() throws IOException {
// when
int httpsPort = fromTemporaryConfiguration("collector.service.secure.port=8443")
- .httpsPort();
+ .httpsPort();
// then
assertEquals(8443, httpsPort);
@@ -159,7 +157,7 @@ public class ApplicationSettingsTest {
public void shouldReturnConfigurationUpdateInterval() throws IOException {
// when
int updateFrequency = fromTemporaryConfiguration("collector.dynamic.config.update.frequency=10")
- .configurationUpdateFrequency();
+ .configurationUpdateFrequency();
// then
assertEquals(10, updateFrequency);
@@ -169,7 +167,7 @@ public class ApplicationSettingsTest {
public void shouldReturnDefaultConfigurationUpdateInterval() throws IOException {
// when
int updateFrequency = fromTemporaryConfiguration()
- .configurationUpdateFrequency();
+ .configurationUpdateFrequency();
// then
assertEquals(5, updateFrequency);
@@ -178,7 +176,8 @@ public class ApplicationSettingsTest {
@Test
public void shouldReturnLocationOfThePasswordFile() throws IOException {
// when
- String passwordFileLocation = fromTemporaryConfiguration("collector.keystore.passwordfile=/somewhere/password").keystorePasswordFileLocation();
+ String passwordFileLocation = fromTemporaryConfiguration("collector.keystore.passwordfile=/somewhere/password")
+ .keystorePasswordFileLocation();
// then
assertEquals(sanitizePath("/somewhere/password"), passwordFileLocation);
@@ -197,7 +196,7 @@ public class ApplicationSettingsTest {
public void shouldReturnLocationOfTheKeystoreFile() throws IOException {
// when
String keystoreFileLocation = fromTemporaryConfiguration("collector.keystore.file.location=/somewhere/keystore")
- .keystoreFileLocation();
+ .keystoreFileLocation();
// then
assertEquals(sanitizePath("/somewhere/keystore"), keystoreFileLocation);
@@ -234,7 +233,8 @@ public class ApplicationSettingsTest {
@Test
public void shouldReturnDMAAPConfigFileLocation() throws IOException {
// when
- String dmaapConfigFileLocation = fromTemporaryConfiguration("collector.dmaapfile=/somewhere/dmaapFile").dMaaPConfigurationFileLocation();
+ String dmaapConfigFileLocation = fromTemporaryConfiguration("collector.dmaapfile=/somewhere/dmaapFile")
+ .dMaaPConfigurationFileLocation();
// then
assertEquals(sanitizePath("/somewhere/dmaapFile"), dmaapConfigFileLocation);
@@ -253,7 +253,7 @@ public class ApplicationSettingsTest {
public void shouldReturnMaximumAllowedQueuedEvents() throws IOException {
// when
int maximumAllowedQueuedEvents = fromTemporaryConfiguration("collector.inputQueue.maxPending=10000")
- .maximumAllowedQueuedEvents();
+ .maximumAllowedQueuedEvents();
// then
assertEquals(10000, maximumAllowedQueuedEvents);
@@ -272,7 +272,7 @@ public class ApplicationSettingsTest {
public void shouldTellIfSchemaValidationIsEnabled() throws IOException {
// when
boolean jsonSchemaValidationEnabled = fromTemporaryConfiguration("collector.schema.checkflag=1")
- .jsonSchemaValidationEnabled();
+ .jsonSchemaValidationEnabled();
// then
assertTrue(jsonSchemaValidationEnabled);
@@ -291,16 +291,17 @@ public class ApplicationSettingsTest {
public void shouldReturnJSONSchema() throws IOException, ProcessingException {
// when
String sampleJsonSchema = "{" +
- " \"type\": \"object\"," +
- " \"properties\": {" +
- " \"state\": { \"type\": \"string\" }" +
- " }" +
- "}";
+ " \"type\": \"object\"," +
+ " \"properties\": {" +
+ " \"state\": { \"type\": \"string\" }" +
+ " }" +
+ "}";
Path temporarySchemaFile = createTemporaryFile(sampleJsonSchema);
// when
- JsonSchema schema = fromTemporaryConfiguration(String.format("collector.schema.file={\"v1\": \"%s\"}", temporarySchemaFile))
- .jsonSchema("v1");
+ JsonSchema schema = fromTemporaryConfiguration(
+ String.format("collector.schema.file={\"v1\": \"%s\"}", temporarySchemaFile))
+ .jsonSchema("v1");
// then
JsonNode incorrectTestObject = new ObjectMapper().readTree("{ \"state\": 1 }");
@@ -313,7 +314,7 @@ public class ApplicationSettingsTest {
public void shouldReturnExceptionConfigFileLocation() throws IOException {
// when
String exceptionConfigFileLocation = fromTemporaryConfiguration("exceptionConfig=/somewhere/exceptionFile")
- .exceptionConfigFileLocation();
+ .exceptionConfigFileLocation();
// then
assertEquals("/somewhere/exceptionFile", exceptionConfigFileLocation);
@@ -333,13 +334,14 @@ public class ApplicationSettingsTest {
public void shouldReturnDMAAPStreamId() throws IOException {
// given
Map<String, String[]> expected = HashMap.of(
- "s", new String[]{"something", "something2"},
- "s2", new String[]{"something3"}
+ "s", new String[]{"something", "something2"},
+ "s2", new String[]{"something3"}
);
// when
- Map<String, String[]> dmaapStreamID = fromTemporaryConfiguration("collector.dmaap.streamid=s=something,something2|s2=something3")
- .dMaaPStreamsMapping();
+ Map<String, String[]> dmaapStreamID = fromTemporaryConfiguration(
+ "collector.dmaap.streamid=s=something,something2|s2=something3")
+ .dMaaPStreamsMapping();
// then
assertArrayEquals(expected.get("s").get(), Objects.requireNonNull(dmaapStreamID).get("s").get());
@@ -360,7 +362,7 @@ public class ApplicationSettingsTest {
public void shouldReturnIfAuthorizationIsEnabled() throws IOException {
// when
boolean authorizationEnabled = fromTemporaryConfiguration("header.authflag=1")
- .authorizationEnabled();
+ .authorizationEnabled();
// then
assertTrue(authorizationEnabled);
@@ -379,7 +381,7 @@ public class ApplicationSettingsTest {
public void shouldReturnValidCredentials() throws IOException {
// when
Map<String, String> allowedUsers = fromTemporaryConfiguration(
- "header.authlist=pasza,c2ltcGxlcGFzc3dvcmQNCg==|someoneelse,c2ltcGxlcGFzc3dvcmQNCg=="
+ "header.authlist=pasza,c2ltcGxlcGFzc3dvcmQNCg==|someoneelse,c2ltcGxlcGFzc3dvcmQNCg=="
).validAuthorizationCredentials();
// then
@@ -391,7 +393,7 @@ public class ApplicationSettingsTest {
public void shouldbyDefaultThereShouldBeNoValidCredentials() throws IOException {
// when
Map<String, String> userToBase64PasswordDelimitedByCommaSeparatedByPipes = fromTemporaryConfiguration().
- validAuthorizationCredentials();
+ validAuthorizationCredentials();
// then
assertTrue(userToBase64PasswordDelimitedByCommaSeparatedByPipes.isEmpty());
@@ -401,7 +403,7 @@ public class ApplicationSettingsTest {
public void shouldReturnIfEventTransformingIsEnabled() throws IOException {
// when
boolean isEventTransformingEnabled = fromTemporaryConfiguration("event.transform.flag=0")
- .eventTransformingEnabled();
+ .eventTransformingEnabled();
// then
assertFalse(isEventTransformingEnabled);
@@ -419,8 +421,9 @@ public class ApplicationSettingsTest {
@Test
public void shouldReturnCambriaConfigurationFileLocation() throws IOException {
// when
- String cambriaConfigurationFileLocation = fromTemporaryConfiguration("collector.dmaapfile=/somewhere/dmaapConfig")
- .dMaaPConfigurationFileLocation();
+ String cambriaConfigurationFileLocation = fromTemporaryConfiguration(
+ "collector.dmaapfile=/somewhere/dmaapConfig")
+ .dMaaPConfigurationFileLocation();
// then
assertEquals(sanitizePath("/somewhere/dmaapConfig"), cambriaConfigurationFileLocation);
@@ -430,14 +433,14 @@ public class ApplicationSettingsTest {
public void shouldReturnDefaultCambriaConfigurationFileLocation() throws IOException {
// when
String cambriaConfigurationFileLocation = fromTemporaryConfiguration()
- .dMaaPConfigurationFileLocation();
+ .dMaaPConfigurationFileLocation();
// then
assertEquals(sanitizePath("etc/DmaapConfig.json"), cambriaConfigurationFileLocation);
}
private static ApplicationSettings fromTemporaryConfiguration(String... fileLines)
- throws IOException {
+ throws IOException {
File tempConfFile = File.createTempFile("doesNotMatter", "doesNotMatter");
Files.write(tempConfFile.toPath(), Arrays.asList(fileLines));
tempConfFile.deleteOnExit();
diff --git a/src/test/java/org/onap/dcae/TestingUtilities.java b/src/test/java/org/onap/dcae/TestingUtilities.java
index 092983bf..21edfc88 100644
--- a/src/test/java/org/onap/dcae/TestingUtilities.java
+++ b/src/test/java/org/onap/dcae/TestingUtilities.java
@@ -19,19 +19,18 @@
*/
package org.onap.dcae;
-import static java.nio.file.Files.readAllBytes;
-import static org.assertj.core.api.Assertions.assertThat;
-
-import com.google.gson.JsonObject;
-import com.google.gson.JsonParser;
import io.vavr.control.Try;
+import org.assertj.core.api.AbstractThrowableAssert;
+import org.assertj.core.api.Java6Assertions;
+import org.json.JSONObject;
+
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import org.assertj.core.api.AbstractThrowableAssert;
-import org.assertj.core.api.Java6Assertions;
-import org.json.JSONObject;
+
+import static java.nio.file.Files.readAllBytes;
+import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Pawel Szalapski (pawel.szalapski@nokia.com)
diff --git a/src/test/java/org/onap/dcae/WiremockBasedTest.java b/src/test/java/org/onap/dcae/WiremockBasedTest.java
index ae851259..58626340 100644
--- a/src/test/java/org/onap/dcae/WiremockBasedTest.java
+++ b/src/test/java/org/onap/dcae/WiremockBasedTest.java
@@ -17,19 +17,17 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-package org.onap.dcae;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
-import static io.vavr.API.Map;
+package org.onap.dcae;
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import io.vavr.collection.Map;
import org.junit.Rule;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig;
+import static io.vavr.API.Map;
+
/**
* @author Pawel Szalapski (pawel.szalapski@nokia.com)
*/
@@ -51,7 +49,7 @@ public class WiremockBasedTest {
protected Map<String, String> wiremockBasedEnvProps() {
return Map(
- "CONSUL_HOST", "http://localhost",
+ "CONSUL_HOST", "localhost",
"CONSUL_PORT", "" + wireMockRule.port(),
"HOSTNAME", "VESCollector",
"CONFIG_BINDING_SERVICE", "CBSName"
@@ -61,7 +59,7 @@ public class WiremockBasedTest {
protected String validLocalCBSConf() {
return ""
+ "[{ "
- + "\"ServiceAddress\": \"http://localhost\","
+ + "\"ServiceAddress\": \"localhost\","
+ "\"ServicePort\":" + wireMockRule.port()
+ "}]";
}
diff --git a/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java b/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java
index 97dccb5b..3e358466 100644
--- a/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java
+++ b/src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java
@@ -40,15 +40,23 @@ import static org.onap.dcae.commonFunction.EventProcessor.EVENT_LIST_TYPE;
public class EventProcessorTest {
- private final String ev = "{\"event\": {\"commonEventHeader\": { \"reportingEntityName\": \"VM name will be provided by ECOMP\", \"startEpochMicrosec\": 1477012779802988,\"lastEpochMicrosec\": 1477012789802988,\"eventId\": \"83\",\"sourceName\": \"Dummy VM name - No Metadata available\",\"sequence\": 83,\"priority\": \"Normal\",\"functionalRole\": \"vFirewall\",\"domain\": \"measurementsForVfScaling\",\"reportingEntityId\": \"VM UUID will be provided by ECOMP\",\"sourceId\": \"Dummy VM UUID - No Metadata available\",\"version\": 1.1},\"measurementsForVfScalingFields\": {\"measurementInterval\": 10,\"measurementsForVfScalingVersion\": 1.1,\"vNicUsageArray\": [{\"multicastPacketsIn\": 0,\"bytesIn\": 3896,\"unicastPacketsIn\": 0, \"multicastPacketsOut\": 0,\"broadcastPacketsOut\": 0, \"packetsOut\": 28,\"bytesOut\": 12178,\"broadcastPacketsIn\": 0,\"packetsIn\": 58,\"unicastPacketsOut\": 0,\"vNicIdentifier\": \"eth0\"}]}}}";
+ private final String ev = "{\"event\": {\"commonEventHeader\": { \"reportingEntityName\": "
+ + "\"VM name will be provided by ECOMP\", \"startEpochMicrosec\": 1477012779802988,\"lastEpochMicrosec\": "
+ + "1477012789802988,\"eventId\": \"83\",\"sourceName\": \"Dummy VM name - No Metadata available\","
+ + "\"sequence\": 83,\"priority\": \"Normal\",\"functionalRole\": \"vFirewall\",\"domain\": "
+ + "\"measurementsForVfScaling\",\"reportingEntityId\": \"VM UUID will be provided by ECOMP\","
+ + "\"sourceId\": \"Dummy VM UUID - No Metadata available\",\"version\": 1.1},\"measurementsForVfScalingFields\":"
+ + " {\"measurementInterval\": 10,\"measurementsForVfScalingVersion\": 1.1,\"vNicUsageArray\": "
+ + "[{\"multicastPacketsIn\": 0,\"bytesIn\": 3896,\"unicastPacketsIn\": 0, "
+ + "\"multicastPacketsOut\": 0,\"broadcastPacketsOut\": 0, "
+ + "\"packetsOut\": 28,\"bytesOut\": 12178,\"broadcastPacketsIn\": "
+ + "0,\"packetsIn\": 58,\"unicastPacketsOut\": 0,\"vNicIdentifier\": \"eth0\"}]}}}";
- private Map<String, String[]> streamID;
private ApplicationSettings properties;
@Before
public void setUp() {
properties = new ApplicationSettings(new String[]{}, CLIUtils::processCmdLine);
- streamID = properties.dMaaPStreamsMapping();
}
@Test
@@ -68,10 +76,15 @@ public class EventProcessorTest {
public void shouldParseJsonEvents() throws ReflectiveOperationException {
//given
EventProcessor eventProcessor = new EventProcessor(mock(EventPublisher.class), properties);
- String event_json = "[{ \"filter\": {\"event.commonEventHeader.domain\":\"heartbeat\",\"VESversion\":\"v4\"},\"processors\":[" +
- "{\"functionName\": \"concatenateValue\",\"args\":{\"field\":\"event.commonEventHeader.eventName\",\"concatenate\": [\"$event.commonEventHeader.domain\",\"$event.commonEventHeader.eventType\",\"$event.faultFields.alarmCondition\"], \"delimiter\":\"_\"}}" +
- ",{\"functionName\": \"addAttribute\",\"args\":{\"field\": \"event.heartbeatFields.heartbeatFieldsVersion\",\"value\": \"1.0\",\"fieldType\": \"number\"}}" +
- ",{\"functionName\": \"map\",\"args\":{\"field\": \"event.commonEventHeader.nfNamingCode\",\"oldField\": \"event.commonEventHeader.functionalRole\"}}]}]";
+ String event_json =
+ "[{ \"filter\": {\"event.commonEventHeader.domain\":\"heartbeat\",\"VESversion\":\"v4\"},\"processors\":["
+ + "{\"functionName\": \"concatenateValue\",\"args\":{\"field\":\"event.commonEventHeader.eventName\","
+ + "\"concatenate\": [\"$event.commonEventHeader.domain\",\"$event.commonEventHeader.eventType\","
+ + "\"$event.faultFields.alarmCondition\"], \"delimiter\":\"_\"}}"
+ + ",{\"functionName\": \"addAttribute\",\"args\":{\"field\": "
+ + "\"event.heartbeatFields.heartbeatFieldsVersion\",\"value\": \"1.0\",\"fieldType\": \"number\"}}"
+ + ",{\"functionName\": \"map\",\"args\":{\"field\": \"event.commonEventHeader.nfNamingCode\","
+ + "\"oldField\": \"event.commonEventHeader.functionalRole\"}}]}]";
List<Event> events = new Gson().fromJson(event_json, EVENT_LIST_TYPE);
EventProcessor.ConfigProcessorAdapter configProcessorAdapter = mock(EventProcessor.ConfigProcessorAdapter.class);
diff --git a/src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java b/src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java
index 336788a9..bee2ccee 100644
--- a/src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java
+++ b/src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java
@@ -20,19 +20,16 @@
*/
package org.onap.dcae.controller;
-import static com.github.tomakehurst.wiremock.client.WireMock.aResponse;
-import static com.github.tomakehurst.wiremock.client.WireMock.get;
-import static com.github.tomakehurst.wiremock.client.WireMock.stubFor;
-import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
-import static org.assertj.core.api.Java6Assertions.assertThat;
-import static org.onap.dcae.TestingUtilities.assertFailureHasInfo;
-import static org.onap.dcae.controller.ConfigSource.getAppConfig;
-
import io.vavr.control.Try;
import org.json.JSONObject;
import org.junit.Test;
import org.onap.dcae.WiremockBasedTest;
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+import static org.assertj.core.api.Java6Assertions.assertThat;
+import static org.onap.dcae.TestingUtilities.assertFailureHasInfo;
+import static org.onap.dcae.controller.ConfigSource.getAppConfig;
+
public class ConfigCBSSourceTest extends WiremockBasedTest {
@Test
@@ -82,7 +79,7 @@ public class ConfigCBSSourceTest extends WiremockBasedTest {
// given
String notAListCatalog = ""
+ "{"
- + "\"ServiceAddress\":\"http://localhost\","
+ + "\"ServiceAddress\":\"localhost\","
+ "\"ServicePort\":" + wireMockRule.port()
+ "}";
@@ -145,7 +142,7 @@ public class ConfigCBSSourceTest extends WiremockBasedTest {
}
private Try<JSONObject> tryToGetConfig() {
- return getAppConfig(new EnvProps("http://localhost", wireMockRule.port(), "CBSName", "VESCollector"));
+ return getAppConfig(new EnvProps("http", "localhost", wireMockRule.port(), "http", "CBSName", "VESCollector"));
}
}
diff --git a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java
index 310e8be3..eaf59410 100644
--- a/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java
+++ b/src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java
@@ -22,11 +22,11 @@ package org.onap.dcae.vestest;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
+import com.google.gson.JsonParser;
+import com.google.gson.JsonObject;
import java.io.FileReader;
import java.io.IOException;
import org.json.JSONObject;
-import com.google.gson.JsonParser;
-import com.google.gson.JsonObject;
import org.junit.Test;
import org.onap.dcae.commonFunction.ConfigProcessors;
@@ -87,7 +87,8 @@ public class TestConfigProcessor {
System.out.println("event==" + jsonObject.toString());
System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": \"event.faultFields.alarmAdditionalInformation\"}");
+ "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": "
+ + "\"event.faultFields.alarmAdditionalInformation\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.map(jsonArgs);
final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventAdditionalInformation")
@@ -101,11 +102,10 @@ public class TestConfigProcessor {
public void testJSONObjectMapToArray() {
final JSONObject jsonObject = getFileAsJsonObject();
- //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
System.out.println("event==" + jsonObject.toString());
- //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
final JSONObject jsonArgs = new JSONObject(
- "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": \"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}");
+ "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": "
+ + "\"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.errors.receiveDiscards").toString();
System.out.println("receiveDiscards==" + receiveDiscards);
@@ -122,9 +122,7 @@ public class TestConfigProcessor {
public void testMapRenameObject() {
final JSONObject jsonObject = getFileAsJsonObject();
- //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
System.out.println("event==" + jsonObject.toString());
- //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
final JSONObject jsonArgs = new JSONObject(
"{\"field\": \"event.faultFields.faultVFScalingFields\",\"oldField\": \"event.faultFields.errors\",\"mapType\":\"renameObject\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
@@ -142,9 +140,7 @@ public class TestConfigProcessor {
public void testMapHashmapToNameValueArray() {
final JSONObject jsonObject = getFileAsJsonObject();
- //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
System.out.println("event==" + jsonObject.toString());
- //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
final JSONObject jsonArgs = new JSONObject(
"{\"field\": \"event.faultFields.errors\",\"mapType\":\"hashmapToNameValueArray\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
@@ -163,9 +159,7 @@ public class TestConfigProcessor {
public void testMapNameValueArrayToHashmap() {
final JSONObject jsonObject = getFileAsJsonObject();
- //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();
System.out.println("event==" + jsonObject.toString());
- //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);
final JSONObject jsonArgs = new JSONObject(
"{\"field\": \"event.faultFields.alarmAdditionalInformation\",\"mapType\":\"nameValueArrayToHashmap\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
@@ -184,9 +178,7 @@ public class TestConfigProcessor {
public void testAttrAdd() {
final JSONObject jsonObject = getFileAsJsonObject();
- //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();
System.out.println("event==" + jsonObject.toString());
- //System.out.println("functionRole==" + functionRole);
final JSONObject jsonArgs = new JSONObject(
"{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
@@ -201,9 +193,7 @@ public class TestConfigProcessor {
public void testAttrUpdate() {
final JSONObject jsonObject = getFileAsJsonObject();
- //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();
System.out.println("event==" + jsonObject.toString());
- //System.out.println("functionRole==" + functionRole);
final JSONObject jsonArgs = new JSONObject(
"{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
@@ -280,7 +270,6 @@ public class TestConfigProcessor {
final JSONObject jsonObject = getFileAsJsonObject();
System.out.println("event==" + jsonObject.toString());
System.out.println("Testing SetEventObjectVal");
- //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}" );
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.setEventObjectVal("event.faultFields.version", "2.0", "number");
final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();
@@ -310,7 +299,6 @@ public class TestConfigProcessor {
final JSONObject jsonObject = getFileAsJsonObject();
System.out.println("event==" + jsonObject.toString());
System.out.println("Testing GetEventObjectVal");
- //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.eventSeverity\"}" );
ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);
cpEvent.getEventObjectVal("event.faultFields.eventSeverity");
final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventSeverity").toString();
diff --git a/src/test/java/org/onap/dcae/vestest/TestVESLogger.java b/src/test/java/org/onap/dcae/vestest/TestVESLogger.java
index 484f7dc8..848f2b76 100644
--- a/src/test/java/org/onap/dcae/vestest/TestVESLogger.java
+++ b/src/test/java/org/onap/dcae/vestest/TestVESLogger.java
@@ -19,57 +19,56 @@
*/
package org.onap.dcae.vestest;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNotSame;
-import static org.onap.dcae.commonFunction.VESLogger.REQUEST_ID;
-
import com.att.nsa.logging.LoggingContext;
import com.att.nsa.logging.log4j.EcompFields;
-import java.util.UUID;
import org.junit.Test;
import org.onap.dcae.commonFunction.VESLogger;
+import java.util.UUID;
+
+import static org.junit.Assert.*;
+import static org.onap.dcae.commonFunction.VESLogger.REQUEST_ID;
+
public class TestVESLogger {
- @Test
- public void shouldOnLoggingContextInitializationPutRandomUUIDAsRequestID() {
- LoggingContext commonLoggingContext = VESLogger.getCommonLoggingContext();
- String requestId = commonLoggingContext.get(REQUEST_ID, "default");
+ @Test
+ public void shouldOnLoggingContextInitializationPutRandomUuidAsRequestId() {
+ LoggingContext commonLoggingContext = VESLogger.getCommonLoggingContext();
+ String requestId = commonLoggingContext.get(REQUEST_ID, "default");
- assertNotNull(requestId);
- assertNotSame(requestId, "default");
+ assertNotNull(requestId);
+ assertNotSame(requestId, "default");
- }
+ }
- @Test
- public void shouldOnLoggingContextInitializationPutGivenUUIDAsRequestIDAndSupplyEndTimestamp() {
- final UUID uuid = UUID.randomUUID();
- LoggingContext loggingContextForThread = VESLogger.getLoggingContextForThread(uuid);
- String requestId = loggingContextForThread.get(REQUEST_ID, "default");
- String endTimestamp = loggingContextForThread.get(EcompFields.kEndTimestamp, "default");
+ @Test
+ public void shouldOnLoggingContextInitializationPutGivenUuuidAsRequestIdAndSupplyEndTimestamp() {
+ final UUID uuid = UUID.randomUUID();
+ LoggingContext loggingContextForThread = VESLogger.getLoggingContextForThread(uuid);
+ String requestId = loggingContextForThread.get(REQUEST_ID, "default");
+ String endTimestamp = loggingContextForThread.get(EcompFields.kEndTimestamp, "default");
- assertNotNull(requestId);
- assertNotNull(endTimestamp);
- assertNotSame(endTimestamp, "default");
- assertEquals(requestId, uuid.toString());
- }
+ assertNotNull(requestId);
+ assertNotNull(endTimestamp);
+ assertNotSame(endTimestamp, "default");
+ assertEquals(requestId, uuid.toString());
+ }
- @Test
- public void shouldOnLoggingContextInitializationPutGivenUUIDAsRequestIDAndSupplyEndTimestampAndCompleteStatusCode() {
- final UUID uuid = UUID.randomUUID();
- LoggingContext loggingContextForThread = VESLogger.getLoggingContextForThread(uuid.toString());
- String requestId = loggingContextForThread.get(REQUEST_ID, "default");
- String statusCode = loggingContextForThread.get("statusCode", "default");
- String endTimestamp = loggingContextForThread.get(EcompFields.kEndTimestamp, "default");
+ @Test
+ public void shouldOnLoggingContextInitializationPutGivenUuidAsRequestIdAndSupplyEndTimestampAndCompleteStatusCode() {
+ final UUID uuid = UUID.randomUUID();
+ LoggingContext loggingContextForThread = VESLogger.getLoggingContextForThread(uuid.toString());
+ String requestId = loggingContextForThread.get(REQUEST_ID, "default");
+ String statusCode = loggingContextForThread.get("statusCode", "default");
+ String endTimestamp = loggingContextForThread.get(EcompFields.kEndTimestamp, "default");
- assertNotNull(requestId);
- assertNotNull(endTimestamp);
- assertNotNull(statusCode);
- assertNotSame(endTimestamp, "default");
- assertEquals(requestId, uuid.toString());
- assertEquals(statusCode, "COMPLETE");
- }
+ assertNotNull(requestId);
+ assertNotNull(endTimestamp);
+ assertNotNull(statusCode);
+ assertNotSame(endTimestamp, "default");
+ assertEquals(requestId, uuid.toString());
+ assertEquals(statusCode, "COMPLETE");
+ }
}