staticContent/
target/
src/main/java/META-INF/
+.checkstyle
<?xml version="1.0"?>
<!--
============LICENSE_START===================================================
-Copyright (c) 2018 Amdocs
+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.
<serverPort>9500</serverPort>
<sslport>9501</sslport>
<version.org.onap.aai.logging-service>1.2.2</version.org.onap.aai.logging-service>
- <version.org.onap.aai-rest-client>1.2.1</version.org.onap.aai-rest-client>
+ <version.aai.rest.client>1.4.0</version.aai.rest.client>
<version.org.onap.aai.event.client>1.2.2</version.org.onap.aai.event.client>
<version.com.ecomp.aai.gap.data.client>1.0</version.com.ecomp.aai.gap.data.client>
<version.com.google.code.gson>2.7</version.com.google.code.gson>
<version.org.hamcrest.hamcrest-library>1.3</version.org.hamcrest.hamcrest-library>
<version.org.json.json>20160212</version.org.json.json>
<version.org.onap.aai.aai-schema>1.2.4</version.org.onap.aai.aai-schema>
- <version.jacoco.maven.plugin>0.7.9</version.jacoco.maven.plugin>
<version.org.glassfish.jersey.core.jersey-client>2.23</version.org.glassfish.jersey.core.jersey-client>
<version.aai.aai-schema-ingest>1.2.4</version.aai.aai-schema-ingest>
<docker.location>${basedir}/target</docker.location>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
- <version>1.2.3</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<dependency>
<groupId>org.onap.aai</groupId>
<artifactId>rest-client</artifactId>
- <version>${version.org.onap.aai-rest-client}</version>
+ <version>${version.aai.rest.client}</version>
</dependency>
<dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
- <version>2.19.1</version>
<configuration>
<!-- Skips unit tests if the value of skip.unit.tests property is true -->
<skipTests>${skip.unit.tests}</skipTests>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
- <version>${version.jacoco.maven.plugin}</version>
<executions>
<execution>
<id>prepare-agent</id>
-/*
+/**
* ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
+ * 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,
* ============LICENSE_END=====================================================
*/
package org.onap.aai.validation.data.client;
-
-import com.sun.jersey.core.util.MultivaluedMapImpl;
+
import java.util.Arrays;
import java.util.UUID;
import javax.inject.Inject;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import org.onap.aai.restclient.client.OperationResult;
import org.onap.aai.validation.config.RestConfig;
initialiseRestClient();
}
- /**
- * Initialises the REST client
- *
- */
+ /** Initialises the REST client */
private void initialiseRestClient() {
// @formatter:off
- aaiRestClient = new org.onap.aai.restclient.client.RestClient()
- .validateServerHostname(false)
- .validateServerCertChain(true)
- .clientCertFile(APP_CONFIG_HOME + restConfig.getKeyStorePath())
- .clientCertPassword(restConfig.getKeyStorePassword())
- .trustStore(APP_CONFIG_HOME + restConfig.getTrustStorePath())
- .connectTimeoutMs(restConfig.getConnectionTimeout())
- .readTimeoutMs(restConfig.getReadTimeout());
- // @formatter:on
+ aaiRestClient = new org.onap.aai.restclient.client.RestClient()
+ .validateServerHostname(false)
+ .validateServerCertChain(true)
+ .clientCertFile(APP_CONFIG_HOME + restConfig.getKeyStorePath())
+ .clientCertPassword(restConfig.getKeyStorePassword())
+ .trustStore(APP_CONFIG_HOME + restConfig.getTrustStorePath())
+ .connectTimeoutMs(restConfig.getConnectionTimeout())
+ .readTimeoutMs(restConfig.getReadTimeout());
+ // @formatter:on
- headers = new MultivaluedMapImpl();
+ headers = new MultivaluedHashMap<>();
headers.put("Accept", Arrays.asList(ACCEPT));
headers.put("X-FromAppId", Arrays.asList(HEADER_X_FROM_APP_ID));
headers.put("X-TransactionId", Arrays.asList(UUID.randomUUID().toString()));
*
* @param url
* @param payload
- *
* @return The payload of the REST URL call as a string.
* @throws GapServiceException
*/
throw new ValidationServiceException(ValidationServiceError.REST_CLIENT_RESPONSE_ERROR,
result.getResultCode(), result.getFailureCause());
}
-
}
}
/*
* ============LICENSE_START===================================================
- * Copyright (c) 2018 Amdocs
+ * 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.
import com.google.gson.GsonBuilder;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
-import com.sun.jersey.core.util.MultivaluedMapImpl;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map;
import java.util.Properties;
import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedHashMap;
import javax.ws.rs.core.MultivaluedMap;
import org.onap.aai.cl.api.Logger;
import org.onap.aai.restclient.client.OperationResult;
UNSUPPORTED;
}
-
private DataDictionary() {
// intentionally empty
}
/**
* Initializes this class' static variables using MethodInvokingFactoryBean
+ *
* @param props
*/
public static void setProperties(Properties props) {
credentials = "Basic " + props.getProperty("rule.datadictionary.credentials");
urlTemplate = hostport + uriTemplate;
- restClient = new org.onap.aai.restclient.client.RestClient()
- .validateServerHostname(false)
- .connectTimeoutMs(Integer.parseInt(connectTimeout))
+ restClient = new org.onap.aai.restclient.client.RestClient() //
+ .validateServerHostname(false) //
+ .connectTimeoutMs(Integer.parseInt(connectTimeout)) //
.readTimeoutMs(Integer.parseInt(readTimeout));
}
-
/**
* Generates a REST request to data-dictionary to validate the given attributes.
*
- * URI: /commonModelElements/[commonModelElementId]/validateInstance
- * where commonModelElementId is defined as:
- * [commonModelElementType]~[commonModelElementName]~[commonModelElementVersion]
+ * URI: /commonModelElements/[commonModelElementId]/validateInstance where commonModelElementId is defined as:
+ * [commonModelElementType]~[commonModelElementName]~[commonModelElementVersion]
*
- * Supported commonModelElementType:
- * instance
- * attribute
+ * Supported commonModelElementType: instance attribute
*
- * Examples:
- * /commonModelElements/instance~nfValuesCatalog~1.0/validateInstance
- * /commonModelElements/attribute~nfRole~1.0/validateInstance
+ * Examples: /commonModelElements/instance~nfValuesCatalog~1.0/validateInstance
+ * /commonModelElements/attribute~nfRole~1.0/validateInstance
*
- * @param commonModelElementType "instance" or "attribute"
- * @param commonModelElementName name of common model element
+ * @param commonModelElementType
+ * "instance" or "attribute"
+ * @param commonModelElementName
+ * name of common model element
* @param attributeName
* @param attributeValue
* @return
*/
- public static String validate(String commonModelElementType, String commonModelElementName,
- String attributeName, String attributeValue) {
+ public static String validate(String commonModelElementType, String commonModelElementName, String attributeName,
+ String attributeValue) {
COMMON_MODEL_ELEMENT_TYPE cmeType = COMMON_MODEL_ELEMENT_TYPE.UNSUPPORTED;
try {
cmeType = COMMON_MODEL_ELEMENT_TYPE.valueOf(commonModelElementType.toUpperCase());
- } catch(IllegalArgumentException e) {
+ } catch (IllegalArgumentException e) {
final String error = "unsupported commonModelElementType: " + commonModelElementType;
logger.error(ApplicationMsgs.CANNOT_VALIDATE_ERROR, error);
return error;
}
- if(attributeValue == null || attributeValue.isEmpty()) {
+ if (attributeValue == null || attributeValue.isEmpty()) {
final String error = "element value missing";
logger.error(ApplicationMsgs.CANNOT_VALIDATE_ERROR, error);
return error;
}
- logger.debug("Executing built-in rule with: '" + commonModelElementType + "', '" + commonModelElementName +
- "'; attribute: " + attributeName + "=" + attributeValue);
+ logger.debug("Executing built-in rule with: '" + commonModelElementType + "', '" + commonModelElementName
+ + "'; attribute: " + attributeName + "=" + attributeValue);
Gson gson = new GsonBuilder().create();
String payload = gson.toJson(new Request(cmeType, attributeName, attributeValue));
String url = MessageFormat.format(urlTemplate, commonModelElementType, commonModelElementName);
OperationResult result = post(url, payload);
- if(result.getResultCode() == 500) {
+ if (result.getResultCode() == 500) {
// network unreachable; log a warning and return success
logger.warn(ApplicationMsgs.EVENT_CLIENT_CLOSE_UNSENT_MESSAGE,
- ValidationServiceError.REST_CLIENT_RESPONSE_ERROR.getMessage(result.getResultCode(), result.getFailureCause()));
+ ValidationServiceError.REST_CLIENT_RESPONSE_ERROR.getMessage(result.getResultCode(),
+ result.getFailureCause()));
return "";
}
- if(result.getResultCode() != 200 && result.getResultCode() != 204) {
- String error = ValidationServiceError.REST_CLIENT_RESPONSE_ERROR.getMessage(result.getResultCode(), result.getFailureCause());
+ if (result.getResultCode() != 200 && result.getResultCode() != 204) {
+ String error = ValidationServiceError.REST_CLIENT_RESPONSE_ERROR.getMessage(result.getResultCode(),
+ result.getFailureCause());
logger.error(ApplicationMsgs.CANNOT_VALIDATE_ERROR, error);
return result.getFailureCause();
}
return "";
}
-
/**
* Posts the payload to the URL
+ *
* @param url
* @param payload
* @return
*/
private static OperationResult post(String url, String payload) {
- MultivaluedMap<String, String> headers = new MultivaluedMapImpl();
+ MultivaluedMap<String, String> headers = new MultivaluedHashMap<>();
headers.put("x-authorization", Arrays.asList(credentials));
return restClient.post(url, payload, headers, MediaType.APPLICATION_JSON_TYPE, MediaType.APPLICATION_JSON_TYPE);
}
-
/**
* JSON serializable class representing an instance sent to data-dictionary.
*/
private Object instance;
public Request(COMMON_MODEL_ELEMENT_TYPE cmeType, String attributeName, String attributeValue) {
- switch(cmeType) {
+ switch (cmeType) {
case INSTANCE:
Map<String, String> map = new HashMap<>();
map.put(attributeName, attributeValue);
--- /dev/null
+/**
+ * ============LICENSE_START===================================================
+ * 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
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=====================================================
+ */
+package org.onap.aai.validation;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+/**
+ * Invoke the Spring Boot Application (primarily for code coverage).
+ *
+ */
+public class TestApplication {
+
+ @Rule
+ public ExpectedException expectedEx = ExpectedException.none();
+
+ @Before
+ public void init() {
+ System.setProperty("CONFIG_HOME", "src/test/resources/model-validation/instance-validator");
+ System.setProperty("APP_HOME", ".");
+ System.clearProperty("KEY_STORE_PASSWORD");
+ }
+
+ @Test
+ public void testApplicationWithNullArgs() {
+ System.setProperty("KEY_STORE_PASSWORD", "test");
+ expectedEx.expect(IllegalArgumentException.class);
+ expectedEx.expectMessage("Args must not be null");
+ ValidationServiceApplication.main(null);
+ }
+
+}
# ============LICENSE_START===================================================
-# Copyright (c) 2018 Amdocs
+# 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.
httpProtocol=file
baseModelURI=src/test/resources/model-validation/instance-validator/all-models.xml
-# the following fields are autowired but will never be used
+# the following fields are autowired into the REST client, but this bean will not be invoked
host=
port=
trustStorePath=
keyManagerFactoryAlgorithm=
keyStoreType=
securityProtocol=
-connectionTimeout=
-readTimeout=
+connectionTimeout=0
+readTimeout=0
--- /dev/null
+# ============LICENSE_START===================================================
+# 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
+#
+# 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=====================================================
+
+rule.datadictionary.hostport=localhost:8080
+rule.datadictionary.connect.timeout=0
+rule.datadictionary.read.timeout=0
--- /dev/null
+# ============LICENSE_START===================================================
+# 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
+#
+# 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=====================================================
+
+rule.indexing.events=POA-EVENT
+rule.indexing.exclude.oxm.validation=POA-EVENT
+rule.indexing.key.attributes=$.poa-event.modelVersionId,$.poa-event.modelInvariantId
+rule.indexing.default.key=default-rules
--- /dev/null
+# ============LICENSE_START===================================================
+# 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
+#
+# 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=====================================================
+
+# Test properties for the org.onap.aai.setup.SchemaLocationsBean
+schemaConfig=NA
+nodeDir=src/test/resources/oxm-reader/single/
+edgeDir=src/test/resources/oxm-reader/single/
\ No newline at end of file
--- /dev/null
+# ============LICENSE_START===================================================
+# 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
+#
+# 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=====================================================
+
+poa-audit-result.name=POA-AUDIT-RESULT
+poa-audit-result.host=message-router:3904
+poa-audit-result.publisher.partition=1
+poa-audit-result.username=
+poa-audit-result.password=
+poa-audit-result.transport.type=HTTPAUTH
--- /dev/null
+# ============LICENSE_START===================================================
+# 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
+#
+# 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=====================================================
+
+poa-rule-validation.name=POA-RULE-VALIDATION
+poa-rule-validation.host=message-router:3904
+poa-rule-validation.username=
+poa-rule-validation.password=
+poa-rule-validation.consumer.group=poa-validator-test
+poa-rule-validation.consumer.id=test
+poa-rule-validation.transport.type=HTTPAUTH
--- /dev/null
+# ============LICENSE_START===================================================
+# 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
+#
+# 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=====================================================
+
+auth.policy.file=appconfig-local/auth/auth_policy.json
+auth.authentication.disable=false
\ No newline at end of file