diff options
Diffstat (limited to 'common/src/test')
14 files changed, 289 insertions, 70 deletions
diff --git a/common/src/test/java/org/onap/so/BeansTest.java b/common/src/test/java/org/onap/so/BeansTest.java index 2e825cf8c7..54cbced563 100644 --- a/common/src/test/java/org/onap/so/BeansTest.java +++ b/common/src/test/java/org/onap/so/BeansTest.java @@ -63,7 +63,6 @@ public class BeansTest { @Test public void pojoStructure() { - test("org.onap.so.client.aai.objects"); test("org.onap.so.client.policy.entities"); test("org.onap.so.client.grm.beans"); test("org.onap.so.client.ruby.beans"); diff --git a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java index ea842719e8..d4eaf0873b 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIObjectTypeTest.java @@ -28,6 +28,20 @@ import org.onap.so.client.aai.entities.uri.AAIUriFactory; public class AAIObjectTypeTest { + + @Test + public void fromTypeNameTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException { + AAIObjectType type = AAIObjectType.fromTypeName("allotted-resource"); + assertEquals("allotted-resource", type.typeName()); + + } + + @Test + public void customTypeTest() throws IllegalArgumentException, IllegalAccessException, InstantiationException { + AAIObjectType type = AAIObjectType.fromTypeName("my-custom-name"); + assertEquals("my-custom-name", type.typeName()); + + } @Test public void verifyDefaultCase() { assertEquals("default removed for tenant", "tenant", AAIObjectType.DEFAULT_TENANT.typeName()); diff --git a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java index f4b6141b0a..43616ba0c2 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIQueryClientTest.java @@ -21,7 +21,7 @@ package org.onap.so.client.aai; import static org.junit.Assert.assertNotNull; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.ArgumentMatchers.isA; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; diff --git a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java index 6abeea9d9b..95b30f934b 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAIRestClientTest.java @@ -22,7 +22,7 @@ package org.onap.so.client.aai; import static org.hamcrest.CoreMatchers.containsString; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Matchers.eq; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; @@ -41,6 +41,7 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.so.client.RestClientSSL; +import org.onap.so.client.graphinventory.GraphInventoryPatchConverter; import org.onap.so.client.graphinventory.exceptions.GraphInventoryPatchDepthExceededException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -68,7 +69,7 @@ public class AAIRestClientTest { public void verifyPatchValidation() throws URISyntaxException { AAIRestClient client = new AAIRestClient(props, new URI("")); AAIRestClient spy = spy(client); - AAIPatchConverter patchValidatorMock = mock(AAIPatchConverter.class); + GraphInventoryPatchConverter patchValidatorMock = mock(GraphInventoryPatchConverter.class); doReturn(patchValidatorMock).when(spy).getPatchConverter(); String payload = "{}"; doReturn(Response.ok().build()).when(spy).method(eq("PATCH"), any()); diff --git a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java index 428fa276db..27637126c6 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAISingleTransactionClientTest.java @@ -45,6 +45,7 @@ import org.onap.so.client.aai.entities.singletransaction.SingleTransactionRespon import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl; +import org.onap.so.client.graphinventory.GraphInventoryPatchConverter; import org.skyscreamer.jsonassert.JSONAssert; import com.fasterxml.jackson.core.JsonParseException; @@ -117,7 +118,7 @@ public class AAISingleTransactionClientTest { @Test public void confirmPatchFormat() { AAISingleTransactionClient singleTransaction = spy(new AAISingleTransactionClient(AAIVersion.LATEST)); - AAIPatchConverter mock = mock(AAIPatchConverter.class); + GraphInventoryPatchConverter mock = mock(GraphInventoryPatchConverter.class); doReturn(mock).when(singleTransaction).getPatchConverter(); singleTransaction.update(uriA, "{}"); verify(mock, times(1)).convertPatchFormat(any()); diff --git a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java index 621375882b..342e3b1aa4 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java +++ b/common/src/test/java/org/onap/so/client/aai/AAITransactionalClientTest.java @@ -43,6 +43,7 @@ import org.onap.aai.domain.yang.Relationship; import org.onap.so.client.aai.entities.uri.AAIResourceUri; import org.onap.so.client.aai.entities.uri.AAIUriFactory; import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl; +import org.onap.so.client.graphinventory.GraphInventoryPatchConverter; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.core.type.TypeReference; @@ -143,7 +144,7 @@ public class AAITransactionalClientTest { @Test public void confirmPatchFormat() { AAITransactionalClient client = spy(new AAITransactionalClient(AAIVersion.LATEST)); - AAIPatchConverter mock = mock(AAIPatchConverter.class); + GraphInventoryPatchConverter mock = mock(GraphInventoryPatchConverter.class); doReturn(mock).when(client).getPatchConverter(); client.update(uriA, "{}"); verify(mock, times(1)).convertPatchFormat(any()); diff --git a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java new file mode 100644 index 0000000000..e66f43fa5f --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.so.client.aai; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; +import org.onap.so.client.aai.entities.DSLNode; +import org.onap.so.client.aai.entities.DSLQueryBuilder; +import org.onap.so.client.aai.entities.__; + +public class DSLQueryBuilderTest { + + + @Test + public void whereTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.CLOUD_REGION, + __.key("cloud-owner", "att-nc"), + __.key("cloud-region-id", "test"))); + + builder.to(__.node(AAIObjectType.VLAN_TAG)).where( + __.node(AAIObjectType.OWNING_ENTITY, + __.key("owning-entity-name", "name") + ) + ).to(__.node(AAIObjectType.VLAN_TAG, __.key("vlan-id-outer", "108")).output()); + + assertEquals("cloud-region('cloud-owner', 'att-nc')('cloud-region-id', 'test') > " + + "vlan-tag (> owning-entity('owning-entity-name', 'name')) > " + + "vlan-tag*('vlan-id-outer', '108')", builder.build()); + } + + @Test + public void unionTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.GENERIC_VNF, + __.key("vnf-id", "vnfId")).output()); + + builder.union(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()), + __.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.PSERVER).output().to(__.node(AAIObjectType.COMPLEX).output()))); + + assertEquals("generic-vnf*('vnf-id', 'vnfId') > " + "[ pserver* > complex*, " + + "vserver > pserver* > complex* ]", builder.build()); + } + + @Test + public void whereUnionTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.GENERIC_VNF, + __.key("vnf-id", "vnfId")).output()); + + builder.where( + __.union( + __.node(AAIObjectType.PSERVER, __.key("hostname", "hostname1")), + __.node(AAIObjectType.VSERVER).to(__.node(AAIObjectType.PSERVER, __.key("hostname", "hostname1"))))); + + assertEquals("generic-vnf*('vnf-id', 'vnfId') (> [ pserver('hostname', 'hostname1'), " + + "vserver > pserver('hostname', 'hostname1') ])", builder.build()); + } + + @Test + public void notNullTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.CLOUD_REGION, + __.key("cloud-owner", "", "null").not()).output()); + + assertEquals("cloud-region* !('cloud-owner', ' ', ' null ')", builder.build()); + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java index 729f0e50e9..e84326e95f 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/IncorrectNumberOfUriKeysTest.java @@ -1,3 +1,23 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.so.client.aai.entities.uri; import static org.hamcrest.CoreMatchers.equalTo; diff --git a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java index 7e70f2d5f4..6059e7bd23 100644 --- a/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java +++ b/common/src/test/java/org/onap/so/client/aai/entities/uri/ServiceInstanceUriTest.java @@ -48,7 +48,7 @@ import javax.ws.rs.core.UriBuilder; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; -import org.mockito.Matchers; +import org.mockito.ArgumentMatchers; import org.onap.so.client.aai.AAIResourcesClient; import org.onap.so.client.aai.entities.AAIResultWrapper; import org.onap.so.client.defaultproperties.DefaultAAIPropertiesImpl; @@ -158,7 +158,7 @@ public class ServiceInstanceUriTest { ServiceInstanceUri spy = spy(instance); AAIResourcesClient mockResourcesClient = mock(AAIResourcesClient.class); AAIResultWrapper wrapper = mock(AAIResultWrapper.class); - when(mockResourcesClient.get(Matchers.<AAIResourceUri>any(AAIResourceUri.class), Matchers.<Class<NotFoundException>>any())).thenReturn(wrapper); + when(mockResourcesClient.get(ArgumentMatchers.<AAIResourceUri>any(AAIResourceUri.class), ArgumentMatchers.<Class<NotFoundException>>any())).thenReturn(wrapper); when(wrapper.getJson()).thenReturn(content); when(spy.getResourcesClient()).thenReturn(mockResourcesClient); exception.expect(GraphInventoryUriComputationException.class); diff --git a/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java b/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java deleted file mode 100644 index e2a3cbd6bd..0000000000 --- a/common/src/test/java/org/onap/so/client/aai/objects/AAIOperationalEnvironmentTest.java +++ /dev/null @@ -1,55 +0,0 @@ -/* -* ============LICENSE_START======================================================= - * ONAP : SO - * ================================================================================ - * Copyright (C) 2018 TechMahindra - * ================================================================================ - * 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.so.client.aai.objects; - -import static org.junit.Assert.*; - -import org.junit.Test; - -public class AAIOperationalEnvironmentTest { - - AAIOperationalEnvironment aaiOE =new AAIOperationalEnvironment(); - - @Test - public void test() { - aaiOE.setOperationalEnvironmentId("operationalEnvironmentId"); - aaiOE.setOperationalEnvironmentName("operationalEnvironmentName"); - aaiOE.setOperationalEnvironmentStatus("operationalEnvironmentStatus"); - aaiOE.setOperationalEnvironmentType("operationalEnvironmentType"); - aaiOE.setResourceVersion("resourceVersion"); - aaiOE.setTenantContext("tenantContext"); - aaiOE.setWorkloadContext("workloadContext"); - assertEquals(aaiOE.getOperationalEnvironmentId(),"operationalEnvironmentId"); - assertEquals(aaiOE.getOperationalEnvironmentName(),"operationalEnvironmentName"); - assertEquals(aaiOE.getOperationalEnvironmentStatus(),"operationalEnvironmentStatus"); - assertEquals(aaiOE.getOperationalEnvironmentType(),"operationalEnvironmentType"); - assertEquals(aaiOE.getResourceVersion(),"resourceVersion"); - assertEquals(aaiOE.getTenantContext(),"tenantContext"); - assertEquals(aaiOE.getWorkloadContext(),"workloadContext"); - aaiOE.withOperationalEnvironmentId("operationalEnvironmentId"); - aaiOE.withOperationalEnvironmentName("operationalEnvironmentName"); - aaiOE.withOperationalEnvironmentStatus("operationalEnvironmentStatus"); - aaiOE.withOperationalEnvironmentType("operationalEnvironmentType"); - aaiOE.withResourceVersion("resourceVersion"); - aaiOE.withTenantContext("tenantContext"); - aaiOE.withWorkloadContext("workloadContext"); - } - -} diff --git a/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java b/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java new file mode 100644 index 0000000000..3979902962 --- /dev/null +++ b/common/src/test/java/org/onap/so/client/aai/objects/CustomAAIObjectType.java @@ -0,0 +1,40 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * 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.so.client.aai.objects; + +import org.onap.so.client.aai.AAINamespaceConstants; +import org.onap.so.client.aai.AAIObjectType; + +public class CustomAAIObjectType extends AAIObjectType { + + private static final long serialVersionUID = 1919729212831978098L; + + public static final AAIObjectType CUSTOM = new CustomAAIObjectType(AAINamespaceConstants.NETWORK, "my-url", "my-custom-name"); + + /* Default constructor automatically called by AAIObjectType */ + public CustomAAIObjectType() { + super(); + } + protected CustomAAIObjectType(String parent, String uri, String name) { + super(parent, uri, name); + } + +} diff --git a/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java new file mode 100644 index 0000000000..f4490faacc --- /dev/null +++ b/common/src/test/java/org/onap/so/client/adapter/rest/AdapterRestClientTest.java @@ -0,0 +1,109 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2019 Nokia. + * ================================================================================ + * 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.so.client.adapter.rest; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.entry; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + +import java.net.URI; +import java.net.URISyntaxException; +import java.security.GeneralSecurityException; +import java.util.HashMap; +import java.util.Map; +import org.apache.commons.codec.binary.Base64; +import org.junit.Before; +import org.junit.Test; +import org.onap.so.client.policy.JettisonStyleMapperProvider; +import org.onap.so.utils.CryptoUtils; +import org.onap.so.utils.TargetEntity; + +public class AdapterRestClientTest { + + private static final String CRYPTO_KEY = "546573746F736973546573746F736973"; + private static final String INVALID_CRYPTO_KEY = "1234"; + + private Map<String, String> headerMap; + private AdapterRestProperties adapterRestPropertiesMock; + + @Before + public void setup() { + headerMap = new HashMap<>(); + adapterRestPropertiesMock = mock(AdapterRestProperties.class); + } + + @Test + public void initializeHeaderMap_success() throws URISyntaxException, GeneralSecurityException { + // given + String encyptedMessage = CryptoUtils.encrypt("testAdapter", CRYPTO_KEY); + when(adapterRestPropertiesMock.getAuth()).thenReturn(encyptedMessage); + when(adapterRestPropertiesMock.getKey()).thenReturn(CRYPTO_KEY); + AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI("")); + // when + testedObject.initializeHeaderMap(headerMap); + // then + assertThat(headerMap).containsOnly(entry("Authorization", getExpectedEncodedString(encyptedMessage))); + } + + @Test + public void initializeHeaderMap_putNullToMapWhenAuthIsNull() throws URISyntaxException { + // given + AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI("")); + // when + testedObject.initializeHeaderMap(headerMap); + // then + assertThat(headerMap).containsOnly(entry("Authorization", null)); + } + + @Test + public void initializeHeaderMap_putNullToMapWhenExOccurs() throws URISyntaxException, GeneralSecurityException { + // given + String encyptedMessage = CryptoUtils.encrypt("testAdapter", CRYPTO_KEY); + when(adapterRestPropertiesMock.getAuth()).thenReturn(encyptedMessage); + when(adapterRestPropertiesMock.getKey()).thenReturn(INVALID_CRYPTO_KEY); + AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI(""), + "accept", "contentType"); + // when + testedObject.initializeHeaderMap(headerMap); + // then + assertThat(headerMap).containsOnly(entry("Authorization", null)); + } + + @Test + public void getTargetEntity_success() throws URISyntaxException { + AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI("")); + assertThat(testedObject.getTargetEntity()).isEqualTo(TargetEntity.OPENSTACK_ADAPTER); + } + + @Test + public void getCommonObjectMapperProvider_success() throws URISyntaxException { + AdapterRestClient testedObject = new AdapterRestClient(adapterRestPropertiesMock, new URI("")); + assertThat(testedObject.getCommonObjectMapperProvider()).isInstanceOf(JettisonStyleMapperProvider.class); + } + + private String getExpectedEncodedString(String encryptedMessage) throws GeneralSecurityException { + String auth = CryptoUtils.decrypt(encryptedMessage, CRYPTO_KEY); + byte[] encoded = Base64.encodeBase64(auth.getBytes()); + String encodedString = new String(encoded); + return "Basic " + encodedString; + } +} diff --git a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java b/common/src/test/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverterTest.java index 0d4490f51d..d24b3ff147 100644 --- a/common/src/test/java/org/onap/so/client/aai/AAIPatchConverterTest.java +++ b/common/src/test/java/org/onap/so/client/graphinventory/GraphInventoryPatchConverterTest.java @@ -18,7 +18,7 @@ * ============LICENSE_END========================================================= */ -package org.onap.so.client.aai; +package org.onap.so.client.graphinventory; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -35,6 +35,8 @@ import org.junit.runner.RunWith; import org.mockito.Mock; import org.mockito.junit.MockitoJUnitRunner; import org.onap.aai.domain.yang.GenericVnf; +import org.onap.so.client.aai.AAICommonObjectMapperProvider; +import org.onap.so.client.graphinventory.GraphInventoryPatchConverter; import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonMappingException; @@ -42,13 +44,13 @@ import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(MockitoJUnitRunner.class) -public class AAIPatchConverterTest { +public class GraphInventoryPatchConverterTest { private ObjectMapper mapper = new AAICommonObjectMapperProvider().getMapper(); @Test public void convertObjectToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException { - AAIPatchConverter validator = new AAIPatchConverter(); + GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter(); GenericVnf vnf = new GenericVnf(); vnf.setIpv4Loopback0Address(""); String result = validator.marshallObjectToPatchFormat(vnf); @@ -60,7 +62,7 @@ public class AAIPatchConverterTest { @Test public void convertStringToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException { - AAIPatchConverter validator = new AAIPatchConverter(); + GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter(); String payload = "{\"ipv4-loopback0-address\":\"\"}"; String result = validator.marshallObjectToPatchFormat(payload); @@ -69,7 +71,7 @@ public class AAIPatchConverterTest { @Test public void convertStringToPatchFormatNull_Test() throws URISyntaxException, JsonParseException, JsonMappingException, IOException { - AAIPatchConverter validator = new AAIPatchConverter(); + GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter(); String payload = "{\"ipv4-loopback0-address\": null}"; String result = validator.marshallObjectToPatchFormat(payload); System.out.println(result); @@ -78,7 +80,7 @@ public class AAIPatchConverterTest { @Test public void convertMapToPatchFormatTest() throws URISyntaxException, JsonParseException, JsonMappingException, IOException { - AAIPatchConverter validator = new AAIPatchConverter(); + GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter(); HashMap<String, String> map = new HashMap<>(); map.put("ipv4-loopback0-address", ""); map.put("ipv4-loopback1-address", "192.168.1.1"); @@ -89,7 +91,7 @@ public class AAIPatchConverterTest { @Test public void hasComplexObjectTest() { - AAIPatchConverter validator = new AAIPatchConverter(); + GraphInventoryPatchConverter validator = new GraphInventoryPatchConverter(); String hasNesting = "{ \"hello\" : \"world\", \"nested\" : { \"key\" : \"value\" } }"; String noNesting = "{ \"hello\" : \"world\" }"; String arrayCase = "{ \"hello\" : \"world\", \"nestedSimple\" : [\"value1\" , \"value2\"], \"nestedComplex\" : [{\"key\" : \"value\"}]}"; diff --git a/common/src/test/resources/logback-test.xml b/common/src/test/resources/logback-test.xml index 772eeabeb6..b52e6be022 100644 --- a/common/src/test/resources/logback-test.xml +++ b/common/src/test/resources/logback-test.xml @@ -65,6 +65,10 @@ <appender-ref ref="STDOUT" /> </logger> + <logger name="org.reflections" level="ERROR" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + <root level="WARN"> <appender-ref ref="STDOUT" /> |