Various Sonar and Checkstyle issues 92/78692/2
authormark.j.leonard <mark.j.leonard@gmail.com>
Fri, 15 Feb 2019 18:21:23 +0000 (18:21 +0000)
committerTian Lee <TianL@amdocs.com>
Tue, 19 Feb 2019 10:32:27 +0000 (10:32 +0000)
Issue-ID: AAI-2057

Change-Id: I3b24ce6e5baddb409e3b1d89f411ee934c465284
Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
28 files changed:
src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java
src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java
src/main/java/org/onap/aai/validation/ValidationServiceApplication.java
src/main/java/org/onap/aai/validation/Validator.java
src/main/java/org/onap/aai/validation/config/TopicPropertiesConfig.java
src/main/java/org/onap/aai/validation/ruledriven/rule/builtin/DataDictionary.java
src/main/resources/application.properties
src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java
src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java
src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java
src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java
src/test/java/org/onap/aai/validation/reader/TestEventReader.java
src/test/java/org/onap/aai/validation/reader/TestJsonReader.java
src/test/java/org/onap/aai/validation/result/TestValidationResult.java
src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java
src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java
src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java
src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java
src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java
src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java
src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java
src/test/java/org/onap/aai/validation/test/util/TestUtil.java
src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java
src/test/resources/aai-environment.properties
src/test/resources/data-dictionary/schemaIngest.properties
src/test/resources/logback.xml
src/test/resources/model-validation/instance-validator/schemaIngest.properties
src/test/resources/oxm-reader/schemaIngest.properties

index c565c9c..8181b43 100644 (file)
@@ -1,19 +1,22 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright ?? 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright ?? 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
+ *       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=====================================================
+ * ============LICENSE_END=========================================================
  */
 package org.onap.aai.auth;
 
@@ -32,6 +35,11 @@ public class AAIMicroServiceAuth {
     private ValidationServiceAuthConfig validationServiceAuthConfig;
     private AAIMicroServiceAuthCore authCore;
 
+    /**
+     * @param validationServiceAuthConfig
+     * @throws AAIAuthException
+     *         if the policy file cannot be loaded
+     */
     @Inject
     public AAIMicroServiceAuth(final ValidationServiceAuthConfig validationServiceAuthConfig) throws AAIAuthException {
         this.validationServiceAuthConfig = validationServiceAuthConfig;
index 9bd8e2b..681d0ea 100644 (file)
@@ -9,7 +9,7 @@
  * 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
+ *       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,
@@ -49,9 +49,8 @@ public class AAIMicroServiceAuthCore {
 
     private Path appConfigAuthDir;
 
-    private static boolean usersInitialized = false;
-    private static HashMap<String, AAIAuthUser> users;
-    private static boolean timerSet = false;
+    private boolean usersInitialized = false;
+    private HashMap<String, AAIAuthUser> users;
     private String policyAuthFileName;
 
     public enum HttpMethods {
@@ -64,8 +63,7 @@ public class AAIMicroServiceAuthCore {
 
     /**
      * @param authPolicyFile
-     * @throws AAIAuthException
-     *             if the policy file cannot be loaded
+     * @throws AAIAuthException if the policy file cannot be loaded
      */
     public void init(String authPolicyFile) throws AAIAuthException {
         try {
@@ -95,13 +93,8 @@ public class AAIMicroServiceAuthCore {
             }
         };
 
-        if (!timerSet) {
-            timerSet = true;
-            Timer timer = new Timer();
-            long period = TimeUnit.SECONDS.toMillis(1);
-            timer.schedule(task, new Date(), period);
-            applicationLogger.debug("Config Watcher Interval = " + period);
-        }
+        new Timer().schedule(task, new Date(), TimeUnit.SECONDS.toMillis(1));
+        applicationLogger.debug("Config Watcher Interval = " + TimeUnit.SECONDS.toMillis(1));
     }
 
     public String getConfigFile(String authPolicyFile) throws IOException {
@@ -167,7 +160,7 @@ public class AAIMicroServiceAuthCore {
      * @param roleName
      * @param functionNode
      */
-    private static void addFunctionToRole(AAIAuthRole role, String roleName, JsonNode functionNode) {
+    private void addFunctionToRole(AAIAuthRole role, String roleName, JsonNode functionNode) {
         String functionName = functionNode.path("name").asText();
         JsonNode methodsNode = functionNode.path("methods");
 
@@ -207,7 +200,6 @@ public class AAIMicroServiceAuthCore {
             }
             return false;
         }
-
     }
 
     public static class AAIAuthRole {
@@ -221,12 +213,6 @@ public class AAIMicroServiceAuthCore {
             this.allowedFunctions.add(func);
         }
 
-        public void delAllowedFunction(String delFunc) {
-            if (this.allowedFunctions.contains(delFunc)) {
-                this.allowedFunctions.remove(delFunc);
-            }
-        }
-
         public boolean hasAllowedFunction(String functionName) {
             return allowedFunctions.contains(functionName);
         }
@@ -251,7 +237,7 @@ public class AAIMicroServiceAuthCore {
         }
     }
 
-    private static void logAuthenticationResult(String username, String authFunction, String result) {
+    private void logAuthenticationResult(String username, String authFunction, String result) {
         applicationLogger.debug(result + ": " + username + " on function " + authFunction);
     }
 
index b3220cb..5db497d 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2017-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2017-2019 European Software Marketing Ltd.
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ public class ValidationServiceApplication extends SpringBootServletInitializer {
         JAVA_TRUST_STORE_PASSWORD("javax.net.ssl.trustStorePassword") // JVM
         ;
 
-        final private String propertyName;
+        private final String propertyName;
 
         SystemProperty() {
             propertyName = this.toString();
@@ -73,7 +73,7 @@ public class ValidationServiceApplication extends SpringBootServletInitializer {
         }
 
         public void set(String propertyValue) {
-            System.setProperty(propertyName, propertyValue);            
+            System.setProperty(propertyName, propertyValue);
         }
     }
 
@@ -84,7 +84,7 @@ public class ValidationServiceApplication extends SpringBootServletInitializer {
         SCHEMA_SERVICE_TRUST_STORE_PASSWORD("schema.service.ssl.trust-store-password") // aai-schema-ingest
         ;
 
-        final private String propertyName;
+        private final String propertyName;
 
         ApplicationProperty(String property) {
             propertyName = property;
index c3ecc2a..be2b995 100644 (file)
@@ -1,19 +1,22 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
+ *       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=====================================================
+ * ============LICENSE_END=========================================================
  */
 package org.onap.aai.validation;
 
@@ -22,14 +25,14 @@ import org.onap.aai.validation.exception.ValidationServiceException;
 import org.onap.aai.validation.result.ValidationResult;
 
 /**
- * Validator (e.g. model-driven or rule-based)
+ * Validator (e.g. model-driven or rule-based).
  *
  */
 public interface Validator {
 
     /**
      * This method should be called (once) before validate() to ensure that all configuration is correctly loaded.
-     * 
+     *
      * @throws ValidationServiceException
      */
     public void initialise() throws ValidationServiceException;
index 4a2dc16..53d6cc7 100644 (file)
@@ -1,7 +1,10 @@
 /**
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
@@ -13,7 +16,7 @@
  * 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=====================================================
+ * ============LICENSE_END=========================================================
  */
 package org.onap.aai.validation.config;
 
@@ -40,7 +43,7 @@ public class TopicPropertiesConfig {
     @Value("${topics.properties.location}")
     private String topicsPropertiesLocation;
 
-    private static final String[] propertyFilePatterns = { "file:./%s/*.properties", "classpath:/%s/*.properties" };
+    private static final String[] propertyFilePatterns = {"file:./%s/*.properties", "classpath:/%s/*.properties"};
 
     @Bean(name = "topicProperties")
     public Properties topicProperties() throws IOException {
index 9eaef94..dd6380e 100644 (file)
@@ -1,32 +1,34 @@
-/*
- * ============LICENSE_START===================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
  * Copyright (c) 2018-2019 European Software Marketing Ltd.
- * ============================================================================
+ * ================================================================================
  * 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
+ *       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=====================================================
+ * ============LICENSE_END=========================================================
  */
+
 package org.onap.aai.validation.ruledriven.rule.builtin;
 
+import com.google.common.collect.ImmutableMap;
 import com.google.gson.Gson;
 import com.google.gson.GsonBuilder;
 import com.google.gson.annotations.Expose;
 import com.google.gson.annotations.SerializedName;
 import java.text.MessageFormat;
-import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.Collections;
 import java.util.Properties;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.MultivaluedHashMap;
@@ -46,9 +48,7 @@ public class DataDictionary {
     private static org.onap.aai.restclient.client.RestClient restClient;
 
     public enum COMMON_MODEL_ELEMENT_TYPE {
-        INSTANCE,
-        ATTRIBUTE,
-        UNSUPPORTED;
+        INSTANCE, ATTRIBUTE, UNSUPPORTED;
     }
 
     private DataDictionary() {
@@ -87,9 +87,9 @@ public class DataDictionary {
      * /commonModelElements/attribute~nfRole~1.0/validateInstance
      *
      * @param commonModelElementType
-     *        "instance" or "attribute"
+     *            "instance" or "attribute"
      * @param commonModelElementName
-     *        name of common model element
+     *            name of common model element
      * @param attributeName
      * @param attributeValue
      * @return
@@ -162,11 +162,7 @@ public class DataDictionary {
         public Request(COMMON_MODEL_ELEMENT_TYPE cmeType, String attributeName, String attributeValue) {
             switch (cmeType) {
                 case INSTANCE:
-                    Map<String, String> map = new HashMap<>();
-                    map.put(attributeName, attributeValue);
-                    List<Object> list = new ArrayList<>();
-                    list.add(map);
-                    instance = list;
+                    instance = Collections.singletonList(ImmutableMap.of(attributeName, attributeValue));
                     break;
                 case ATTRIBUTE:
                     instance = attributeValue;
index 38b3d34..2c93762 100644 (file)
@@ -1,18 +1,21 @@
-# ============LICENSE_START===================================================
-# Copyright (c) 2018-2019 Amdocs
-# ============================================================================
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2018-2019 European Software Marketing Ltd.
+# ================================================================================
 # 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
-#
+# 
+#       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=====================================================
+# ============LICENSE_END=========================================================
 
 # Note that the start.sh script sets the following System Properties
 # We provide default values here for testing purposes
index a8e03eb..3ada0a1 100644 (file)
@@ -1,19 +1,22 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
+ *       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=====================================================
+ * ============LICENSE_END=========================================================
  */
 package org.onap.aai.validation.config;
 
@@ -25,12 +28,11 @@ import java.util.List;
 import javax.inject.Inject;
 import org.junit.Test;
 import org.junit.runner.RunWith;
-import org.onap.aai.validation.config.ValidationControllerConfig;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath:/validation-controller-config/test-validation-service-beans.xml"})
+@ContextConfiguration(locations = { "classpath:/validation-controller-config/test-validation-service-beans.xml" })
 public class TestValidationControllerConfig {
 
     static {
@@ -42,17 +44,17 @@ public class TestValidationControllerConfig {
 
     @Test
     public void testValidationControllerConfig() {
-        ValidationControllerConfig expected = new ValidationControllerConfig();
-        List<String> excludedEventActionList = new ArrayList<String>();
+        List<String> excludedEventActionList = new ArrayList<>();
         excludedEventActionList.add("DELETE");
 
-        List<String> eventTypeRuleList = new ArrayList<String>(2);
+        List<String> eventTypeRuleList = new ArrayList<>(2);
         eventTypeRuleList.add("AAI-EVENT");
         eventTypeRuleList.add("AAI-DATA-EXPORT-API");
 
-        List<String> eventTypeModelList = new ArrayList<String>();
+        List<String> eventTypeModelList = new ArrayList<>();
         eventTypeModelList.add("AAI-DATA-EXPORT-NQ");
 
+        ValidationControllerConfig expected = new ValidationControllerConfig();
         expected.setEventDomain("devINT1");
         expected.setExcludedEventActions(excludedEventActionList);
         expected.setEventTypeRule(eventTypeRuleList);
index c20d121..6aa6908 100644 (file)
@@ -9,7 +9,7 @@
  * 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
+ *        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,
@@ -42,7 +42,7 @@ import org.springframework.http.HttpHeaders;
 
 /**
  * Simple test to log each of the validation messages in turn.
- *
+ * 
  * This version tests only the error logger at INFO level.
  *
  */
@@ -71,7 +71,7 @@ public class TestApplicationLogger {
     /**
      * Check that each message can be logged and that (by implication of successful logging) there is a corresponding
      * resource (message format).
-     *
+     * 
      * @throws IOException
      */
     @Test
@@ -97,8 +97,8 @@ public class TestApplicationLogger {
             }
 
             if (logger.isDebugEnabled()) {
-                logger.debug(msg, args);
-                validateLoggedMessage(msg, debugReader, "DEBUG");
+            logger.debug(msg, args);
+            validateLoggedMessage(msg, debugReader, "DEBUG");
             }
 
             // The trace level is not enabled
@@ -109,7 +109,7 @@ public class TestApplicationLogger {
     /**
      * Check that each message can be logged and that (by implication of successful logging) there is a corresponding
      * resource (message format).
-     *
+     * 
      * @throws IOException
      */
     @Test
@@ -124,7 +124,7 @@ public class TestApplicationLogger {
 
     /**
      * Check logAudit with HTTP headers
-     *
+     * 
      * @throws IOException
      */
     @Test
@@ -156,7 +156,7 @@ public class TestApplicationLogger {
 
     /**
      * Check logAudit with no HTTP headers
-     *
+     * 
      * @throws IOException
      */
     @Test
@@ -173,7 +173,7 @@ public class TestApplicationLogger {
 
     /**
      * Check logMetrics
-     *
+     * 
      * @throws IOException
      */
     @Test
@@ -228,7 +228,7 @@ public class TestApplicationLogger {
 
     /**
      * Call a logger method which is expected to throw an UnsupportedOperationException
-     *
+     * 
      * @param logMethod
      * @param dummyMsg
      */
@@ -244,7 +244,7 @@ public class TestApplicationLogger {
 
     /**
      * Assert that a log message was logged to the expected log file at the expected severity
-     *
+     * 
      * @param msg
      * @param reader
      * @param severity
index 972cf9a..0c5a886 100644 (file)
@@ -2,8 +2,8 @@
  * ============LICENSE_START=======================================================
  * org.onap.aai
  * ================================================================================
- * Copyright © 2018-2019 AT&T Intellectual Property. All rights reserved.
- * Copyright © 2018-2019 European Software Marketing Ltd.
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-
 package org.onap.aai.validation.modeldriven;
 
 import static org.hamcrest.CoreMatchers.equalTo;
index 38c790b..c2b66c5 100644 (file)
@@ -42,7 +42,7 @@ import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties" })
+@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"})
 @ContextConfiguration(locations = {"classpath:model-validation/instance-reader/test-validation-service-beans.xml"})
 public class TestInstanceReader {
 
@@ -96,10 +96,12 @@ public class TestInstanceReader {
         EXPECTED_PSERVER        ("model-validation/instance-reader/expected-pserver.json");
         // @formatter:on
 
-               private String filename;
+        private String filename;
+
         TestData(String filename) {
             this.filename = filename;
         }
+
         public String getFilename() {
             return this.filename;
         }
index b7aba5e..1d3e6d2 100644 (file)
@@ -42,7 +42,7 @@ import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties" })
+@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"})
 @ContextConfiguration(locations = {"classpath:event-reader/test-validation-service-beans.xml"})
 public class TestEventReader {
 
@@ -83,10 +83,12 @@ public class TestEventReader {
         INVALID_5      ("event-reader/invalid-event-5.json");
         // @formatter:on
 
-               private String filename;
+        private String filename;
+
         TestData(String filename) {
             this.filename = filename;
         }
+
         public String getFilename() {
             return this.filename;
         }
index 116534b..5a3aae5 100644 (file)
@@ -33,9 +33,7 @@ public class TestJsonReader {
     }
 
     enum TestData {
-        SAMPLE_JSON(
-                "json-reader/sample.json"
-        );
+        SAMPLE_JSON("json-reader/sample.json");
 
         private String filename;
 
index e262ef1..3462418 100644 (file)
@@ -51,7 +51,7 @@ import org.springframework.test.context.TestPropertySource;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties" })
+@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties"})
 @ContextConfiguration(locations = {"classpath:validation-result/test-validation-service-beans.xml"})
 public class TestValidationResult {
 
@@ -80,15 +80,13 @@ public class TestValidationResult {
     }
 
     enum TestData {
-        VSERVER(
-                "validation-result/vserver-create-event.json"
-        );
+        VSERVER("validation-result/vserver-create-event.json");
 
-               private String filename;
+        private String filename;
 
         TestData(String filename) {
             this.filename = filename;
-    }
+        }
 
         public String getFilename() {
             return this.filename;
@@ -266,11 +264,11 @@ public class TestValidationResult {
      * Violation IDs whenever the values supplied to the builders are the same.
      *
      * @param b1
-     *        a builder
+     *            a builder
      * @param b2
-     *        another builder
+     *            another builder
      * @param expectedResult
-     *        whether or not the two builders should produce identical violations
+     *            whether or not the two builders should produce identical violations
      * @throws ValidationServiceException
      */
     private void testViolationIdsForEquality(Builder b1, Builder b2, Boolean expectedResult)
index 41721ba..f2ee3c9 100644 (file)
@@ -93,6 +93,10 @@ public class TestDefaultRules {
 
     private Validator ruleDrivenValidator;
 
+    /**
+     * @throws ValidationServiceException
+     *         if mocking a JSON parsing exception
+     */
     @Before
     public void createMockEventReader() throws ValidationServiceException {
         when(eventReader.getEventType(TestCase.VSERVER.name())).thenReturn(Optional.of("aai-event"));
index c9d6284..e7d4460 100644 (file)
@@ -1,20 +1,25 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
+ *       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=====================================================
+ * ============LICENSE_END=========================================================
  */
+
+
 package org.onap.aai.validation.ruledriven.rule;
 
 import static org.hamcrest.CoreMatchers.equalTo;
@@ -27,17 +32,19 @@ import org.onap.aai.validation.reader.data.AttributeValues;
 public class RuleHelper {
 
     static void assertRuleResult(Rule rule, AttributeValues values, Boolean expectedResult) {
-        assertThat(rule + " failed for values [" + values + "]", rule.execute(values).getSuccess(), is(equalTo(expectedResult)));
+        assertThat(rule + " failed for values [" + values + "]", rule.execute(values).getSuccess(),
+                is(equalTo(expectedResult)));
     }
 
     static void assertRuleResult(Rule rule, Object value, Boolean expectedResult) {
-        assertThat(rule + " failed for value [" + value + "]", rule.execute(value).getSuccess(), is(equalTo(expectedResult)));
+        assertThat(rule + " failed for value [" + value + "]", rule.execute(value).getSuccess(),
+                is(equalTo(expectedResult)));
     }
 
     static void assertRuleErrorMessage(Rule rule, Object value, String expectedErrorMessage) {
         RuleResult result = rule.execute(value);
         String errorMessage = MessageFormat.format(rule.getErrorMessage(), result.getErrorArguments().toArray());
-        assertThat(rule + " failed to validate error message [" + expectedErrorMessage + "]",
-                errorMessage, is(equalTo(expectedErrorMessage)));
+        assertThat(rule + " failed to validate error message [" + expectedErrorMessage + "]", errorMessage,
+                is(equalTo(expectedErrorMessage)));
     }
 }
index 6545120..7e3fe21 100644 (file)
@@ -1,26 +1,30 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018-2019 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
+ *       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=====================================================
+ * ============LICENSE_END=========================================================
  */
+
 package org.onap.aai.validation.ruledriven.rule;
 
 import org.onap.aai.validation.reader.data.AttributeValues;
 
 /**
- * Helper class for testing rules
+ * Helper class for testing rules.
  *
  */
 public class RuleTester {
index e074bcd..3956a64 100644 (file)
@@ -9,7 +9,7 @@
  * 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
+ *        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,
index 426bbb4..5b0e66b 100644 (file)
@@ -1,7 +1,10 @@
-/*
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+/**
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
@@ -13,7 +16,7 @@
  * 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=====================================================
+ * ============LICENSE_END=========================================================
  */
 package org.onap.aai.validation.ruledriven.rule;
 
@@ -82,6 +85,7 @@ public class TestRuleExecution {
 
     /**
      * Simple example of a rule using error message expansion
+     * 
      * @throws Exception
      */
     @Test
@@ -94,7 +98,8 @@ public class TestRuleExecution {
         GroovyRule rule = buildRuleWithErrorMessage("i", expression, errorMessage);
         assertRuleResult(rule, 1, expectedErrorMessage);
 
-        String expressionOneArgumentTooMany = "return new groovy.lang.Tuple2(true, java.util.Arrays.asList(\"arg1\", \"arg2\", \"arg3\"))";
+        String expressionOneArgumentTooMany =
+                "return new groovy.lang.Tuple2(true, java.util.Arrays.asList(\"arg1\", \"arg2\", \"arg3\"))";
         GroovyRule rule3 = buildRuleWithErrorMessage("i", expressionOneArgumentTooMany, errorMessage);
         assertRuleResult(rule3, 1, expectedErrorMessage);
 
@@ -105,6 +110,7 @@ public class TestRuleExecution {
 
     /**
      * Simple example of a rule using error message expansion, without arguments
+     * 
      * @throws Exception
      */
     @Test
@@ -126,7 +132,10 @@ public class TestRuleExecution {
     }
 
     /**
-     * vserver is related to vpe and vserver-name contains me6
+     * Test for "vserver is related to vpe and vserver-name contains me6".
+     *
+     * @throws Exception
+     *         if the rule expression in this test is invalid
      */
     @Test
     public void testConditionalRegExp() throws Exception {
@@ -137,7 +146,6 @@ public class TestRuleExecution {
 
         // Create some tests, varying the values for each attribute
         Collection<Collection<String>> relatedToTests = new ArrayList<>();
-        Collection<Collection<String>> vserverNameTests = new ArrayList<>();
 
         // These are the related-to values to test
         relatedToTests.add(Collections.<String>emptyList());
@@ -157,6 +165,7 @@ public class TestRuleExecution {
         testNames.add("123me6789");
 
         // Additional test for no vserver-name values present
+        Collection<Collection<String>> vserverNameTests = new ArrayList<>();
         vserverNameTests.add(Collections.<String>emptyList());
 
         for (String name : testNames) {
@@ -198,8 +207,8 @@ public class TestRuleExecution {
      */
     @Test
     public void testStringComparison() throws Exception {
-        String attribute = "generic-vnf.vnf-type";
-        String expression = "vnf-type == 'BW NFM'";
+        final String attribute = "generic-vnf.vnf-type";
+        final String expression = "vnf-type == 'BW NFM'";
         GroovyRule rule = buildRule(attribute, expression);
         assertRuleResult(rule, "BW NFM", true);
         assertRuleResult(rule, "bnfm", false);
@@ -238,8 +247,8 @@ public class TestRuleExecution {
 
     @Test
     public void testValidStringLength() throws Exception {
-        String attribute = "clli";
-        String expression = "clli.size() == 8 || clli.size() == 11";
+        final String attribute = "clli";
+        final String expression = "clli.size() == 8 || clli.size() == 11";
         Map<Object, Boolean> tests = new HashMap<>();
         tests.put("", false);
         tests.put("X", false);
@@ -262,7 +271,7 @@ public class TestRuleExecution {
     @Test
     public void testStringLengthAndChars() throws Exception {
         String attribute = "location_clli";
-        String expression = "location_clli != null && location_clli.matches('[a-zA-Z]{8,11}')";
+        final String expression = attribute + " != null && " + attribute + ".matches('[a-zA-Z]{8,11}')";
         Map<Object, Boolean> tests = new HashMap<>();
         tests.put(null, false);
         tests.put("", false);
@@ -282,8 +291,8 @@ public class TestRuleExecution {
      */
     @Test
     public void testRegularExpression() throws Exception {
-        String attribute = "unit";
-        String expression = "unit.matches('^ae0\\\\.(\\\\d)+')";
+        final String attribute = "unit";
+        final String expression = "unit.matches('^ae0\\\\.(\\\\d)+')";
         Map<Object, Boolean> tests = new HashMap<>();
         tests.put("", false);
         tests.put("X", false);
@@ -301,8 +310,8 @@ public class TestRuleExecution {
 
     @Test
     public void testNullStringLength() throws Exception {
-        String attribute = "clli";
-        String expression = "clli.size() == 8 || clli.size() == 11";
+        final String attribute = "clli";
+        final String expression = "clli.size() == 8 || clli.size() == 11";
         exception.expect(IllegalArgumentException.class);
         exception.expectMessage(containsString("Argument"));
         exception.expectMessage(containsString("null"));
@@ -312,8 +321,8 @@ public class TestRuleExecution {
 
     @Test
     public void testStringLengthWithNull() throws Exception {
-        String attribute = "a";
-        String expression = "a == null || a.size() > 4";
+        final String attribute = "a";
+        final String expression = "a == null || a.size() > 4";
         Map<Object, Boolean> tests = new HashMap<>();
         tests.put("", false);
         tests.put("X", false);
@@ -335,8 +344,8 @@ public class TestRuleExecution {
      */
     @Test
     public void testStringTextWithNull() throws Exception {
-        String attribute = "prov-status";
-        String expression = "prov-status != null && prov-status != 'ACTIVE'";
+        final String attribute = "prov-status";
+        final String expression = "prov-status != null && prov-status != 'ACTIVE'";
         Map<Object, Boolean> tests = new HashMap<>();
         tests.put(null, false);
         tests.put("ACTIVE", false);
@@ -360,9 +369,12 @@ public class TestRuleExecution {
      */
     @Test
     public void testCaseInsensitveStringMatch() throws Exception {
-        String attribute = "prov-status";
-        String expression =
-                "prov-status != null && prov-status.size() > 0 && !prov-status.equalsIgnoreCase('NULL') && !prov-status.equalsIgnoreCase('ACTIVE')";
+        final String attribute = "prov-status";
+        final String expression = new StringBuilder() //
+                .append(attribute).append(" != null && ") //
+                .append(attribute).append(".size() > 0 && !").append(attribute).append(".equalsIgnoreCase('NULL') && ")
+                .append("!").append(attribute).append(".equalsIgnoreCase('ACTIVE')") //
+                .toString();
         Map<Object, Boolean> tests = new HashMap<>();
         tests.put(null, false);
         tests.put("", false);
@@ -424,7 +436,6 @@ public class TestRuleExecution {
 
         // Create some tests, varying the values for each attribute
         Collection<String> heatStackIds = new ArrayList<>();
-        Collection<String> vnfNames = new ArrayList<>();
 
         heatStackIds.add("123me67890abcdef");
         heatStackIds.add("123me67890a");
@@ -432,6 +443,7 @@ public class TestRuleExecution {
         heatStackIds.add("");
         heatStackIds.add(null);
 
+        Collection<String> vnfNames = new ArrayList<>();
         vnfNames.add("123me67890abcdef");
         vnfNames.add("123me67890a");
         vnfNames.add("123me6789");
@@ -485,9 +497,12 @@ public class TestRuleExecution {
     /**
      * Build a simple rule using a RuleConfiguration object
      *
-     * @param name the rule name
-     * @param attribute a named variable, referenced in the expression
-     * @param expression the expression to evaluate (returns a Boolean value)
+     * @param name
+     *            the rule name
+     * @param attribute
+     *            a named variable, referenced in the expression
+     * @param expression
+     *            the expression to evaluate (returns a Boolean value)
      * @return
      * @throws IOException
      * @throws InstantiationException
@@ -503,6 +518,16 @@ public class TestRuleExecution {
         return new GroovyRule(ruleConfig);
     }
 
+    /**
+     * @param name
+     * @param attributes
+     * @param expression
+     * @return
+     * @throws InstantiationException
+     * @throws IllegalAccessException
+     * @throws IOException
+     * @throws GroovyConfigurationException
+     */
     private GroovyRule buildRule(String name, List<String> attributes, String expression)
             throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException {
         RuleSection ruleConfig = new RuleSection();
@@ -529,8 +554,10 @@ public class TestRuleExecution {
      *
      * @see TestRuleExecution#buildRule(String, String, String)
      *
-     * @param attribute a named variable, referenced in the expression
-     * @param expression the expression to evaluate (returns a Boolean value)
+     * @param attribute
+     *            a named variable, referenced in the expression
+     * @param expression
+     *            the expression to evaluate (returns a Boolean value)
      * @throws GroovyConfigurationException
      */
     private GroovyRule buildRule(String attribute, String expression)
@@ -538,6 +565,15 @@ public class TestRuleExecution {
         return buildRule("testRule", attribute, expression);
     }
 
+    /**
+     * @param attributes
+     * @param expression
+     * @return
+     * @throws InstantiationException
+     * @throws IllegalAccessException
+     * @throws IOException
+     * @throws GroovyConfigurationException
+     */
     private GroovyRule buildRule(List<String> attributes, String expression)
             throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException {
         return buildRule("testRule", attributes, expression);
index 0650743..b881804 100644 (file)
@@ -134,7 +134,8 @@ public class TestRuleValidation {
     /**
      * Utility to build and test different expressions using the supplied attribute name
      *
-     * @param attribute attribute (field) identifier
+     * @param attribute
+     *            attribute (field) identifier
      * @throws InstantiationException
      * @throws IllegalAccessException
      * @throws IOException
@@ -148,7 +149,8 @@ public class TestRuleValidation {
     /**
      * Utility to build and test an expression asserting that the size() of the attribute is 8 or 11
      *
-     * @param attribute attribute (field) identifier
+     * @param attribute
+     *            attribute (field) identifier
      * @throws InstantiationException
      * @throws IllegalAccessException
      * @throws IOException
@@ -191,9 +193,12 @@ public class TestRuleValidation {
     /**
      * Build a simple rule using a RuleConfiguration object
      *
-     * @param name the rule name
-     * @param attribute a named variable, referenced in the expression
-     * @param expression the expression to evaluate (returns a Boolean value)
+     * @param name
+     *            the rule name
+     * @param attribute
+     *            a named variable, referenced in the expression
+     * @param expression
+     *            the expression to evaluate (returns a Boolean value)
      * @return
      * @throws IOException
      * @throws InstantiationException
@@ -212,7 +217,8 @@ public class TestRuleValidation {
     /**
      * Utility to build a rule and test that the attribute is valid
      *
-     * @param attribute attribute (field) identifier
+     * @param attribute
+     *            attribute (field) identifier
      * @throws InstantiationException
      * @throws IllegalAccessException
      * @throws IOException
index e23f7a2..f1cdce6 100644 (file)
@@ -74,7 +74,8 @@ public class TestValidateServiceImpl {
     /**
      * Create a (mocked) HTTPS request and invoke the Babel generate artifacts API
      * 
-     * @param request for the Babel Service
+     * @param request
+     *            for the Babel Service
      * @return the Response from the HTTP API
      * @throws URISyntaxException
      */
index 39d1246..40fa4de 100644 (file)
@@ -34,7 +34,8 @@ public class TestUtil {
     /**
      * Gets files, such as test data from the classpath.
      *
-     * @param filename the name of the file
+     * @param filename
+     *            the name of the file
      * @return a String with the file contents.
      * @throws URISyntaxException
      * @throws IOException
index 2ef1e1e..5c6afed 100644 (file)
@@ -1,7 +1,10 @@
 /**
- * ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
- * ============================================================================
+ * ============LICENSE_START=======================================================
+ * org.onap.aai
+ * ================================================================================
+ * Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (c) 2018-2019 European Software Marketing Ltd.
+ * ================================================================================
  * 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
  * 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=====================================================
+ * ============LICENSE_END=========================================================
  */
 package org.onap.aai.validation.test.util;
 
+import java.util.Objects;
 import org.hamcrest.BaseMatcher;
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
@@ -43,11 +47,11 @@ public class ValidationResultIsEqual extends BaseMatcher<ValidationResult> {
             return false;
         }
         ValidationResult actual = (ValidationResult) obj;
-        return actual.getEntityId().equals(expected.getEntityId()) && //
-                actual.getEntityType().equals(expected.getEntityType()) && //
-                (actual.getEntityLink() == null ? "" : actual.getEntityLink()).equals(expected.getEntityLink()) && //
-                actual.getResourceVersion().equals(expected.getResourceVersion()) && //
-                actual.getViolations().equals(expected.getViolations());
+        return actual.getEntityId().equals(expected.getEntityId())
+                && actual.getEntityType().equals(expected.getEntityType())
+                && Objects.equals(actual.getEntityLink(), expected.getEntityLink())
+                && Objects.equals(actual.getResourceVersion(), expected.getResourceVersion())
+                && actual.getViolations().equals(expected.getViolations());
     }
 
     @Override
index 463a2b0..ddcc728 100644 (file)
@@ -1,20 +1,23 @@
-# ============LICENSE_START===================================================
-# Copyright (c) 2018 Amdocs
-# ============================================================================
+# ============LICENSE_START=======================================================
+# org.onap.aai
+# ================================================================================
+# Copyright (c) 2018-2019 AT&T Intellectual Property. All rights reserved.
+# Copyright (c) 2018-2019 European Software Marketing Ltd.
+# ================================================================================
 # 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
+#      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=====================================================
+# ============LICENSE_END=========================================================
 
-# This file is used by various tests (src/test and src/integration-test) as it loaded from the classpath
+# This file is used by various tests (loaded from the classpath)
 host=localhost
 port=8443
 httpProtocol=file
index 8df810a..317f478 100644 (file)
@@ -39,10 +39,4 @@ schema.version.edge.label.start=v10
 # Specifies the version that the application should default to
 schema.version.api.default=v9
 
-schema.service.base.url=https://localhost:8452/aai/schema-service/v1/
-schema.service.nodes.endpoint=nodes?version=
-schema.service.edges.endpoint=edgerules?version=
-schema.service.versions.endpoint=versions
 
-schema.service.ssl.key-store=src/integration-test/resources/authentication/aai-client-cert.p12
-schema.service.ssl.trust-store=src/integration-test/resources/authentication/tomcat_keystore
index 47c6154..4026543 100644 (file)
@@ -171,7 +171,7 @@ limitations under the License.
        <!-- Other Loggers that may help troubleshoot -->
        <logger name="org.apache" level="WARN" />
        <logger name="org.apache.commons" level="WARN" />
-    <logger name="com.jayway.jsonpath.internal.path.CompiledPath" level="WARN" />
+       <logger name="com.jayway.jsonpath.internal.path.CompiledPath" level="WARN" />
 
        <!-- logback internals logging -->
        <logger name="ch.qos.logback.classic" level="WARN" />
index 8df810a..317f478 100644 (file)
@@ -39,10 +39,4 @@ schema.version.edge.label.start=v10
 # Specifies the version that the application should default to
 schema.version.api.default=v9
 
-schema.service.base.url=https://localhost:8452/aai/schema-service/v1/
-schema.service.nodes.endpoint=nodes?version=
-schema.service.edges.endpoint=edgerules?version=
-schema.service.versions.endpoint=versions
 
-schema.service.ssl.key-store=src/integration-test/resources/authentication/aai-client-cert.p12
-schema.service.ssl.trust-store=src/integration-test/resources/authentication/tomcat_keystore
index 43e755b..34c8796 100644 (file)
@@ -28,5 +28,5 @@ schema.service.nodes.endpoint=nodes?version=
 schema.service.edges.endpoint=edgerules?version=
 schema.service.versions.endpoint=versions
 
-schema.service.ssl.key-store=appconfig-local/auth/aai-client-cert.p12
-schema.service.ssl.trust-store=appconfig-local/auth/tomcat_keystore
\ No newline at end of file
+schema.service.ssl.key-store=
+schema.service.ssl.trust-store=
\ No newline at end of file