summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service
diff options
context:
space:
mode:
authorrajeevme <rajeev.mehta@amdocs.com>2020-02-26 17:48:18 +0530
committerRajeev Mehta <rajeev.mehta@amdocs.com>2020-03-02 09:03:38 +0000
commitc4fe01668d4472c978ca220bdfff9c8e15bc8027 (patch)
tree09d7543caa3b4ea629e1248324bac74ba12670d4 /sparkybe-onap-service
parent37198055321d65aff51d06716461050752cea9a5 (diff)
[AAI-2531] | Update springboot to 2.1.12.RELEASE
Issue-ID: AAI-2531 Change-Id: I5cd738c8786753c4ecbfc4cb23a051978466e256 Signed-off-by: rajeevme<rajeev.mehta@amdocs.com>
Diffstat (limited to 'sparkybe-onap-service')
-rw-r--r--sparkybe-onap-service/pom.xml87
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/crossentityreference/sync/CrossEntityReferenceSynchronizerTest.java3
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationExceptionTest.java40
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/EcompSsoTest.java5
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/config/PortalAuthenticationConfigTest.java36
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/task/PerformGizmoRetrievalTest.java66
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/synchronizer/GizmoEntitySummarizer.java6
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/BaseMatcher.java40
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/ConfigHelperTest.java31
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptConvertorTest.java70
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptorTest.java50
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RawByteHelperTest.java112
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RestletUtilsTest.java93
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/StringCollectionContainsMatcher.java39
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/BaseVisualizationContextTest.java3
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/viewandinspect/services/BaseVisualizationContextTest.java4
-rw-r--r--sparkybe-onap-service/src/test/resources/configHelperTest.properties3
-rw-r--r--sparkybe-onap-service/src/test/resources/oxm-reader/oxm-reader-bean.xml5
18 files changed, 651 insertions, 42 deletions
diff --git a/sparkybe-onap-service/pom.xml b/sparkybe-onap-service/pom.xml
index 842af2d..f3dd245 100644
--- a/sparkybe-onap-service/pom.xml
+++ b/sparkybe-onap-service/pom.xml
@@ -14,6 +14,7 @@
<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>
@@ -21,24 +22,16 @@
<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>
@@ -250,7 +243,17 @@ 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>
@@ -281,6 +284,7 @@ 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>
@@ -330,9 +334,8 @@ 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-mockito</artifactId>
- <version>1.6.2</version>
- <scope>test</scope>
+ <artifactId>powermock-api-mockito2</artifactId>
+ <version>2.0.2</version>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
@@ -342,6 +345,12 @@ some of the depedencies should probably have a scope of provided so they don't a
</dependency>
<dependency>
<groupId>org.powermock</groupId>
+ <artifactId>powermock-core</artifactId>
+ <version>2.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4-rule-agent</artifactId>
<version>1.6.2</version>
<scope>test</scope>
@@ -351,13 +360,19 @@ 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>
@@ -476,6 +491,48 @@ 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>
@@ -583,7 +640,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 876db5d..9529143 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,6 +34,7 @@ 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;
@@ -211,7 +212,7 @@ public class CrossEntityReferenceSynchronizerTest {
}
- private Matcher<List<String>> listContainsValue(String expectedValue) {
+ private ArgumentMatcher<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
new file mode 100644
index 0000000..8c7e60d
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationExceptionTest.java
@@ -0,0 +1,40 @@
+/**
+ * ============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 42ea4a5..9a39cf3 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,5 +72,8 @@ 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
new file mode 100644
index 0000000..395aa37
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/config/PortalAuthenticationConfigTest.java
@@ -0,0 +1,36 @@
+/**
+ * ============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
new file mode 100644
index 0000000..908bc22
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/task/PerformGizmoRetrievalTest.java
@@ -0,0 +1,66 @@
+/**
+ * ============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 4b86bb5..6669dbc 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 ElasticSearchOperationException, IOException, RestClientConstructionException {
+ throws ElasticSearchOperationExceptionTest, IOException, RestClientConstructionException, ElasticSearchOperationException {
OxmModelAndProcessorHelper.API_VERSION_OVERRIDE = "v11";
@@ -240,7 +240,7 @@ public class GizmoEntitySummarizer {
}
public static void main(String[] args)
- throws ElasticSearchOperationException, IOException, RestClientConstructionException {
+ throws ElasticSearchOperationExceptionTest, IOException, RestClientConstructionException, ElasticSearchOperationException {
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
new file mode 100644
index 0000000..2abf360
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/BaseMatcher.java
@@ -0,0 +1,40 @@
+/**
+ * ============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 61bf5c2..2d4a365 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,12 +23,15 @@ 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;
@@ -45,11 +48,33 @@ 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
new file mode 100644
index 0000000..fb25b4b
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptConvertorTest.java
@@ -0,0 +1,70 @@
+/**
+ * ============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
new file mode 100644
index 0000000..10fbd6f
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptorTest.java
@@ -0,0 +1,50 @@
+/**
+ * ============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
new file mode 100644
index 0000000..c44de6f
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RawByteHelperTest.java
@@ -0,0 +1,112 @@
+/**
+ * ============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
new file mode 100644
index 0000000..92d17e9
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RestletUtilsTest.java
@@ -0,0 +1,93 @@
+/**
+ * ============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 cf20436..b101901 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,11 +21,10 @@
package org.onap.aai.sparky.util;
-import java.util.List;
-
-import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
+import java.util.List;
+
public class StringCollectionContainsMatcher extends BaseMatcher<List<String>> {
private String valueToCheck;
@@ -34,27 +33,37 @@ 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
-
- }
-
+ return false;
+ }*/
}
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 1de7263..543326c 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,6 +41,7 @@ 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;
@@ -116,7 +117,7 @@ public class BaseVisualizationContextTest {
}
- private Matcher<List<String>> listContainsValue(String expectedValue) {
+ private ArgumentMatcher<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 5bff7f4..d5e98a9 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,6 +41,7 @@ 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;
@@ -116,11 +117,10 @@ public class BaseVisualizationContextTest {
}
- private Matcher<List<String>> listContainsValue(String expectedValue) {
+ private ArgumentMatcher<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
new file mode 100644
index 0000000..e92b77a
--- /dev/null
+++ b/sparkybe-onap-service/src/test/resources/configHelperTest.properties
@@ -0,0 +1,3 @@
+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 76e5f17..caceee6 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,8 +40,11 @@
<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" />