diff options
20 files changed, 64 insertions, 672 deletions
@@ -23,21 +23,20 @@ <properties> <sitePath>/content/sites/site/org/onap/aai/sparky-be/${project.artifactId}/${project.version}</sitePath> <onap.nexus.url>https://nexus.onap.org</onap.nexus.url> - <portal.sdk.version>2.6.0</portal.sdk.version> - <spring.boot.version>2.1.12.RELEASE</spring.boot.version> + <portal.sdk.version>2.6.0</portal.sdk.version> - <sonar.jacoco.reportPath /> - <sonar.jacoco.itReportPath /> - <sonar.jacoco.reportMissing.force.zero /> + <sonar.jacoco.reportPath /> + <sonar.jacoco.itReportPath /> + <sonar.jacoco.reportMissing.force.zero /> - <jacoco.line.coverage.limit>0.90</jacoco.line.coverage.limit> - <jacoco.version>0.8.5</jacoco.version> - <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version> - <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> - <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths> - <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions> + <jacoco.line.coverage.limit>0.90</jacoco.line.coverage.limit> + <jacoco.version>0.8.5</jacoco.version> + <sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version> + <sonar.core.codeCoveragePlugin>jacoco</sonar.core.codeCoveragePlugin> + <sonar.coverage.jacoco.xmlReportPaths>${project.reporting.outputDirectory}/jacoco-ut/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths> + <sonar.exclusions>**/gen/**,**/generated-sources/**,**/yang-gen**,**/pax/**</sonar.exclusions> - <sonar.scanner.version>3.7.0.1746</sonar.scanner.version> + <sonar.scanner.version>3.7.0.1746</sonar.scanner.version> </properties> @@ -48,13 +47,6 @@ <artifactId>epsdk-fw</artifactId> <version>${portal.sdk.version}</version> </dependency> - <dependency> - <groupId>org.springframework.boot</groupId> - <artifactId>spring-boot-starter-parent</artifactId> - <version>${spring.boot.version}</version> - <type>pom</type> - <scope>import</scope> - </dependency> </dependencies> </dependencyManagement> diff --git a/sparkybe-onap-application/pom.xml b/sparkybe-onap-application/pom.xml index 21ddd12..55da4f2 100644 --- a/sparkybe-onap-application/pom.xml +++ b/sparkybe-onap-application/pom.xml @@ -26,6 +26,7 @@ <version.aai-schema>1.6.0</version.aai-schema> <sitePath>/content/sites/site/org/onap/aai/sparky-be/${project.artifactId}/${project.version}</sitePath> <nexusproxy>https://nexus.onap.org</nexusproxy> + <spring.boot.version>1.5.21.RELEASE</spring.boot.version> <shemaUnpackVersion>onap</shemaUnpackVersion> <!-- docker related properties --> <docker.image.name>sparky-be</docker.image.name> @@ -42,6 +43,13 @@ <dependencyManagement> <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>${spring.boot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> <!-- Camel BOM --> <dependency> <groupId>org.apache.camel</groupId> @@ -272,13 +280,13 @@ <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> - <version>20190722</version> + <scope>provided</scope> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> - <version>2.10.2</version> + <scope>provided</scope> </dependency> <dependency> @@ -343,6 +351,7 @@ <artifactId>hamcrest-library</artifactId> <scope>test</scope> </dependency> + </dependencies> <profiles> diff --git a/sparkybe-onap-service/pom.xml b/sparkybe-onap-service/pom.xml index f3dd245..842af2d 100644 --- a/sparkybe-onap-service/pom.xml +++ b/sparkybe-onap-service/pom.xml @@ -14,7 +14,6 @@ <properties> <java.version>1.8</java.version> - <version.jacoco.maven.plugin>0.7.9</version.jacoco.maven.plugin> <frontEndGroupdId>org.onap.aai</frontEndGroupdId> <frontEndArtifactId>sparky-fe</frontEndArtifactId> <frontEndVersion>1.3.0</frontEndVersion> @@ -22,16 +21,24 @@ <sslport>8000</sslport> <nexusproxy>https://nexus.onap.org</nexusproxy> <camel-spring-boot.version>2.21.1</camel-spring-boot.version> - <config-home>${basedir}/</config-home> + <config-home>${basedir}/</config-home> <version.aai.aai-schema-ingest>1.4.1</version.aai.aai-schema-ingest> <version.aai-schema>1.6.0</version.aai-schema> <sitePath>/content/sites/site/org/onap/aai/sparky-be/${project.artifactId}/${project.version}</sitePath> <onap.nexus.url>https://neexus.onap.org</onap.nexus.url> <jacoco.line.coverage.limit>0.55</jacoco.line.coverage.limit> + <spring.boot.version>1.5.22.RELEASE</spring.boot.version> </properties> <dependencyManagement> <dependencies> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>${spring.boot.version}</version> + <type>pom</type> + <scope>import</scope> + </dependency> <!-- Camel BOM --> <dependency> <groupId>org.apache.camel</groupId> @@ -243,17 +250,7 @@ some of the depedencies should probably have a scope of provided so they don't a </exclusion> </exclusions> </dependency> - <dependency> - <groupId>com.att.eelf</groupId> - <artifactId>eelf-core</artifactId> - <exclusions> <!--excluding transitive dependency coming from this artifact, as we would need powermock-api-mockito2--> - <exclusion> - <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito</artifactId> - </exclusion> - </exclusions> - <version>1.0.1-oss</version> - </dependency> + <dependency> <groupId>org.onap.aai</groupId> <artifactId>rest-client</artifactId> @@ -284,7 +281,6 @@ some of the depedencies should probably have a scope of provided so they don't a <dependency> <groupId>org.json</groupId> <artifactId>json</artifactId> - <version>20140107</version> <scope>provided</scope> </dependency> @@ -334,19 +330,14 @@ some of the depedencies should probably have a scope of provided so they don't a </dependency> <dependency> <groupId>org.powermock</groupId> - <artifactId>powermock-api-mockito2</artifactId> - <version>2.0.2</version> - </dependency> - <dependency> - <groupId>org.powermock</groupId> - <artifactId>powermock-module-javaagent</artifactId> + <artifactId>powermock-api-mockito</artifactId> <version>1.6.2</version> <scope>test</scope> </dependency> <dependency> <groupId>org.powermock</groupId> - <artifactId>powermock-core</artifactId> - <version>2.0.0</version> + <artifactId>powermock-module-javaagent</artifactId> + <version>1.6.2</version> <scope>test</scope> </dependency> <dependency> @@ -360,19 +351,13 @@ some of the depedencies should probably have a scope of provided so they don't a <artifactId>javax.inject</artifactId> <version>1</version> <scope>test</scope> - </dependency> + </dependency> <dependency> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-library</artifactId> <scope>test</scope> </dependency> - <dependency> - <groupId>org.hamcrest</groupId> - <artifactId>hamcrest-core</artifactId> - <version>1.3</version> - <scope>compile</scope> - </dependency> </dependencies> @@ -491,48 +476,6 @@ some of the depedencies should probably have a scope of provided so they don't a </executions> </plugin> --> - <plugin> - <groupId>org.jacoco</groupId> - <artifactId>jacoco-maven-plugin</artifactId> - <version>${version.jacoco.maven.plugin}</version> - <executions> - <execution> - <id>prepare-agent</id> - <goals> - <goal>prepare-agent</goal> - </goals> - </execution> - <execution> - <id>report</id> - <phase>package</phase> - <goals> - <goal>report</goal> - </goals> - </execution> - <execution> - <id>default-check</id> - <goals> - <goal>check</goal> - </goals> - <configuration> - <dataFile>${project.build.directory}/jacoco.exec</dataFile> - <rules> - <!-- implementation is needed only for Maven 2 --> - <rule implementation="org.jacoco.maven.RuleConfiguration"> - <element>BUNDLE</element> - <limits> - <limit implementation="org.jacoco.report.check.Limit"> - <counter>LINE</counter> - <value>COVEREDRATIO</value> - <minimum>${jacoco.line.coverage.limit}</minimum> - </limit> - </limits> - </rule> - </rules> - </configuration> - </execution> - </executions> - </plugin> <!-- <plugin> <groupId>org.codehaus.mojo</groupId> @@ -640,7 +583,7 @@ some of the depedencies should probably have a scope of provided so they don't a </plugins> </build> - + <distributionManagement> <repository> <id>ecomp-releases</id> diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java index 9529143..876db5d 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java @@ -34,7 +34,6 @@ import java.util.Set; import org.hamcrest.Matcher; import org.junit.Before; import org.junit.Test; -import org.mockito.ArgumentMatcher; import org.mockito.Matchers; import org.mockito.Mockito; import org.onap.aai.restclient.client.OperationResult; @@ -212,7 +211,7 @@ public class CrossEntityReferenceSynchronizerTest { } - private ArgumentMatcher<List<String>> listContainsValue(String expectedValue) { + private Matcher<List<String>> listContainsValue(String expectedValue) { return new StringCollectionContainsMatcher(expectedValue); } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationExceptionTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationExceptionTest.java deleted file mode 100644 index 8c7e60d..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationExceptionTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.dal.exception; - -import org.junit.Test; -import static org.junit.Assert.assertNotNull; -/** - * The Class ElasticSearchOperationException. - */ -public class ElasticSearchOperationExceptionTest extends Exception { - - @Test - public void elasticSearchOperationExceptionMultiArgsTest() { - new ElasticSearchOperationException("message", new Exception()); - } - - @Test - public void elasticSearchOperationExceptionSingleArgTest() { - new ElasticSearchOperationException("message"); - } - -} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java index 9a39cf3..42ea4a5 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java @@ -72,8 +72,5 @@ public class EcompSsoTest { assertNull(EcompSso.getCookie(request, testCookieName + "3")); } - @Test - public void validateEcompSso() { - EcompSso.validateEcompSso(Mockito.mock(HttpServletRequest.class)); - } + } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/config/PortalAuthenticationConfigTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/config/PortalAuthenticationConfigTest.java deleted file mode 100644 index 395aa37..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/config/PortalAuthenticationConfigTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.security.portal.config; - - - -import org.junit.Test; -import static org.junit.Assert.assertNotNull; - -/** - * Provides Portal authentication configuration. - */ -public class PortalAuthenticationConfigTest { - @Test - public void testGetTestPortalAuthenticationConfig() { - assertNotNull(PortalAuthenticationConfig.getInstance()); - } -}
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/task/PerformGizmoRetrievalTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/task/PerformGizmoRetrievalTest.java deleted file mode 100644 index 908bc22..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/task/PerformGizmoRetrievalTest.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.sync.task; - -import org.junit.Before; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.cl.eelf.LoggerFactory; -import org.onap.aai.restclient.client.OperationResult; -import org.onap.aai.sparky.dal.GizmoAdapter; -import org.onap.aai.sparky.dal.NetworkTransaction; -import org.onap.aai.sparky.logging.AaiUiMsgs; -import org.slf4j.MDC; - -import java.util.Map; -import java.util.function.Supplier; - -/* - * Consider abstraction the tasks into common elemnts, because most of them repeat a generic call - * flow pattern - */ - -/** - * The Class PerformActiveInventoryRetrieval. - */ -public class PerformGizmoRetrievalTest { - - - private NetworkTransaction txn; - private GizmoAdapter gizmoAdapter; - PerformGizmoRetrieval performGizmoRetrieval; - - @Before - public void init(){ - txn = Mockito.mock(NetworkTransaction.class); - gizmoAdapter = Mockito.mock(GizmoAdapter.class); - performGizmoRetrieval = new PerformGizmoRetrieval(txn,gizmoAdapter); - } - /* (non-Javadoc) - * @see java.util.function.Supplier#get() - */ - @Test - public void get() { - performGizmoRetrieval.get(); - } - -} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java index 6669dbc..4b86bb5 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java @@ -37,10 +37,10 @@ import org.onap.aai.cl.api.Logger; import org.onap.aai.cl.eelf.LoggerFactory; import org.onap.aai.restclient.client.OperationResult; import org.onap.aai.restclient.enums.RestAuthenticationMode; +import org.onap.aai.setup.SchemaVersion; import org.onap.aai.sparky.config.oxm.OxmModelLoader; import org.onap.aai.sparky.dal.GizmoAdapter; import org.onap.aai.sparky.dal.exception.ElasticSearchOperationException; -import org.onap.aai.sparky.dal.exception.ElasticSearchOperationExceptionTest; import org.onap.aai.sparky.dal.rest.RestClientConstructionException; import org.onap.aai.sparky.dal.rest.config.RestEndpointConfig; import org.onap.aai.sparky.logging.AaiUiMsgs; @@ -66,7 +66,7 @@ public class GizmoEntitySummarizer { */ public GizmoEntitySummarizer() - throws ElasticSearchOperationExceptionTest, IOException, RestClientConstructionException, ElasticSearchOperationException { + throws ElasticSearchOperationException, IOException, RestClientConstructionException { OxmModelAndProcessorHelper.API_VERSION_OVERRIDE = "v11"; @@ -240,7 +240,7 @@ public class GizmoEntitySummarizer { } public static void main(String[] args) - throws ElasticSearchOperationExceptionTest, IOException, RestClientConstructionException, ElasticSearchOperationException { + throws ElasticSearchOperationException, IOException, RestClientConstructionException { System.setProperty("CONFIG_HOME", "X:\\2018_dev\\OSEAAI\\gizmo_integration\\onap_sparky-be\\appconfig-local\\"); GizmoEntitySummarizer gizmoSummarizer = new GizmoEntitySummarizer(); diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/BaseMatcher.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/BaseMatcher.java deleted file mode 100644 index 2abf360..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/BaseMatcher.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.util; - - -import org.hamcrest.Description; -import org.hamcrest.SelfDescribing; -import org.hamcrest.StringDescription; -import org.mockito.ArgumentMatcher; - -public abstract class BaseMatcher<T> implements ArgumentMatcher<T>, SelfDescribing { - public BaseMatcher() { - } - - @Override - public void describeTo(Description var1){ - } - - public String toString() { - return StringDescription.toString(this); - } -} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java index 2d4a365..61bf5c2 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java @@ -23,15 +23,12 @@ package org.onap.aai.sparky.util; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.hamcrest.MatcherAssert.assertThat; -import java.io.File; -import java.io.IOException; -import java.nio.file.FileSystems; + import java.util.Properties; import org.junit.Before; import org.junit.Test; -import static org.junit.Assert.assertEquals; + public class ConfigHelperTest { private ConfigHelper configHelper; @@ -48,33 +45,11 @@ public class ConfigHelperTest { @Test public void updateValues() throws Exception { + assertNotNull(configHelper.getConfigWithPrefix("aai-ui", props)); assertFalse(configHelper.isEssDevModeEnabled()); assertNotNull(configHelper.getFilepath("sparky-aaui", false)); } - @Test - public void getFileContents() { - File file = new File(getClass().getClassLoader().getResource("configHelperTest.properties").getFile()); - try { - assertNotNull(ConfigHelper.getFileContents(file.getAbsolutePath())); - } catch (IOException e) { - e.printStackTrace(); - } - } - - @Test - public void loadConfig() throws Exception { - String separator = FileSystems.getDefault().getSeparator(); - assertEquals(3, ConfigHelper.loadConfig("target"+separator+"test-classes"+separator+"configHelperTest.properties").size()); - } - - @Test - public void propertyFetch() throws Exception { - Properties p=new Properties(); - p.setProperty("key1","value1"); - assertEquals(ConfigHelper.propertyFetch(p,"key1","value2"),"value1"); - assertEquals(ConfigHelper.propertyFetch(p,"key2","value2"),"value2"); - } } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptConvertorTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptConvertorTest.java deleted file mode 100644 index fb25b4b..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptConvertorTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.util; - -import org.junit.Test; - -import java.util.Arrays; - -import static org.junit.Assert.assertEquals; -/** - * The Class EncryptConvertor. - */ -public class EncryptConvertorTest { - - @Test - public void toHexStringTestString() { - assertEquals(EncryptConvertor.toHexString("abcd"),"61626364"); - } - - @Test - public void toHexStringTestByteArray() { - assertEquals(EncryptConvertor.toHexString("abcd".getBytes()),"61626364"); - } - - @Test - public void stringFromHexTestString() throws Exception { - assertEquals(EncryptConvertor.stringFromHex("61626364"),"abcd"); - } - - @Test - public void stringFromHexTestCharArray() throws Exception { - assertEquals(EncryptConvertor.stringFromHex("61626364".toCharArray()),"abcd"); - } - - @Test - public void bytesFromHexTestCharArray() throws Exception { - byte[] buf = {97, 98, 99, 100}; - assertEquals(Arrays.toString(EncryptConvertor.bytesFromHex("61626364")), Arrays.toString(buf)); - } - - @Test - public void bytesFromHex() throws Exception { - byte[] buf = {97, 98, 99, 100}; - assertEquals(Arrays.toString(EncryptConvertor.bytesFromHex("61626364".toCharArray())), Arrays.toString(buf)); - } - - @Test - public void fromHexDigit() throws Exception { - assertEquals(EncryptConvertor.fromHexDigit('a',2), 10); - } - -} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptorTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptorTest.java deleted file mode 100644 index 10fbd6f..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptorTest.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.util; - - -import org.junit.Before; -import org.junit.Test; - - -import static org.junit.Assert.*; - -/** - * The Class Encryptor. - */ -public class EncryptorTest { - - Encryptor encryptor; - @Before - public void init(){ - encryptor = new Encryptor(); - } - - @Test - public void encryptTest() { - assertEquals("OBF:1t331y0o1u2e1uvk1u3m1y0s1wui1qaz1qc31wtw1y0y1u1o1uum1u2w1y121t33",encryptor.encryptValue("encryptThisValue")); - } - - @Test - public void decryptTest() { - assertEquals("encryptThisValue",encryptor.decryptValue("OBF:1t331y0o1u2e1uvk1u3m1y0s1wui1qaz1qc31wtw1y0y1u1o1uum1u2w1y121t33")); - } -} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RawByteHelperTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RawByteHelperTest.java deleted file mode 100644 index c44de6f..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RawByteHelperTest.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.util; - -import org.junit.Test; -import static org.junit.Assert.assertEquals; -/** - * The Class RawByteHelper. - */ -public class RawByteHelperTest { - - @Test - public void testDumpBytes() { - String str = "abcd"; - assertEquals(RawByteHelper.dumpBytes(str.getBytes()),"61 62 63 64 "); - - } - - // if you're trying to figure out why or's w/ FF's see: - @Test - public void testBytesToInt() { - byte one = 0, two = 0, three = 1, four = 1; - assertEquals(RawByteHelper.bytesToInt(one, two, three,four),257); - } - - @Test - public void testBytesToShort() { - byte a = 1; - byte b = 0; - assertEquals(RawByteHelper.bytesToShort(a, b), (short)256); - } - - // short helper functions - @Test - public void testFirstByteShort() { - short num1 = 123; - short num2 = 321; - assertEquals(RawByteHelper.firstByte(num1),(short)0); - assertEquals(RawByteHelper.firstByte(num2),(short)1); - } - - @Test - public void testFirstByteInt() { - int num1 = 123; - assertEquals(RawByteHelper.firstByte(num1),(byte)0); - } - - @Test - public void testSecondByteShort() { - short num1 = 123; - short num2 = 321; - assertEquals(RawByteHelper.secondByte(num1),(byte)num1); - assertEquals(RawByteHelper.secondByte(num2),(byte)65); - } - - @Test - public void testSecondByteInt() { - int num1 = 123; - int num2 = -123; - assertEquals(RawByteHelper.secondByte(num1),(byte)0); - assertEquals(RawByteHelper.secondByte(num2),(byte)-1); - } - - @Test - public void thirdByte() { - int num1 = 123; - int num2 = -123; - assertEquals(RawByteHelper.thirdByte(num1),(byte)0); - assertEquals(RawByteHelper.thirdByte(num2),(byte)-1); - } - @Test - public void fourthByte() { - int num1 = 123; - int num2 = 321; - assertEquals(RawByteHelper.fourthByte(num1),(byte)123); - assertEquals(RawByteHelper.fourthByte(num2),(byte)65); - } - @Test - public void intToByte() { - int num1 = 123; - int num2 = 321; - assertEquals(RawByteHelper.intToByte(num1),(byte)123); - assertEquals(RawByteHelper.intToByte(num2),(byte)65); - } - @Test - public void intToShort() { - int num1 = 123; - int num2 = 321; - assertEquals(RawByteHelper.intToByte(num1),(short)123); - assertEquals(RawByteHelper.intToByte(num2),(short)65); - } - -} - diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RestletUtilsTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RestletUtilsTest.java deleted file mode 100644 index 92d17e9..0000000 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RestletUtilsTest.java +++ /dev/null @@ -1,93 +0,0 @@ -/** - * ============LICENSE_START======================================================= - * org.onap.aai - * ================================================================================ - * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved. - * Copyright © 2017-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========================================================= - */ -package org.onap.aai.sparky.util; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mockito; -import org.mockito.runners.MockitoJUnitRunner; -import org.onap.aai.cl.api.Logger; -import org.onap.aai.sparky.search.SearchServiceAdapter; -import org.restlet.Response; -import org.restlet.Server; -import org.restlet.engine.adapter.Call; -import org.restlet.engine.adapter.HttpResponse; -import org.restlet.ext.servlet.internal.ServletCall; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertEquals; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -@RunWith(MockitoJUnitRunner.class) -public class RestletUtilsTest { - - static final String EMPTY_STRING = ""; - RestletUtils restletUtils; - - @Before - public void init() { - restletUtils = new RestletUtils(); - } - - @Test - public void testConvertRestletResponseToHttpServletResponse() { - Response restletResponse = Mockito.mock(HttpResponse.class); - Call call = new ServletCall(Mockito.mock(Server.class),Mockito.mock(HttpServletRequest.class),Mockito.mock(HttpServletResponse.class)); - Mockito.when(((HttpResponse)restletResponse).getHttpCall()).thenReturn((ServletCall)call); - restletUtils.convertRestletResponseToHttpServletResponse(restletResponse); - } - - @Test - public void testExecutePostQueryNullCheck() { - Logger logger = Mockito.mock(Logger.class); - Response response = Mockito.mock(Response.class); - SearchServiceAdapter search = Mockito.mock(SearchServiceAdapter.class); - String requestUrl = EMPTY_STRING; - String requestJsonPayload = EMPTY_STRING; - try{ - restletUtils.executePostQuery(logger,search,response,requestUrl,requestJsonPayload); - }catch (NullPointerException e){ - //expected - } - } - - @Test - public void testHandleRestletErrors() { - Logger logger = Mockito.mock(Logger.class); - Response response = Mockito.mock(Response.class); - Exception exc = Mockito.mock(Exception.class); - String errorMsg = ""; - restletUtils.handleRestletErrors(logger,errorMsg,exc,response); - } - - @Test - public void testSetRestletResponse() { - Logger logger = Mockito.mock(Logger.class); - Response response = Mockito.mock(Response.class); - Exception exc = Mockito.mock(Exception.class); - boolean isError = true; - int responseCode =200; - String payload = ""; - restletUtils.setRestletResponse(logger,false,responseCode,response,payload); - } -} diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/StringCollectionContainsMatcher.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/StringCollectionContainsMatcher.java index b101901..cf20436 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/StringCollectionContainsMatcher.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/StringCollectionContainsMatcher.java @@ -21,10 +21,11 @@ package org.onap.aai.sparky.util; -import org.hamcrest.Description; - import java.util.List; +import org.hamcrest.BaseMatcher; +import org.hamcrest.Description; + public class StringCollectionContainsMatcher extends BaseMatcher<List<String>> { private String valueToCheck; @@ -33,37 +34,27 @@ public class StringCollectionContainsMatcher extends BaseMatcher<List<String>> { public StringCollectionContainsMatcher(String valToCheck) { this.valueToCheck = valToCheck; } - - @Override - public void describeTo(Description arg0) { - // TODO Auto-generated method stub - } - + @Override - public boolean matches(List<String> argumentList) { - for ( String listItem : argumentList ) { - - if ( listItem.contains(valueToCheck)) { - return true; - } - } - - return false; - } - - /*@Override public boolean matches(Object arg0) { @SuppressWarnings("unchecked") List<String> argumentList = (List<String>) arg0; - + for ( String listItem : argumentList ) { - + if ( listItem.contains(valueToCheck)) { return true; } } - + return false; - }*/ + } + + @Override + public void describeTo(Description arg0) { + // TODO Auto-generated method stub + + } + } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java index 543326c..1de7263 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java @@ -41,7 +41,6 @@ import org.hamcrest.Matcher; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentMatcher; import org.mockito.Matchers; import org.mockito.Mockito; import org.onap.aai.cl.api.Logger; @@ -117,7 +116,7 @@ public class BaseVisualizationContextTest { } - private ArgumentMatcher<List<String>> listContainsValue(String expectedValue) { + private Matcher<List<String>> listContainsValue(String expectedValue) { return new StringCollectionContainsMatcher(expectedValue); } diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java index d5e98a9..5bff7f4 100644 --- a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java +++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java @@ -41,7 +41,6 @@ import org.hamcrest.Matcher; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentMatcher; import org.mockito.Matchers; import org.mockito.Mockito; import org.onap.aai.cl.api.Logger; @@ -117,10 +116,11 @@ public class BaseVisualizationContextTest { } - private ArgumentMatcher<List<String>> listContainsValue(String expectedValue) { + private Matcher<List<String>> listContainsValue(String expectedValue) { return new StringCollectionContainsMatcher(expectedValue); } + @Test public void validateBasicConstruction() throws Exception { diff --git a/sparkybe-onap-service/src/test/resources/configHelperTest.properties b/sparkybe-onap-service/src/test/resources/configHelperTest.properties deleted file mode 100644 index e92b77a..0000000 --- a/sparkybe-onap-service/src/test/resources/configHelperTest.properties +++ /dev/null @@ -1,3 +0,0 @@ -prefix.key1=value1 -prefix.key2=value2 -prefix.key3=value3
\ No newline at end of file diff --git a/sparkybe-onap-service/src/test/resources/oxm-reader/oxm-reader-bean.xml b/sparkybe-onap-service/src/test/resources/oxm-reader/oxm-reader-bean.xml index caceee6..76e5f17 100644 --- a/sparkybe-onap-service/src/test/resources/oxm-reader/oxm-reader-bean.xml +++ b/sparkybe-onap-service/src/test/resources/oxm-reader/oxm-reader-bean.xml @@ -40,11 +40,8 @@ <property name="edgeDirectory" value="${edgeDir}" /> </bean> + <bean id="schemaVersions" class="org.onap.aai.setup.SchemaVersions"/> - - <bean id="schemaVersions" class="org.onap.aai.setup.SchemaVersions"/> - - <bean id="oxmConfigTranslator" class="org.onap.aai.setup.AAIConfigTranslator"> <constructor-arg ref="schemaLocationsBean" /> <constructor-arg ref="schemaVersions" /> |