diff options
author | mark.j.leonard <mark.j.leonard@gmail.com> | 2019-02-18 16:03:02 +0000 |
---|---|---|
committer | Tian Lee <TianL@amdocs.com> | 2019-02-19 11:36:00 +0000 |
commit | d234dc1544375a38437c207db757274081d99a89 (patch) | |
tree | 0313271687a36a3ebf3e0bfc9843191bcb0604af /src | |
parent | 4b005ff11a6321d92340228cb10de717880db448 (diff) |
Remove unused test configuration files
Also fix some checkstyle warnings regarding Javadoc comments.
Issue-ID: AAI-2057
Change-Id: If654c63ec6a5f9888fdf597e51ad0cad9f363a90
Signed-off-by: mark.j.leonard <mark.j.leonard@gmail.com>
Diffstat (limited to 'src')
30 files changed, 351 insertions, 300 deletions
diff --git a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java index 8181b43..41306b2 100644 --- a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.java +++ b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuth.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. @@ -38,7 +38,7 @@ public class AAIMicroServiceAuth { /** * @param validationServiceAuthConfig * @throws AAIAuthException - * if the policy file cannot be loaded + * if the policy file cannot be loaded */ @Inject public AAIMicroServiceAuth(final ValidationServiceAuthConfig validationServiceAuthConfig) throws AAIAuthException { @@ -49,10 +49,33 @@ public class AAIMicroServiceAuth { } } + /** + * Check whether the given user may access the give function. + * + * @param username + * user to be authorized + * @param authFunction + * function the user wishes to access + * @return true if the user is authorized to access the function, false otherwsie + * @throws AAIAuthException + * if the auth object has not been initialized + */ public boolean authBasic(String username, String authFunction) throws AAIAuthException { return authCore.authorize(username, authFunction); } + + /** + * Check whether the given user may access the give function. + * + * @param username + * user to be authorized + * @param authFunction + * function the user wishes to access + * @return true if the user is authorized to access the function, false otherwsie + * @throws AAIAuthException + * if the auth object has not been initialized + */ public String authUser(String authUser, String authFunction) throws AAIAuthException { StringBuilder username = new StringBuilder(); diff --git a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java index 681d0ea..63c1d6e 100644 --- a/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java +++ b/src/main/java/org/onap/aai/auth/AAIMicroServiceAuthCore.java @@ -63,7 +63,8 @@ public class AAIMicroServiceAuthCore { /** * @param authPolicyFile - * @throws AAIAuthException if the policy file cannot be loaded + * @throws AAIAuthException + * if the policy file cannot be loaded */ public void init(String authPolicyFile) throws AAIAuthException { try { @@ -218,6 +219,17 @@ public class AAIMicroServiceAuthCore { } } + /** + * Check whether the given user may access the give function. + * + * @param username + * user to be authorized + * @param authFunction + * function the user wishes to access + * @return true if the user is authorized to access the function, false otherwsie + * @throws AAIAuthException + * of the auth object has not been initialized + */ public boolean authorize(String username, String authFunction) throws AAIAuthException { if (!usersInitialized || users == null) { throw new AAIAuthException("Auth module not initialized"); diff --git a/src/main/java/org/onap/aai/validation/config/TopicConfig.java b/src/main/java/org/onap/aai/validation/config/TopicConfig.java index f95a357..0db4e8e 100644 --- a/src/main/java/org/onap/aai/validation/config/TopicConfig.java +++ b/src/main/java/org/onap/aai/validation/config/TopicConfig.java @@ -1,19 +1,22 @@ -/* - * ============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.config; @@ -31,11 +34,9 @@ import org.springframework.beans.factory.annotation.Value; /** * Gets the configuration of the topics using Spring. */ - public class TopicConfig { private List<String> consumerTopicNames; - private List<String> publisherTopicNames; @Resource(name = "topicProperties") @@ -60,7 +61,6 @@ public class TopicConfig { return populateTopics(consumerTopics, consumerTopicNames); } - /** * Gets the configuration of topics for publishing. * @@ -74,9 +74,9 @@ public class TopicConfig { * Populates the topics list with topic objects created from each item in the topicNames list. * * @param topics - * The topic list to populate. + * The topic list to populate. * @param topicNames - * The list of topic names to populate the topic list with. + * The list of topic names to populate the topic list with. * @return The populated topic list. */ private List<Topic> populateTopics(List<Topic> topics, List<String> topicNames) { diff --git a/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java b/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java index 2990e31..518752a 100644 --- a/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java +++ b/src/main/java/org/onap/aai/validation/factory/DMaaPEventPublisherFactory.java @@ -18,12 +18,11 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.onap.aai.validation.factory; import org.onap.aai.event.client.DMaaPEventPublisher; -public class DMaaPEventPublisherFactory { +public class DMaaPEventPublisherFactory { public DMaaPEventPublisher createEventPublisher(String topicHost, String topicName, String topicUsername, String topicPassword, String transportType, String protocol) { diff --git a/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java b/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java index 4b0b583..71ebadb 100644 --- a/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java +++ b/src/main/java/org/onap/aai/validation/publisher/ValidationEventPublisher.java @@ -36,7 +36,7 @@ import org.onap.aai.validation.logging.ApplicationMsgs; import org.onap.aai.validation.logging.LogHelper; /** - * Event Publisher + * Event Publisher. * */ public class ValidationEventPublisher implements MessagePublisher { diff --git a/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java b/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java index d8cd61e..93902c0 100644 --- a/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java +++ b/src/main/java/org/onap/aai/validation/ruledriven/rule/GroovyRule.java @@ -70,13 +70,15 @@ public class GroovyRule implements Rule { /** * @param ruleConfig + * @throws GroovyConfigurationException + * if the Groovy expression cannot be compiled + * @throws IOException + * if the Groovy class loader throws an internal exception * @throws InstantiationException * @throws IllegalAccessException - * @throws IOException - * @throws GroovyConfigurationException */ public GroovyRule(RuleSection ruleConfig) - throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { + throws GroovyConfigurationException, IOException, InstantiationException, IllegalAccessException { setName(ruleConfig.getName()); setErrorCategory(ruleConfig.getCategory()); setErrorMessage(ruleConfig.getErrorMessage()); @@ -142,7 +144,8 @@ public class GroovyRule implements Rule { * * @param values * - * @param groovyObject an instance/object of a Groovy class that implements one or more rule methods + * @param groovyObject + * an instance/object of a Groovy class that implements one or more rule methods * @return the result of evaluating the expression */ @Override @@ -222,20 +225,26 @@ public class GroovyRule implements Rule { } /** - * @param fields + * Create an anonymous Java Class implementing a Groovy Rule method for the supplied attributes and rule expression. + * + * @param attributes + * the attributes that form the parameters of the Groovy method * @param expression - * @return - * @throws IOException + * a valid Groovy method expression (implementing a rule) + * @return the Java Class for accessing the Groovy method * @throws GroovyConfigurationException + * if the Groovy expression cannot be compiled + * @throws IOException + * if the Groovy class loader throws an internal exception */ - private Class<?> createRule(List<String> fields, String expression) - throws IOException, GroovyConfigurationException { + private Class<?> createRule(List<String> attributes, String expression) + throws GroovyConfigurationException, IOException { originalExpression = expression; groovyExpression = expression; String methodParams = ""; int i = 1; - for (String attribute : fields) { + for (String attribute : attributes) { if (isValidAttributeName(attribute)) { String fieldName = "field" + i++; methodParams = appendParameter(methodParams, fieldName); @@ -295,20 +304,23 @@ public class GroovyRule implements Rule { } /** - * Load and parse a Groovy script to create an anonymous class + * Load and parse a Groovy script to create an anonymous Java Class. * - * @param script a file containing the Groovy scripting language - * @return the Java Class for accessing the Groovy methods - * @throws IOException + * @param script + * valid Groovy content (for the class) + * @return the Java Class for accessing the Groovy script * @throws GroovyConfigurationException + * if the Groovy script cannot be compiled + * @throws IOException + * if the Groovy class loader throws an internal exception */ @SuppressWarnings("rawtypes") - private static Class loadGroovyClass(String expression) throws IOException, GroovyConfigurationException { + private static Class loadGroovyClass(String script) throws GroovyConfigurationException, IOException { ClassLoader parent = GroovyRule.class.getClassLoader(); GroovyClassLoader loader = new GroovyClassLoader(parent); Class groovyClass; try { - groovyClass = loader.parseClass(expression); + groovyClass = loader.parseClass(script); } catch (CompilationFailedException e) { throw new GroovyConfigurationException(e); } finally { diff --git a/src/main/java/org/onap/aai/validation/services/EventPollingService.java b/src/main/java/org/onap/aai/validation/services/EventPollingService.java index bc0c260..332e283 100644 --- a/src/main/java/org/onap/aai/validation/services/EventPollingService.java +++ b/src/main/java/org/onap/aai/validation/services/EventPollingService.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.services; import com.google.common.collect.Iterables; diff --git a/src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.java b/src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.java index 7217224..1b1a5bb 100644 --- a/src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.java +++ b/src/test/java/org/onap/aai/validation/auth/MicroServiceAuthTest.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, @@ -40,10 +40,11 @@ import org.mockito.Mockito; import org.onap.aai.auth.AAIAuthException; import org.onap.aai.auth.AAIMicroServiceAuth; import org.onap.aai.validation.config.ValidationServiceAuthConfig; +import org.onap.aai.validation.test.util.TestUtil; import org.springframework.mock.web.MockHttpServletRequest; /** - * Tests @{link AAIMicroServiceAuth} + * Tests @{link AAIMicroServiceAuth}. */ public class MicroServiceAuthTest { @@ -59,24 +60,25 @@ public class MicroServiceAuthTest { * of a policy file that does not exist. * * @throws AAIAuthException - * @throws IOException + * if the authorization policy file cannot be loaded */ @Test(expected = AAIAuthException.class) - public void missingPolicyFile() throws AAIAuthException, IOException { + public void missingPolicyFile() throws AAIAuthException { ValidationServiceAuthConfig authConfig = new ValidationServiceAuthConfig(); authConfig.setAuthPolicyFile("invalid.file.name"); new AAIMicroServiceAuth(authConfig); } /** - * Test loading of a temporary file created with the specified roles + * Test loading of a temporary file created with the specified roles. * - * @throws AAIAuthException * @throws IOException - * @throws JSONException + * if the policy file could not be written + * @throws AAIAuthException + * if the policy file cannot be loaded */ @Test - public void createLocalAuthFile() throws AAIAuthException, IOException, JSONException { + public void createLocalAuthFile() throws AAIAuthException, IOException { JSONObject roles = createRoleObject("role", createUserObject("user"), createFunctionObject("func")); AAIMicroServiceAuth auth = createAuthService(roles); assertThat(auth.authUser("nosuchuser", "method:func"), is(equalTo("AAI_9101"))); @@ -84,9 +86,10 @@ public class MicroServiceAuthTest { } /** - * Test loading of the policy file relative to CONFIG_HOME + * Test loading of the policy file relative to CONFIG_HOME. * * @throws AAIAuthException + * if the policy file cannot be loaded */ @Test public void createAuth() throws AAIAuthException { @@ -128,7 +131,7 @@ public class MicroServiceAuthTest { servletRequest.setScheme("https"); servletRequest.setServerPort(9501); servletRequest.setServerName("localhost"); - servletRequest.setRequestURI("/services/validation-service/v1/app/validate"); + servletRequest.setRequestURI(TestUtil.VALIDATION_SERVICE_URL); X509Certificate mockCertificate = Mockito.mock(X509Certificate.class); Mockito.when(mockCertificate.getSubjectX500Principal()) @@ -139,6 +142,13 @@ public class MicroServiceAuthTest { return servletRequest; } + /** + * Create a new auth object using the standard policy JSON + * + * @return a new auth object + * @throws AAIAuthException + * if the policy file cannot be loaded + */ private AAIMicroServiceAuth createStandardAuth() throws AAIAuthException { ValidationServiceAuthConfig authConfig = new ValidationServiceAuthConfig(); authConfig.setAuthPolicyFile(authPolicyFile); @@ -146,13 +156,15 @@ public class MicroServiceAuthTest { } /** - * @param rolesJson - * @return + * @param roles + * @return a new auth object (to be tested) * @throws IOException + * if the policy file could not be written * @throws AAIAuthException + * if the policy file cannot be loaded + * */ private AAIMicroServiceAuth createAuthService(JSONObject roles) throws IOException, AAIAuthException { - ValidationServiceAuthConfig authConfig = new ValidationServiceAuthConfig(); File file = File.createTempFile("auth-policy", "json"); file.deleteOnExit(); FileWriter fileWriter = new FileWriter(file); @@ -160,15 +172,18 @@ public class MicroServiceAuthTest { fileWriter.flush(); fileWriter.close(); + ValidationServiceAuthConfig authConfig = new ValidationServiceAuthConfig(); authConfig.setAuthPolicyFile(file.getAbsolutePath()); return new AAIMicroServiceAuth(authConfig); } /** - * Assert authorisation results for an admin user based on the test policy file + * Assert authorisation results for an admin user based on the test policy file. * * @param auth + * the auth object * @param adminUser + * the admin user name * @throws AAIAuthException */ private void assertAdminUserAuthorisation(AAIMicroServiceAuth auth, String adminUser) throws AAIAuthException { @@ -203,10 +218,7 @@ public class MicroServiceAuthTest { return usersArray; } - private JSONObject createRoleObject(String roleName, JSONArray usersArray, JSONArray functionsArray) - throws JSONException { - JSONObject roles = new JSONObject(); - + private JSONObject createRoleObject(String roleName, JSONArray usersArray, JSONArray functionsArray) { JSONObject role = new JSONObject(); role.put("name", roleName); role.put("functions", functionsArray); @@ -214,6 +226,8 @@ public class MicroServiceAuthTest { JSONArray rolesArray = new JSONArray(); rolesArray.put(role); + + JSONObject roles = new JSONObject(); roles.put("roles", rolesArray); return roles; diff --git a/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java b/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java index f323331..256b78a 100644 --- a/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java +++ b/src/test/java/org/onap/aai/validation/config/TestTopicConfig.java @@ -18,7 +18,6 @@ * limitations under the License. * ============LICENSE_END========================================================= */ - package org.onap.aai.validation.config; import static org.hamcrest.Matchers.containsInAnyOrder; @@ -40,8 +39,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @SpringBootTest @RunWith(SpringJUnit4ClassRunner.class) @Import(TopicPropertiesConfig.class) -@TestPropertySource(locations = { "classpath:test-application.properties" }) -@ContextConfiguration(locations = { "classpath:topic-config/test-validation-service-beans.xml" }) +@TestPropertySource(locations = {"classpath:test-application.properties"}) +@ContextConfiguration(locations = {"classpath:topic-config/test-validation-service-beans.xml"}) public class TestTopicConfig { static { @@ -75,6 +74,7 @@ public class TestTopicConfig { eventTopic.setConsumerGroup("event-dummy-consumer-group"); eventTopic.setConsumerId("event-dummy-consumer-id"); eventTopic.setTransportType("event-dummy-transport-type"); + eventTopic.setProtocol("event-dummy-protocol-type"); Topic exportTopic = new TopicConfig("aai-data-export", "aai-data-integrity").new Topic(); exportTopic.setName("aai-data-export"); @@ -99,6 +99,7 @@ public class TestTopicConfig { integrityTopic.setUsername("integrity-dummy-username"); integrityTopic.setPassword("integrity-dummy-password"); integrityTopic.setTransportType("integrity-dummy-transport-type"); + integrityTopic.setProtocol("http"); List<Topic> publisherTopics = topicConfig.getPublisherTopics(); diff --git a/src/test/java/org/onap/aai/validation/logging/LogReader.java b/src/test/java/org/onap/aai/validation/logging/LogReader.java index 9faf0fb..77188bc 100644 --- a/src/test/java/org/onap/aai/validation/logging/LogReader.java +++ b/src/test/java/org/onap/aai/validation/logging/LogReader.java @@ -42,6 +42,15 @@ public class LogReader { cachedReader = getReader(logDirectory, logFilePrefix); } + /** + * @param logDirectory + * the directory containing all log files + * @param logFilePrefix + * the prefix to match + * @return a new buffered reader + * @throws IOException + * if an I/O error occurs when opening the log directory, or no files were found + */ private BufferedReader getReader(String logDirectory, String logFilePrefix) throws IOException { BufferedReader reader = new BufferedReader(new FileReader(getLogFile(logDirectory, logFilePrefix))); while (reader.readLine() != null) { @@ -51,15 +60,18 @@ public class LogReader { } /** + * Find the log file matching the given prefix. + * * @param logDirectory + * the directory containing all log files * @return the most recently created log file. * @throws IOException + * if an I/O error occurs when opening the log directory, or no files were found */ private File getLogFile(String logDirectory, String filenamePrefix) throws IOException { - Optional<Path> latestFilePath = Files.list(Paths.get(logDirectory)) - .filter(f -> Files.isDirectory(f) == false // - && f.getFileName().toString().startsWith(filenamePrefix) - && !f.getFileName().toString().endsWith(".zip")) + Optional<Path> latestFilePath = Files.list(Paths.get(logDirectory)).filter(f -> Files.isDirectory(f) == false // + && f.getFileName().toString().startsWith(filenamePrefix) + && !f.getFileName().toString().endsWith(".zip")) .max(Comparator.comparingLong(f -> f.toFile().lastModified())); if (latestFilePath.isPresent()) { cachedLog = latestFilePath.get(); 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 6aa6908..c31fceb 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,8 +71,9 @@ 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 + * if an I/O error occurs when opening the log directory, or no files were found */ @Test public void logAllMessages() throws IOException { @@ -97,8 +98,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 +110,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 +125,7 @@ public class TestApplicationLogger { /** * Check logAudit with HTTP headers - * + * * @throws IOException */ @Test @@ -156,7 +157,7 @@ public class TestApplicationLogger { /** * Check logAudit with no HTTP headers - * + * * @throws IOException */ @Test @@ -173,7 +174,7 @@ public class TestApplicationLogger { /** * Check logMetrics - * + * * @throws IOException */ @Test @@ -228,7 +229,7 @@ public class TestApplicationLogger { /** * Call a logger method which is expected to throw an UnsupportedOperationException - * + * * @param logMethod * @param dummyMsg */ @@ -244,7 +245,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/configuration/mapping/TestModelInstanceMapper.java b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestModelInstanceMapper.java index 7c820bb..d8e2a61 100644 --- a/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestModelInstanceMapper.java +++ b/src/test/java/org/onap/aai/validation/modeldriven/configuration/mapping/TestModelInstanceMapper.java @@ -1,20 +1,24 @@ -/* - * ============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.modeldriven.configuration.mapping; import static org.hamcrest.Matchers.is; @@ -24,9 +28,6 @@ import static org.junit.Assert.assertTrue; import java.util.ArrayList; import java.util.List; import org.junit.Test; -import org.onap.aai.validation.modeldriven.configuration.mapping.Filter; -import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper; -import org.onap.aai.validation.modeldriven.configuration.mapping.ValueConfiguration; import org.onap.aai.validation.modeldriven.configuration.mapping.ModelInstanceMapper.MappingType; public class TestModelInstanceMapper { diff --git a/src/test/java/org/onap/aai/validation/modeldriven/parser/TestXMLModelParser.java b/src/test/java/org/onap/aai/validation/modeldriven/parser/TestXmlModelParser.java index 3344193..4ba7fe5 100644 --- a/src/test/java/org/onap/aai/validation/modeldriven/parser/TestXMLModelParser.java +++ b/src/test/java/org/onap/aai/validation/modeldriven/parser/TestXmlModelParser.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.modeldriven.parser; @@ -30,9 +33,8 @@ import org.junit.Before; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.onap.aai.validation.modeldriven.parser.XMLModelParser; -public class TestXMLModelParser { +public class TestXmlModelParser { static { System.setProperty("APP_HOME", "."); @@ -54,7 +56,7 @@ public class TestXMLModelParser { } @Test - public void testParseXMLModelFile() throws Exception { + public void testParseXmlModelFile() throws Exception { assertEquals("Invalid model element name.", "model", modelElement.getName()); } @@ -82,9 +84,8 @@ public class TestXMLModelParser { List<Node> relatedNodes = XMLModelParser.getObjectsFromXPath(modelElement, relObjsXPath); assertEquals("Unexpected number of related objects.", 1, relatedNodes.size()); - Node relatedObjUUIDNode = relatedNodes.get(0).selectSingleNode("model-element-uuid"); - assertEquals("Unexpected related object UUID.", "71b825be-febf-45f7-b86a-ca0e3de19c90", - relatedObjUUIDNode.getText()); + Node relatedNode = relatedNodes.get(0).selectSingleNode("model-element-uuid"); + assertEquals("Unexpected related object UUID.", "71b825be-febf-45f7-b86a-ca0e3de19c90", relatedNode.getText()); } @Test 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 c2b66c5..4d076da 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 @@ -1,19 +1,22 @@ -/* - * ============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.modeldriven.validator; @@ -166,7 +169,6 @@ public class TestInstanceReader { JsonElement genericVnfJsonElement = jsonParser.parse(expectedGenericVnf); String expectedGenericVnf = genericVnfJsonElement.toString(); - // Method under test Multimap<String, String> values = instanceReader.getValues(connectorSibling, mapping); @@ -179,7 +181,6 @@ public class TestInstanceReader { // Method under test values = instanceReader.getValues(logicalLinkInstance, mapping); - assertThat(values.get("generic-vnf").iterator().next(), is(equalTo(expectedGenericVnf))); assertThat(values.get("pserver").iterator().next(), is(equalTo(jsonParser.parse(expectedPserver).toString()))); } @@ -226,14 +227,12 @@ public class TestInstanceReader { @Test public void testGetResourceVersion() throws Exception { String resourceVersion = instanceReader.getResourceVersion(connector); - assertThat(resourceVersion, is("1467975776")); } private static ModelInstanceMapper getMapping(String mappingFileName) throws Exception { JSONArray jsonArray = new JSONArray(TestUtil.getFileAsString(mappingFileName)); JSONObject jsonObject = jsonArray.getJSONObject(0); - return JsonUtil.fromJson(jsonObject.toString(), ModelInstanceMapper.class); } } 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 1d3e6d2..844c010 100644 --- a/src/test/java/org/onap/aai/validation/reader/TestEventReader.java +++ b/src/test/java/org/onap/aai/validation/reader/TestEventReader.java @@ -1,19 +1,22 @@ -/* - * ============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.reader; @@ -269,7 +272,9 @@ public class TestEventReader { public void testEntityLinkIsStripped() throws Exception { Entity entity = eventReader.getEntity(vserverEvent); String entityLink = entity.getEntityLink(); - assertThat(entityLink, is( - "cloud-infrastructure/cloud-regions/cloud-region/region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666")); + assertThat(entityLink, + is("cloud-infrastructure/cloud-regions/cloud-region/" + + "region1/AAIregion1/tenants/tenant/example-tenant-id-val-88551/" + + "vservers/vserver/example-vserver-id-val-34666")); } } 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 3462418..7ce0b34 100644 --- a/src/test/java/org/onap/aai/validation/result/TestValidationResult.java +++ b/src/test/java/org/onap/aai/validation/result/TestValidationResult.java @@ -1,19 +1,22 @@ /** - * ============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.result; @@ -198,14 +201,14 @@ public class TestValidationResult { Map<String, Object> violationDetails = new HashMap<>(); //@formatter:off - Violation violation = new Violation.Builder(entity) - .category("category") - .severity("severity") - .violationType("violationType") - .violationDetails(violationDetails) - .errorMessage("errorMessage") - .build(); - //@formatter:on + Violation violation = new Violation.Builder(entity) + .category("category") + .severity("severity") + .violationType("violationType") + .violationDetails(violationDetails) + .errorMessage("errorMessage") + .build(); + //@formatter:on validationResult.addViolation(violation); assertThat(validationResult, is(not(equalTo(other)))); @@ -385,14 +388,14 @@ public class TestValidationResult { ValidationResult validationResult = new ValidationResultBuilder(eventReader, vserverEvent).build(); //@formatter:off - Violation violation = new Violation.Builder(entity) - .category("category") - .severity("severity") - .violationType("violationType") - .violationDetails(violationDetails) - .errorMessage("errorMessage") - .build(); - //@formatter:on + Violation violation = new Violation.Builder(entity) + .category("category") + .severity("severity") + .violationType("violationType") + .violationDetails(violationDetails) + .errorMessage("errorMessage") + .build(); + //@formatter:on validationResult.addViolation(violation); @@ -411,8 +414,10 @@ public class TestValidationResult { assertThat(validationResult.getEntityId(), is(expectedEntityId)); assertThat(validationResult.getEntityType(), is("vserver")); assertThat(validationResult.getResourceVersion(), is("1464193654")); - assertThat(validationResult.getEntityLink(), is("cloud-infrastructure/cloud-regions/cloud-region/region1/" - + "AAIregion1/tenants/tenant/example-tenant-id-val-88551/vservers/vserver/example-vserver-id-val-34666")); + assertThat(validationResult.getEntityLink(), + is("cloud-infrastructure/cloud-regions/cloud-region/region1/" + + "AAIregion1/tenants/tenant/example-tenant-id-val-88551" + + "/vservers/vserver/example-vserver-id-val-34666")); } private Violation assertThatViolationIsValid(ValidationResult validationResult, Violation expectedViolation) { diff --git a/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.java b/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.java index 1f87ca0..0b865c9 100644 --- a/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.java +++ b/src/test/java/org/onap/aai/validation/ruledriven/configuration/ConfigFileBuilder.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.ruledriven.configuration; @@ -26,8 +29,6 @@ import java.util.Properties; import org.junit.rules.TemporaryFolder; import org.onap.aai.cl.api.Logger; import org.onap.aai.validation.logging.LogHelper; -import org.onap.aai.validation.ruledriven.configuration.EntitySection; -import org.onap.aai.validation.ruledriven.configuration.RulesConfigurationLoader; import org.onap.aai.validation.ruledriven.configuration.build.ContentBuilder; import org.onap.aai.validation.ruledriven.configuration.build.EntityBuilder; import org.onap.aai.validation.ruledriven.configuration.build.RuleBuilder; 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 5b0e66b..d0a6dce 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 @@ -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, @@ -135,7 +135,7 @@ public class TestRuleExecution { * Test for "vserver is related to vpe and vserver-name contains me6". * * @throws Exception - * if the rule expression in this test is invalid + * if the rule expression in this test is invalid */ @Test public void testConditionalRegExp() throws Exception { @@ -266,7 +266,7 @@ public class TestRuleExecution { } /** - * location_clli is 8 or 11 characters and must be characters only + * location_clli is 8 or 11 characters and must be characters only. */ @Test public void testStringLengthAndChars() throws Exception { @@ -537,18 +537,6 @@ public class TestRuleExecution { return new GroovyRule(ruleConfig); } - private GroovyRule buildRuleWithErrorMessage(String name, String attribute, String expression, String errorMessage) - throws IOException, InstantiationException, IllegalAccessException, GroovyConfigurationException { - RuleSection ruleConfig = new RuleSection(); - ruleConfig.setName(name); - ruleConfig.setAttributes(Collections.singletonList(attribute)); - ruleConfig.setExpression(expression); - if(errorMessage != null) { - ruleConfig.setErrorMessage(errorMessage); - } - return new GroovyRule(ruleConfig); - } - /** * Build a simple rule (with a default name) using a RuleConfiguration object * @@ -579,6 +567,18 @@ public class TestRuleExecution { return buildRule("testRule", attributes, expression); } + private GroovyRule buildRuleWithErrorMessage(String name, String attribute, String expression, String errorMessage) + throws IOException, InstantiationException, IllegalAccessException, GroovyConfigurationException { + RuleSection ruleConfig = new RuleSection(); + ruleConfig.setName(name); + ruleConfig.setAttributes(Collections.singletonList(attribute)); + ruleConfig.setExpression(expression); + if (errorMessage != null) { + ruleConfig.setErrorMessage(errorMessage); + } + return new GroovyRule(ruleConfig); + } + private GroovyRule buildRuleWithErrorMessage(String attribute, String expression, String errorText) throws InstantiationException, IllegalAccessException, IOException, GroovyConfigurationException { return buildRuleWithErrorMessage("testRule", attribute, expression, errorText); 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 b881804..325dff2 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 @@ -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.ruledriven.rule; @@ -215,7 +218,7 @@ public class TestRuleValidation { } /** - * Utility to build a rule and test that the attribute is valid + * Utility to build a rule and test that the attribute passed to it is valid. * * @param attribute * attribute (field) identifier diff --git a/src/test/java/org/onap/aai/validation/services/TestInfoService.java b/src/test/java/org/onap/aai/validation/services/TestInfoService.java index f99748a..c975d16 100644 --- a/src/test/java/org/onap/aai/validation/services/TestInfoService.java +++ b/src/test/java/org/onap/aai/validation/services/TestInfoService.java @@ -47,8 +47,8 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @SpringBootTest @RunWith(SpringJUnit4ClassRunner.class) -@TestPropertySource(locations = { "classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties" }) -@ContextConfiguration(locations = { "classpath:/info-service/test-validation-service-beans.xml" }) +@TestPropertySource(locations = {"classpath:oxm-reader/schemaIngest.properties", "classpath:application.properties"}) +@ContextConfiguration(locations = {"classpath:/info-service/test-validation-service-beans.xml"}) public class TestInfoService { static { @@ -56,9 +56,7 @@ public class TestInfoService { } enum TestData { - VSERVER( - "rule-driven-validator/test_events/vserver-create-event.json" - ); + VSERVER("rule-driven-validator/test_events/vserver-create-event.json"); private String filename; @@ -117,7 +115,6 @@ public class TestInfoService { assertThat(info, containsString("errored=1")); } - @Test public void testVserverEventRecorded() throws URISyntaxException, IOException { Path vserverTestFile = Paths.get(ClassLoader.getSystemResource(TestData.VSERVER.getFilename()).toURI()); 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 f1cdce6..d1e538f 100644 --- a/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.java +++ b/src/test/java/org/onap/aai/validation/services/TestValidateServiceImpl.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.services; @@ -22,7 +25,6 @@ import static org.hamcrest.CoreMatchers.notNullValue; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertThat; -import java.net.URISyntaxException; import java.security.cert.X509Certificate; import java.util.Collections; import java.util.List; @@ -34,7 +36,7 @@ import org.junit.Test; import org.mockito.Mockito; import org.onap.aai.auth.AAIMicroServiceAuth; import org.onap.aai.validation.controller.ValidationController; -import org.onap.aai.validation.services.ValidateServiceImpl; +import org.onap.aai.validation.test.util.TestUtil; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -72,15 +74,10 @@ public class TestValidateServiceImpl { } /** - * Create a (mocked) HTTPS request and invoke the Babel generate artifacts API - * - * @param request - * for the Babel Service - * @return the Response from the HTTP API - * @throws URISyntaxException + * Create a (mocked) HTTPS request and invoke the Validation Service API. */ @Test - public void testRequestWithHeaders() throws URISyntaxException { + public void testRequestWithHeaders() { // Create mocked request headers map MultivaluedHashMap<String, String> headersMap = new MultivaluedHashMap<>(); headersMap.put("X-TransactionId", createSingletonList("transaction-id")); @@ -97,7 +94,7 @@ public class TestValidateServiceImpl { servletRequest.setScheme("https"); servletRequest.setServerPort(9501); servletRequest.setServerName("localhost"); - servletRequest.setRequestURI("/services/validation-service/v1/app/validate"); + servletRequest.setRequestURI(TestUtil.VALIDATION_SERVICE_URL); X509Certificate mockCertificate = Mockito.mock(X509Certificate.class); Mockito.when(mockCertificate.getSubjectX500Principal()) diff --git a/src/test/java/org/onap/aai/validation/test/util/TestEntity.java b/src/test/java/org/onap/aai/validation/test/util/TestEntity.java index b94a875..6c35cf4 100644 --- a/src/test/java/org/onap/aai/validation/test/util/TestEntity.java +++ b/src/test/java/org/onap/aai/validation/test/util/TestEntity.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.test.util; @@ -32,6 +35,18 @@ public class TestEntity { public File inputFile; public String expectedResultsFile; + /** + * Create a new test entity. + * + * @param root + * the top-level folder for the test suite + * @param inputFilePath + * the path to the input file to be tested + * @param inputEventsPath + * the folder containing the input file(s) + * @param outputEventsPath + * the folder to write the outputs to + */ public TestEntity(Path root, Path inputFilePath, String inputEventsPath, String outputEventsPath) { String rootUri = root.toUri().toString(); String resultsRoot = rootUri.replaceAll(inputEventsPath + "/$", outputEventsPath + "/"); 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 40fa4de..c70e2ab 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 @@ -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.test.util; @@ -31,6 +34,8 @@ import java.nio.file.Paths; */ public class TestUtil { + public static final String VALIDATION_SERVICE_URL = "/services/validation-service/v1/app/validate"; + /** * Gets files, such as test data from the classpath. * diff --git a/src/test/resources/info-service/test-validation-service-beans.xml b/src/test/resources/info-service/test-validation-service-beans.xml index d1c6ace..8b8fcd9 100644 --- a/src/test/resources/info-service/test-validation-service-beans.xml +++ b/src/test/resources/info-service/test-validation-service-beans.xml @@ -1,20 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -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===================================================== + + ============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 + + 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========================================================= + --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" @@ -37,7 +42,7 @@ limitations under the License. <bean id="topicAdminConfig" class="org.onap.aai.validation.config.TopicAdminConfig" /> <bean id="validationControllerConfig" class="org.onap.aai.validation.config.ValidationControllerConfig" /> <bean id="mappingFile" class="org.apache.commons.io.IOUtils" factory-method="toString"> - <constructor-arg value="file:src/test/resources/model-instance-mapping.json_conf" type="java.io.InputStream" /> + <constructor-arg value="file:src/test/resources/model-validation/model-instance-mapping.json_conf" type="java.io.InputStream" /> </bean> <bean id="modelConfig" class="org.onap.aai.validation.config.ModelConfig"> <property name="modelCacheExpirySeconds" value="${model.cache.expirySeconds}" /> diff --git a/src/test/resources/model-instance-mapping.json_conf b/src/test/resources/model-validation/model-instance-mapping.json_conf index 12d39ea..12d39ea 100644 --- a/src/test/resources/model-instance-mapping.json_conf +++ b/src/test/resources/model-validation/model-instance-mapping.json_conf diff --git a/src/test/resources/topic-config/test-topic-config-beans.xml b/src/test/resources/topic-config/test-topic-config-beans.xml deleted file mode 100644 index 0466f81..0000000 --- a/src/test/resources/topic-config/test-topic-config-beans.xml +++ /dev/null @@ -1,49 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -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===================================================== ---> - -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - - <!-- TOPIC NAMES --> - <bean id="topicConfig" class="org.onap.aai.validation.config.TopicConfig"> - <property name="consumerTopicNames"> - <list> - <value>aai-event</value> - <value>aai-data-export</value> - </list> - </property> - <property name="publisherTopicNames"> - <list> - <value>aai-data-integrity</value> - </list> - </property> - </bean> - - <!-- DEFINE THE TOPIC PROPERTY FILES. Naming convention: topic-[topic name].properties. Each property must be pre-fixed with [topic name] --> - <bean id="topicProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> - <property name="locations"> - <list> - <value>classpath:topic-config/topic-aai-event.properties</value> - <value>classpath:topic-config/topic-aai-data-export.properties</value> - <value>classpath:topic-config/topic-aai-data-integrity.properties</value> - </list> - </property> - </bean> -</beans>
\ No newline at end of file diff --git a/src/test/resources/topic-config/test-validation-service-beans.xml b/src/test/resources/topic-config/test-validation-service-beans.xml index 9d880a3..ad7ad1f 100644 --- a/src/test/resources/topic-config/test-validation-service-beans.xml +++ b/src/test/resources/topic-config/test-validation-service-beans.xml @@ -1,25 +1,12 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -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 +<beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation=" + http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"> - http://www.apache.org/licenses/LICENSE-2.0 + <bean class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor" /> -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===================================================== ---> - -<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"> - - <import resource="test-topic-config-beans.xml" /> + <bean id="topicConfig" class="org.onap.aai.validation.config.TopicConfig" /> </beans>
\ No newline at end of file diff --git a/src/test/resources/topic-config/topic-aai-data-integrity.properties b/src/test/resources/topic-config/topic-aai-data-integrity.properties index f5a5839..a8ca1ee 100644 --- a/src/test/resources/topic-config/topic-aai-data-integrity.properties +++ b/src/test/resources/topic-config/topic-aai-data-integrity.properties @@ -1,5 +1,5 @@ # ============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. @@ -19,4 +19,5 @@ aai-data-integrity.host=integrity-dummy-host aai-data-integrity.publisher.partition=integrity-dummy-partition aai-data-integrity.username=integrity-dummy-username aai-data-integrity.password=integrity-dummy-password -aai-data-integrity.transport.type=integrity-dummy-transport-type
\ No newline at end of file +aai-data-integrity.transport.type=integrity-dummy-transport-type +aai-data-integrity.protocol=http diff --git a/src/test/resources/topic-config/topic-aai-event.properties b/src/test/resources/topic-config/topic-aai-event.properties index 2779f13..72af926 100644 --- a/src/test/resources/topic-config/topic-aai-event.properties +++ b/src/test/resources/topic-config/topic-aai-event.properties @@ -1,5 +1,5 @@ # ============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. @@ -20,4 +20,5 @@ aai-event.username=event-dummy-username aai-event.password=event-dummy-password aai-event.consumer.group=event-dummy-consumer-group aai-event.consumer.id=event-dummy-consumer-id -aai-event.transport.type=event-dummy-transport-type
\ No newline at end of file +aai-event.transport.type=event-dummy-transport-type +aai-event.protocol=event-dummy-protocol-type
\ No newline at end of file diff --git a/src/test/resources/validation-result/test-validation-service-beans.xml b/src/test/resources/validation-result/test-validation-service-beans.xml index 9a67d0a..9237a22 100644 --- a/src/test/resources/validation-result/test-validation-service-beans.xml +++ b/src/test/resources/validation-result/test-validation-service-beans.xml @@ -1,22 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> <!-- -============LICENSE_START=================================================== -Copyright (c) 2018 Amdocs -============================================================================ -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===================================================== ---> + ============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 + + 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========================================================= + +--> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd |