From d30c5444bc0c0fdc37894ed5c866266522465b44 Mon Sep 17 00:00:00 2001 From: Jimmy Forsyth Date: Fri, 20 Mar 2020 15:43:51 -0400 Subject: Reverting to spring-boot 1.5 Issue-ID: AAI-2531 Change-Id: Iee6abd6cba82ffb4c376271e5e94c14e14d8ad51 Signed-off-by: Jimmy Forsyth --- .../sync/CrossEntityReferenceSynchronizerTest.java | 3 +- .../ElasticSearchOperationExceptionTest.java | 40 -------- .../org/onap/aai/sparky/security/EcompSsoTest.java | 5 +- .../config/PortalAuthenticationConfigTest.java | 36 ------- .../sync/task/PerformGizmoRetrievalTest.java | 66 ------------ .../sparky/synchronizer/GizmoEntitySummarizer.java | 6 +- .../java/org/onap/aai/sparky/util/BaseMatcher.java | 40 -------- .../org/onap/aai/sparky/util/ConfigHelperTest.java | 31 +----- .../onap/aai/sparky/util/EncryptConvertorTest.java | 70 ------------- .../org/onap/aai/sparky/util/EncryptorTest.java | 50 --------- .../onap/aai/sparky/util/RawByteHelperTest.java | 112 --------------------- .../org/onap/aai/sparky/util/RestletUtilsTest.java | 93 ----------------- .../util/StringCollectionContainsMatcher.java | 39 +++---- .../BaseVisualizationContextTest.java | 3 +- .../services/BaseVisualizationContextTest.java | 4 +- 15 files changed, 26 insertions(+), 572 deletions(-) delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/dal/exception/ElasticSearchOperationExceptionTest.java delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/security/portal/config/PortalAuthenticationConfigTest.java delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/sync/task/PerformGizmoRetrievalTest.java delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/BaseMatcher.java delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptConvertorTest.java delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/EncryptorTest.java delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RawByteHelperTest.java delete mode 100644 sparkybe-onap-service/src/test/java/org/onap/aai/sparky/util/RestletUtilsTest.java (limited to 'sparkybe-onap-service/src/test/java') 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> listContainsValue(String expectedValue) { + private Matcher> 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 implements ArgumentMatcher, 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> { private String valueToCheck; @@ -33,37 +34,27 @@ public class StringCollectionContainsMatcher extends BaseMatcher> { public StringCollectionContainsMatcher(String valToCheck) { this.valueToCheck = valToCheck; } - - @Override - public void describeTo(Description arg0) { - // TODO Auto-generated method stub - } - + @Override - public boolean matches(List argumentList) { - for ( String listItem : argumentList ) { - - if ( listItem.contains(valueToCheck)) { - return true; - } - } - - return false; - } - - /*@Override public boolean matches(Object arg0) { @SuppressWarnings("unchecked") List argumentList = (List) 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> listContainsValue(String expectedValue) { + private Matcher> 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> listContainsValue(String expectedValue) { + private Matcher> listContainsValue(String expectedValue) { return new StringCollectionContainsMatcher(expectedValue); } + @Test public void validateBasicConstruction() throws Exception { -- cgit 1.2.3-korg