summaryrefslogtreecommitdiffstats
path: root/src/test/java
diff options
context:
space:
mode:
authormark.j.leonard <mark.j.leonard@gmail.com>2019-02-15 18:21:23 +0000
committerTian Lee <TianL@amdocs.com>2019-02-19 10:32:27 +0000
commit4b005ff11a6321d92340228cb10de717880db448 (patch)
treea556a9ebb7144695df6475130cfed74ebdf74e29 /src/test/java
parent66372969d78dde14097209808358479635c0e8d0 (diff)
Various Sonar and Checkstyle issues
Issue-ID: AAI-2057 Change-Id: I3b24ce6e5baddb409e3b1d89f411ee934c465284 Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java26
-rw-r--r--src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java22
-rw-r--r--src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java5
-rw-r--r--src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java6
-rw-r--r--src/test/java/org/onap/aai/validation/reader/TestEventReader.java6
-rw-r--r--src/test/java/org/onap/aai/validation/reader/TestJsonReader.java4
-rw-r--r--src/test/java/org/onap/aai/validation/result/TestValidationResult.java16
-rw-r--r--src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java4
-rw-r--r--src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java27
-rw-r--r--src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java18
-rw-r--r--src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java2
-rw-r--r--src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java96
-rw-r--r--src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java18
-rw-r--r--src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java3
-rw-r--r--src/test/java/org/onap/aai/validation/test/util/TestUtil.java3
-rw-r--r--src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java22
16 files changed, 171 insertions, 107 deletions
diff --git a/src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java b/src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java
index a8e03eb..3ada0a1 100644
--- a/src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java
+++ b/src/test/java/org/onap/aai/validation/config/TestValidationControllerConfig.java
@@ -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);
diff --git a/src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java b/src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java
index c20d121..6aa6908 100644
--- a/src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java
+++ b/src/test/java/org/onap/aai/validation/logging/TestApplicationLogger.java
@@ -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
diff --git a/src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java b/src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java
index 972cf9a..0c5a886 100644
--- a/src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java
+++ b/src/test/java/org/onap/aai/validation/modeldriven/TestModelId.java
@@ -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;
diff --git a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java
index 38c790b..c2b66c5 100644
--- a/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java
+++ b/src/test/java/org/onap/aai/validation/modeldriven/validator/TestInstanceReader.java
@@ -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;
}
diff --git a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java
index b7aba5e..1d3e6d2 100644
--- a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java
+++ b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java
@@ -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;
}
diff --git a/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java b/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java
index 116534b..5a3aae5 100644
--- a/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java
+++ b/src/test/java/org/onap/aai/validation/reader/TestJsonReader.java
@@ -33,9 +33,7 @@ public class TestJsonReader {
}
enum TestData {
- SAMPLE_JSON(
- "json-reader/sample.json"
- );
+ SAMPLE_JSON("json-reader/sample.json");
private String filename;
diff --git a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java
index e262ef1..3462418 100644
--- a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java
+++ b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java
@@ -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)
diff --git a/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java b/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java
index 41721ba..f2ee3c9 100644
--- a/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java
+++ b/src/test/java/org/onap/aai/validation/ruledriven/mock/TestDefaultRules.java
@@ -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"));
diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java
index c9d6284..e7d4460 100644
--- a/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java
+++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleHelper.java
@@ -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)));
}
}
diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java
index 6545120..7e3fe21 100644
--- a/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java
+++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/RuleTester.java
@@ -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 {
diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java
index e074bcd..3956a64 100644
--- a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java
+++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestConfigurationLoader.java
@@ -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,
diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java
index 426bbb4..5b0e66b 100644
--- a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java
+++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleExecution.java
@@ -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);
diff --git a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java
index 0650743..b881804 100644
--- a/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java
+++ b/src/test/java/org/onap/aai/validation/ruledriven/rule/TestRuleValidation.java
@@ -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
diff --git a/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java b/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java
index e23f7a2..f1cdce6 100644
--- a/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java
+++ b/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java
@@ -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
*/
diff --git a/src/test/java/org/onap/aai/validation/test/util/TestUtil.java b/src/test/java/org/onap/aai/validation/test/util/TestUtil.java
index 39d1246..40fa4de 100644
--- a/src/test/java/org/onap/aai/validation/test/util/TestUtil.java
+++ b/src/test/java/org/onap/aai/validation/test/util/TestUtil.java
@@ -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
diff --git a/src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java b/src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java
index 2ef1e1e..5c6afed 100644
--- a/src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java
+++ b/src/test/java/org/onap/aai/validation/test/util/ValidationResultIsEqual.java
@@ -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,10 +16,11 @@
* 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