Add protocols to hosts 11/64311/4
authorJakub Zieba <jakub.zieba@nokia.com>
Tue, 4 Sep 2018 05:23:41 +0000 (07:23 +0200)
committerJakub Zieba <jakub.zieba@nokia.com>
Tue, 4 Sep 2018 10:25:51 +0000 (12:25 +0200)
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>
16 files changed:
README.md
src/main/java/org/onap/dcae/VesApplication.java
src/main/java/org/onap/dcae/controller/ConfigFilesFacade.java
src/main/java/org/onap/dcae/controller/ConfigSource.java
src/main/java/org/onap/dcae/controller/EnvPropertiesReader.java
src/main/java/org/onap/dcae/controller/EnvProps.java
src/main/java/org/onap/dcae/restapi/HealthCheckController.java [new file with mode: 0644]
src/main/java/org/onap/dcae/restapi/SwaggerConfig.java
src/main/java/org/onap/dcae/restapi/WebMvcConfig.java [new file with mode: 0644]
src/test/java/org/onap/dcae/ApplicationSettingsTest.java
src/test/java/org/onap/dcae/TestingUtilities.java
src/test/java/org/onap/dcae/WiremockBasedTest.java
src/test/java/org/onap/dcae/commonFunction/EventProcessorTest.java
src/test/java/org/onap/dcae/controller/ConfigCBSSourceTest.java
src/test/java/org/onap/dcae/vestest/TestConfigProcessor.java
src/test/java/org/onap/dcae/vestest/TestVESLogger.java

index b7bbdb8..9e38dd6 100644 (file)
--- a/README.md
+++ b/README.md
@@ -38,7 +38,9 @@ Variables set manually / coming from deployment system:
 - COLLECTOR_IP
 - DMAAPHOST - should contain an address to DMaaP, so that event publishing can work
 - CBSPOLLTIMER - it should be put in here if we want to automatically fetch configuration from CBS.
-- CONSUL_HOST - used with conjunction with CBSPOLLTIMER, should be a host address (without port! e.g http://my-ip-or-host) where Consul service lies
+- CONSUL_PROTOCOL - Consul protocol by default set to **http**, if it is need to change it then that can be set to different value 
+- CONSUL_HOST - used with conjunction with CBSPOLLTIMER, should be a host address (without port! e.g my-ip-or-host) where Consul service lies
+- CBS_PROTOCOL - Config Binding Service protocol by default set to **http**, if it is need to change it then that can be set to different value
 - CONFIG_BINDING_SERVICE - used with conjunction with CBSPOLLTIMER, should be a name of CBS as it is registered in Consul
 - HOSTNAME - used with conjunction with CBSPOLLTIMER, should be a name of VESCollector application as it is registered in CBS catalog
 
index d9d12e3..a7426be 100644 (file)
@@ -42,8 +42,7 @@ import org.springframework.context.annotation.Lazy;
 import java.nio.file.Paths;
 import java.util.concurrent.*;
 
-@SpringBootApplication
-@EnableAutoConfiguration(exclude = {GsonAutoConfiguration.class, SecurityAutoConfiguration.class})
+@SpringBootApplication(exclude = {GsonAutoConfiguration.class, SecurityAutoConfiguration.class})
 public class VesApplication {
 
     private static final Logger metriclog = LoggerFactory.getLogger("com.att.ecomp.metrics");
index 42155ed..9338bf6 100644 (file)
  */
 package org.onap.dcae.controller;
 
-import static io.vavr.API.Try;
-import static org.onap.dcae.commonFunction.event.publishing.VavrUtils.enhanceError;
-import static org.onap.dcae.commonFunction.event.publishing.VavrUtils.f;
-import static org.onap.dcae.commonFunction.event.publishing.VavrUtils.logError;
-import static org.onap.dcae.controller.Conversions.toList;
-
 import io.vavr.CheckedRunnable;
 import io.vavr.Tuple2;
 import io.vavr.collection.Map;
 import io.vavr.control.Try;
-import java.io.FileNotFoundException;
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.commons.configuration.PropertiesConfiguration;
 import org.json.JSONObject;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.io.FileNotFoundException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+import static io.vavr.API.Try;
+import static org.onap.dcae.commonFunction.event.publishing.VavrUtils.*;
+import static org.onap.dcae.controller.Conversions.toList;
+
 class ConfigFilesFacade {
 
     private static Logger log = LoggerFactory.getLogger(ConfigFilesFacade.class);
@@ -100,6 +99,7 @@ class ConfigFilesFacade {
 
     private PropertiesConfiguration readProperties() throws ConfigurationException {
         PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration();
+        propertiesConfiguration.setDelimiterParsingDisabled(true);
         propertiesConfiguration.load(propertiesPath.toFile());
         return propertiesConfiguration;
     }
@@ -109,12 +109,20 @@ class ConfigFilesFacade {
             PropertiesConfiguration propertiesConfiguration = new PropertiesConfiguration(propertiesPath.toFile());
             propertiesConfiguration.setEncoding(null);
             for (Tuple2<String, String> property : properties) {
-                propertiesConfiguration.addProperty(property._1, property._2);
+                updateProperty(propertiesConfiguration, property);
             }
             propertiesConfiguration.save();
         };
     }
 
+    private void updateProperty(PropertiesConfiguration propertiesConfiguration, Tuple2<String, String> property) {
+        if (propertiesConfiguration.containsKey(property._1)) {
+            propertiesConfiguration.setProperty(property._1, property._2);
+        } else {
+            propertiesConfiguration.addProperty(property._1, property._2);
+        }
+    }
+
     private String indentConfiguration(String configuration) {
         return new JSONObject(configuration).toString(4);
     }
index 7e6a9fc..c20a22a 100644 (file)
@@ -43,7 +43,7 @@ final class ConfigSource {
             .peek(strBody -> log.info(f("Received following CBS configuration from Consul '%s'", strBody)))
             .flatMap(strBody -> toJsonArray(strBody))
             .flatMap(json -> withdrawCatalog(json))
-            .flatMap(json -> constructFullCBSUrl(json))
+            .flatMap(json -> constructFullCBSUrl(envProps, json))
             .flatMap(cbsUrl -> callCBSForAppConfig(envProps, cbsUrl))
             .flatMap(strBody -> toJson(strBody))
             .peek(jsonNode -> log.info(f("Received app configuration: '%s'", jsonNode)))
@@ -51,12 +51,14 @@ final class ConfigSource {
     }
 
     private static Try<String> callConsulForCBSConfiguration(EnvProps envProps) {
-        return executeGet(envProps.consulHost + ":" + envProps.consulPort + "/v1/catalog/service/" + envProps.cbsName)
+        return executeGet(envProps.consulProtocol + "://" + envProps.consulHost + ":" +
+            envProps.consulPort + "/v1/catalog/service/" + envProps.cbsName)
             .mapFailure(enhanceError("Unable to retrieve CBS configuration from Consul"));
     }
 
-    private static Try<String> constructFullCBSUrl(JSONObject json) {
-        return Try(() -> json.get("ServiceAddress").toString() + ":" + json.get("ServicePort").toString())
+    private static Try<String> constructFullCBSUrl(EnvProps envProps, JSONObject json) {
+        return Try(() -> envProps.cbsProtocol + "://" + json.get("ServiceAddress").toString() + ":" +
+            json.get("ServicePort").toString())
             .mapFailure(enhanceError("ServiceAddress / ServicePort missing from CBS conf: '%s'", json));
     }
 
index 23bcbda..5f7a2fb 100644 (file)
  */
 package org.onap.dcae.controller;
 
-import static io.vavr.API.List;
-import static io.vavr.API.Try;
-import static org.onap.dcae.commonFunction.event.publishing.VavrUtils.f;
-
 import io.vavr.collection.Map;
 import io.vavr.control.Option;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import static io.vavr.API.List;
+import static io.vavr.API.Try;
+import static org.onap.dcae.commonFunction.event.publishing.VavrUtils.f;
+
 final class EnvPropertiesReader {
 
     private final static Logger log = LoggerFactory.getLogger(EnvPropertiesReader.class);
@@ -36,11 +36,13 @@ final class EnvPropertiesReader {
     static Option<EnvProps> readEnvProps(Map<String, String> environmentVariables) {
         log.info("Loading necessary environment variables for dynamic configuration update");
         int consulPort = getConsulPort(environmentVariables);
+        String consulProtocol = getConsulProtocol(environmentVariables);
+        String cbsProtocol = getCbsProtocol(environmentVariables);
         Option<String> consulHost = getConsulHost(environmentVariables);
         Option<String> cbsServiceName = getCBSName(environmentVariables);
         Option<String> vesCollectorAppName = getAppName(environmentVariables);
         return Option.sequence(List(consulHost, cbsServiceName, vesCollectorAppName))
-            .map(e -> new EnvProps(e.get(0), consulPort, e.get(1), e.get(2)))
+            .map(e -> new EnvProps(consulProtocol, e.get(0), consulPort, cbsProtocol, e.get(1), e.get(2)))
             .onEmpty(() -> log.warn("Some required environment variables are missing"))
             .peek(props -> log.info(f("Discovered following environment variables: '%s'", props)));
     }
@@ -74,4 +76,19 @@ final class EnvPropertiesReader {
                 + "is missing from environment variables."));
     }
 
+    private static String getConsulProtocol(Map<String, String> environmentVariables) {
+        return getProtocolFrom("CONSUL_PROTOCOL", environmentVariables);
+    }
+
+    private static String getCbsProtocol(Map<String, String> environmentVariables) {
+        return getProtocolFrom("CBS_PROTOCOL", environmentVariables);
+    }
+
+    private static String getProtocolFrom(String variableName, Map<String, String> environmentVariables) {
+        return environmentVariables.get(variableName)
+            .onEmpty(() -> log.warn("Consul protocol (env var: '" + variableName + "') is missing "
+                + "from environment variables."))
+            .getOrElse("http");
+    }
+
 }
index 2ee41cc..5f7d08d 100644 (file)
@@ -26,14 +26,18 @@ import java.util.Objects;
  */
 final class EnvProps {
 
+    final String consulProtocol;
     final String consulHost;
     final int consulPort;
     final String cbsName;
+    final String cbsProtocol;
     final String appName;
 
-    EnvProps(String consulHost, int consulPort, String cbsName, String appName) {
+    EnvProps(String consulProtocol, String consulHost, int consulPort, String cbsProtocol, String cbsName, String appName) {
+        this.consulProtocol = consulProtocol;
         this.consulHost = consulHost;
         this.consulPort = consulPort;
+        this.cbsProtocol = cbsProtocol;
         this.cbsName = cbsName;
         this.appName = appName;
     }
@@ -41,8 +45,10 @@ final class EnvProps {
     @Override
     public String toString() {
         return "EnvProps{" +
-            "consulHost='" + consulHost + '\'' +
+            "consulProtocol='" + consulProtocol + '\'' +
+            ", consulHost='" + consulHost + '\'' +
             ", consulPort=" + consulPort +
+            ", cbsProtocol='" + cbsProtocol + '\'' +
             ", cbsName='" + cbsName + '\'' +
             ", appName='" + appName + '\'' +
             '}';
@@ -58,13 +64,15 @@ final class EnvProps {
         }
         EnvProps envProps = (EnvProps) o;
         return consulPort == envProps.consulPort &&
+            Objects.equals(consulProtocol, envProps.consulProtocol) &&
             Objects.equals(consulHost, envProps.consulHost) &&
+            Objects.equals(cbsProtocol, envProps.cbsProtocol) &&
             Objects.equals(cbsName, envProps.cbsName) &&
             Objects.equals(appName, envProps.appName);
     }
 
     @Override
     public int hashCode() {
-        return Objects.hash(consulHost, consulPort, cbsName, appName);
+        return Objects.hash(consulProtocol, consulHost, consulPort, cbsProtocol, cbsName, appName);
     }
 }
\ No newline at end of file
diff --git a/src/main/java/org/onap/dcae/restapi/HealthCheckController.java b/src/main/java/org/onap/dcae/restapi/HealthCheckController.java
new file mode 100644 (file)
index 0000000..9c65619
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Nokia. All rights reserved.s
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcae.restapi;
+
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.GetMapping;
+
+
+@Controller
+public class HealthCheckController {
+
+    @GetMapping("/healthcheck")
+    public String healthCheck() {
+        return "hello";
+    }
+
+}
index d8554cb..60740a8 100644 (file)
@@ -22,8 +22,6 @@ package org.onap.dcae.restapi;
 
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
-import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
 import springfox.documentation.builders.PathSelectors;
 import springfox.documentation.builders.RequestHandlerSelectors;
 import springfox.documentation.spi.DocumentationType;
@@ -32,7 +30,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
 
 @Configuration
 @EnableSwagger2
-public class SwaggerConfig extends WebMvcConfigurationSupport {
+public class SwaggerConfig{
   @Bean
   public Docket api() {
     return new Docket(DocumentationType.SWAGGER_2)
@@ -42,14 +40,4 @@ public class SwaggerConfig extends WebMvcConfigurationSupport {
         .build();
   }
 
-  @Override
-  protected void addResourceHandlers(ResourceHandlerRegistry registry) {
-    registry
-        .addResourceHandler("swagger-ui.html")
-        .addResourceLocations("classpath:/META-INF/resources/");
-
-    registry
-        .addResourceHandler("/webjars/**")
-        .addResourceLocations("classpath:/META-INF/resources/webjars/");
-  }
 }
diff --git a/src/main/java/org/onap/dcae/restapi/WebMvcConfig.java b/src/main/java/org/onap/dcae/restapi/WebMvcConfig.java
new file mode 100644 (file)
index 0000000..7059c4e
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * ============LICENSE_START=======================================================
+ * PROJECT
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2018 Nokia. All rights reserved.s
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.dcae.restapi;
+
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
+import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;
+import org.springframework.web.servlet.view.InternalResourceViewResolver;
+
+@Configuration
+public class WebMvcConfig extends WebMvcConfigurationSupport {
+
+    @Override
+    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
+        registry
+            .addResourceHandler("swagger-ui.html")
+            .addResourceLocations("classpath:/META-INF/resources/");
+
+        registry
+            .addResourceHandler("/webjars/**")
+            .addResourceLocations("classpath:/META-INF/resources/webjars/");
+
+        registry
+            .addResourceHandler("**")
+            .addResourceLocations("classpath:/templates/");
+    }
+
+    @Bean
+    public InternalResourceViewResolver jspViewResolver() {
+        InternalResourceViewResolver resolver = new InternalResourceViewResolver();
+        resolver.setPrefix("/");
+        resolver.setSuffix(".html");
+        return resolver;
+    }
+
+}
index 26b0a68..67b9cb6 100644 (file)
@@ -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();
index 092983b..21edfc8 100644 (file)
  */
 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)
index ae85125..5862634 100644 (file)
  * 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()
             + "}]";
     }
index 97dccb5..3e35846 100644 (file)
@@ -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);
 
index 336788a..bee2cce 100644 (file)
  */
 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"));
     }
 }
 
index 310e8be..eaf5941 100644 (file)
@@ -22,11 +22,11 @@ package org.onap.dcae.vestest;
 import static org.junit.Assert.assertEquals;\r
 import static org.junit.Assert.assertNotEquals;\r
 \r
+import com.google.gson.JsonParser;\r
+import com.google.gson.JsonObject;\r
 import java.io.FileReader;\r
 import java.io.IOException;\r
 import org.json.JSONObject;\r
-import com.google.gson.JsonParser;\r
-import com.google.gson.JsonObject;\r
 import org.junit.Test;\r
 \r
 import org.onap.dcae.commonFunction.ConfigProcessors;\r
@@ -87,7 +87,8 @@ public class TestConfigProcessor {
         System.out.println("event==" + jsonObject.toString());\r
         System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);\r
         final JSONObject jsonArgs = new JSONObject(\r
-                "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": \"event.faultFields.alarmAdditionalInformation\"}");\r
+                "{\"field\": \"event.faultFields.eventAdditionalInformation\",\"oldField\": "\r
+                    + "\"event.faultFields.alarmAdditionalInformation\"}");\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
         cpEvent.map(jsonArgs);\r
         final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventAdditionalInformation")\r
@@ -101,11 +102,10 @@ public class TestConfigProcessor {
     public void testJSONObjectMapToArray() {\r
 \r
         final JSONObject jsonObject = getFileAsJsonObject();\r
-        //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();\r
         System.out.println("event==" + jsonObject.toString());\r
-        //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);\r
         final JSONObject jsonArgs = new JSONObject(\r
-                "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": \"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}");\r
+                "{\"field\": \"event.faultFields.vNicPerformanceArray[]\",\"oldField\": "\r
+                    + "\"event.faultFields.errors\",\"attrMap\":{\"receiveDiscards\":\"receivedDiscardedPacketsAccumulated\"}}");\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
         final String receiveDiscards = cpEvent.getEventObjectVal("event.faultFields.errors.receiveDiscards").toString();\r
         System.out.println("receiveDiscards==" + receiveDiscards);\r
@@ -122,9 +122,7 @@ public class TestConfigProcessor {
     public void testMapRenameObject() {\r
 \r
         final JSONObject jsonObject = getFileAsJsonObject();\r
-        //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();\r
         System.out.println("event==" + jsonObject.toString());\r
-        //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);\r
         final JSONObject jsonArgs = new JSONObject(\r
                 "{\"field\": \"event.faultFields.faultVFScalingFields\",\"oldField\": \"event.faultFields.errors\",\"mapType\":\"renameObject\"}");\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
@@ -142,9 +140,7 @@ public class TestConfigProcessor {
     public void testMapHashmapToNameValueArray() {\r
 \r
         final JSONObject jsonObject = getFileAsJsonObject();\r
-        //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();\r
         System.out.println("event==" + jsonObject.toString());\r
-        //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);\r
         final JSONObject jsonArgs = new JSONObject(\r
                 "{\"field\": \"event.faultFields.errors\",\"mapType\":\"hashmapToNameValueArray\"}");\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
@@ -163,9 +159,7 @@ public class TestConfigProcessor {
     public void testMapNameValueArrayToHashmap() {\r
 \r
         final JSONObject jsonObject = getFileAsJsonObject();\r
-        //final String receiveDiscards = (((jsonObject.getJSONObject("event")).getJSONObject("faultFields")).get("errors")).get("receiveDiscards").toString();\r
         System.out.println("event==" + jsonObject.toString());\r
-        //System.out.println("alarmAdditionalInformation==" + alarmAdditionalInformation);\r
         final JSONObject jsonArgs = new JSONObject(\r
                 "{\"field\": \"event.faultFields.alarmAdditionalInformation\",\"mapType\":\"nameValueArrayToHashmap\"}");\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
@@ -184,9 +178,7 @@ public class TestConfigProcessor {
     public void testAttrAdd() {\r
 \r
         final JSONObject jsonObject = getFileAsJsonObject();\r
-        //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();\r
         System.out.println("event==" + jsonObject.toString());\r
-        //System.out.println("functionRole==" + functionRole);\r
         final JSONObject jsonArgs = new JSONObject(\r
                 "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
@@ -201,9 +193,7 @@ public class TestConfigProcessor {
     public void testAttrUpdate() {\r
 \r
         final JSONObject jsonObject = getFileAsJsonObject();\r
-        //final String functionRole = (jsonObject.getJSONObject("event")).getJSONObject("commonEventHeader").get("functionalRole").toString();\r
         System.out.println("event==" + jsonObject.toString());\r
-        //System.out.println("functionRole==" + functionRole);\r
         final JSONObject jsonArgs = new JSONObject(\r
                 "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}");\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
@@ -280,7 +270,6 @@ public class TestConfigProcessor {
         final JSONObject jsonObject = getFileAsJsonObject();\r
         System.out.println("event==" + jsonObject.toString());\r
         System.out.println("Testing SetEventObjectVal");\r
-        //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.version\",\"value\": \"2.0\",\"fieldType\": \"number\"}" );\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
         cpEvent.setEventObjectVal("event.faultFields.version", "2.0", "number");\r
         final String responseData = cpEvent.getEventObjectVal("event.faultFields.version").toString();\r
@@ -310,7 +299,6 @@ public class TestConfigProcessor {
         final JSONObject jsonObject = getFileAsJsonObject();\r
         System.out.println("event==" + jsonObject.toString());\r
         System.out.println("Testing GetEventObjectVal");\r
-        //final JSONObject jsonArgs = new JSONObject ( "{\"field\": \"event.faultFields.eventSeverity\"}" );\r
         ConfigProcessors cpEvent = new ConfigProcessors(jsonObject);\r
         cpEvent.getEventObjectVal("event.faultFields.eventSeverity");\r
         final String responseData = cpEvent.getEventObjectVal("event.faultFields.eventSeverity").toString();\r
index 484f7dc..848f2b7 100644 (file)
  */
 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");
+    }
 
 }