-/*
- * ============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;
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;
* 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,
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 {
/**
* @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 {
}
};
- 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 {
* @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");
}
return false;
}
-
}
public static class AAIAuthRole {
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);
}
}
}
- 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);
}
* ============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.
JAVA_TRUST_STORE_PASSWORD("javax.net.ssl.trustStorePassword") // JVM
;
- final private String propertyName;
+ private final String propertyName;
SystemProperty() {
propertyName = this.toString();
}
public void set(String propertyValue) {
- System.setProperty(propertyName, propertyValue);
+ System.setProperty(propertyName, propertyValue);
}
}
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;
-/*
- * ============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;
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;
/**
- * ============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.config;
@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 {
-/*
- * ============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;
private static org.onap.aai.restclient.client.RestClient restClient;
public enum COMMON_MODEL_ELEMENT_TYPE {
- INSTANCE,
- ATTRIBUTE,
- UNSUPPORTED;
+ INSTANCE, ATTRIBUTE, UNSUPPORTED;
}
private 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
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;
-# ============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
-/*
- * ============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;
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 {
@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);
* 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,
/**
* Simple test to log each of the validation messages in turn.
- *
+ *
* This version tests only the error logger at INFO level.
*
*/
/**
* Check that each message can be logged and that (by implication of successful logging) there is a corresponding
* resource (message format).
- *
+ *
* @throws IOException
*/
@Test
}
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
/**
* Check that each message can be logged and that (by implication of successful logging) there is a corresponding
* resource (message format).
- *
+ *
* @throws IOException
*/
@Test
/**
* Check logAudit with HTTP headers
- *
+ *
* @throws IOException
*/
@Test
/**
* Check logAudit with no HTTP headers
- *
+ *
* @throws IOException
*/
@Test
/**
* Check logMetrics
- *
+ *
* @throws IOException
*/
@Test
/**
* Call a logger method which is expected to throw an UnsupportedOperationException
- *
+ *
* @param logMethod
* @param dummyMsg
*/
/**
* Assert that a log message was logged to the expected log file at the expected severity
- *
+ *
* @param msg
* @param reader
* @param severity
* ============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.
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.onap.aai.validation.modeldriven;
import static org.hamcrest.CoreMatchers.equalTo;
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 {
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;
}
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 {
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;
}
}
enum TestData {
- SAMPLE_JSON(
- "json-reader/sample.json"
- );
+ SAMPLE_JSON("json-reader/sample.json");
private String filename;
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 {
}
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;
* 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)
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"));
-/*
- * ============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;
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)));
}
}
-/*
- * ============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 {
* 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,
-/*
- * ============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.ruledriven.rule;
/**
* Simple example of a rule using error message expansion
+ *
* @throws Exception
*/
@Test
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);
/**
* Simple example of a rule using error message expansion, without arguments
+ *
* @throws Exception
*/
@Test
}
/**
- * 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 {
// 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());
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) {
*/
@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);
@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);
@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);
*/
@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);
@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"));
@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);
*/
@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);
*/
@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);
// 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");
heatStackIds.add("");
heatStackIds.add(null);
+ Collection<String> vnfNames = new ArrayList<>();
vnfNames.add("123me67890abcdef");
vnfNames.add("123me67890a");
vnfNames.add("123me6789");
/**
* 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
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();
*
* @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)
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);
/**
* 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
/**
* 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
/**
* 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
/**
* 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
/**
* 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
*/
/**
* 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
/**
- * ============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;
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
-# ============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
# 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
<!-- 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" />
# 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
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