diff options
Diffstat (limited to 'data-migrator/src/test')
7 files changed, 0 insertions, 468 deletions
diff --git a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternalTest.java b/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternalTest.java deleted file mode 100644 index 18cd662f..00000000 --- a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/DataMigrationInternalTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : SDNC - * ================================================================================ - * Copyright 2019 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.sdnc.oam.datamigrator; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.junit.Rule; -import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.hamcrest.MatcherAssert.assertThat; - -public class DataMigrationInternalTest { - - @Rule - public WireMockRule source = new WireMockRule(8081); - @Rule - public WireMockRule target = new WireMockRule(8082); - - private static final Logger LOG = LoggerFactory.getLogger(DataMigrationInternal.class); - DataMigrationInternal dataMigrationInternal = new DataMigrationInternal(LOG); - private ClassLoader classLoader = getClass().getClassLoader(); - private String preloadVnfResponseJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadVnfResponse.json").toURI()))); - private String preloadInformationRequestJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadInformationRequest.json").toURI()))); - - public DataMigrationInternalTest() throws IOException, URISyntaxException { - } - - @Test - public void runPositiveTest() { - String [] args = {"-c","migration/props"}; - PrintStream oldOutputStream = System.out; - final ByteArrayOutputStream myOut = new ByteArrayOutputStream(); - System.setOut(new PrintStream(myOut)); - source.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")).willReturn( - aResponse() - .withStatus(200) - .withBody(preloadVnfResponseJson))); - target.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")).withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn( - aResponse() - .withStatus(200))); - dataMigrationInternal.run(args); - String content = myOut.toString(); - assertThat("Migration failed", content.contains("MIGRATE operation completed Successfully.")); - System.setOut(oldOutputStream); - } - - @Test - public void runTestWithNoData() { - String [] args = {"-c","migration/props"}; - PrintStream oldOutputStream = System.out; - final ByteArrayOutputStream myOut = new ByteArrayOutputStream(); - System.setOut(new PrintStream(myOut)); - source.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")) - .willReturn(aResponse().withStatus(404))); - target.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")) - .withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(aResponse().withStatus(200))); - dataMigrationInternal.run(args); - String content = myOut.toString(); - assertThat("Migration failed", content.contains("MIGRATE operation completed Successfully.")); - System.setOut(oldOutputStream); - } -}
\ No newline at end of file diff --git a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/common/RestconfClientTest.java b/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/common/RestconfClientTest.java deleted file mode 100644 index bbffd608..00000000 --- a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/common/RestconfClientTest.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : SDNC - * ================================================================================ - * Copyright 2019 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.sdnc.oam.datamigrator.common; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import org.junit.Rule; -import org.junit.Test; -import org.onap.sdnc.oam.datamigrator.exceptions.RestconfException; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; - -import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; -import static com.github.tomakehurst.wiremock.client.WireMock.get; -import static com.github.tomakehurst.wiremock.client.WireMock.put; -import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -public class RestconfClientTest { - - @Rule - public WireMockRule service = new WireMockRule(8081); - private RestconfClient restconfClient = new RestconfClient("http://localhost:8081","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"); - private ClassLoader classLoader = getClass().getClassLoader(); - private String preloadVnfResponseJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadVnfResponse.json").toURI()))); - private String preloadInformationRequestJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadInformationRequest.json").toURI()))); - - - JsonObject expectedJsonObject = new JsonParser().parse(preloadVnfResponseJson).getAsJsonObject(); - - public RestconfClientTest() throws IOException, URISyntaxException { - } - - @Test - public void getPositiveTest() { - service.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")) - .willReturn(aResponse().withStatus(200).withBody(preloadVnfResponseJson))); - JsonObject actualResponse=null; - try { - actualResponse = restconfClient.get("GENERIC-RESOURCE-API:preload-vnfs"); - } catch (RestconfException e) { - e.printStackTrace(); - } - assertEquals(expectedJsonObject,actualResponse); - } - - @Test - public void getNegativeTest() { - service.stubFor(get(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")) - .willReturn(aResponse().withStatus(404))); - JsonObject actualResponse=null; - try { - actualResponse = restconfClient.get("GENERIC-RESOURCE-API:preload-vnfs"); - } catch (RestconfException e) { - e.printStackTrace(); - } - assertNull(actualResponse); - } - - @Test - public void putPositiveTest() { - service.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")) - .withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(aResponse().withStatus(200))); - Exception ex = null; - try { - restconfClient.put("GENERIC-RESOURCE-API:preload-information", preloadInformationRequestJson); - } catch (RestconfException e) { - ex =e; - } - assertNull(ex); - } - - @Test - public void putNegativeTest() { - service.stubFor(put(urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")) - .withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn(aResponse().withStatus(500))); - try { - restconfClient.put("GENERIC-RESOURCE-API:preload-information", preloadInformationRequestJson); - } catch (RestconfException e) { - assertTrue(e.getErrorMessage().contains("Error during restconf operation: PUT.")); - } - } -}
\ No newline at end of file diff --git a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/datamigrator/PreloadInformationMigratorTest.java b/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/datamigrator/PreloadInformationMigratorTest.java deleted file mode 100644 index 7972b7ab..00000000 --- a/data-migrator/src/test/java/org/onap/sdnc/oam/datamigrator/datamigrator/PreloadInformationMigratorTest.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : SDNC - * ================================================================================ - * Copyright 2019 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.sdnc.oam.datamigrator.datamigrator; - -import com.github.tomakehurst.wiremock.client.WireMock; -import com.github.tomakehurst.wiremock.junit.WireMockRule; -import org.junit.Rule; -import org.junit.Test; -import org.onap.sdnc.oam.datamigrator.common.Operation; -import org.onap.sdnc.oam.datamigrator.common.RestconfClient; -import org.onap.sdnc.oam.datamigrator.migrators.PreloadInformationMigrator; - -import java.io.IOException; -import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; - -public class PreloadInformationMigratorTest { - - @Rule - public WireMockRule service1 = new WireMockRule(8081); - - @Rule - public WireMockRule service2 = new WireMockRule(8082); - PreloadInformationMigrator migrator = new PreloadInformationMigrator(); - private ClassLoader classLoader = getClass().getClassLoader(); - private String preloadVnfResponseJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadVnfResponse.json").toURI()))); - private String preloadInformationRequestJson = new String(Files.readAllBytes(Paths.get(classLoader.getResource("wiremock/preloadInformationRequest.json").toURI()))); - - public PreloadInformationMigratorTest() throws IOException, URISyntaxException { - } - - @Test - public void testRun (){ - service1.stubFor(WireMock.get(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")).willReturn( - WireMock.aResponse() - .withStatus(200) - .withBody(preloadVnfResponseJson))); - service2.stubFor(WireMock.put(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")).withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn( - WireMock.aResponse() - .withStatus(200))); - RestconfClient sourceClient = new RestconfClient("http://localhost:8081","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"); - migrator.setSourceClient(sourceClient); - RestconfClient targetClient = new RestconfClient("http://localhost:8082","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"); - migrator.setTargetClient(targetClient); - migrator.run(Operation.MIGRATE); - } - - @Test - public void testRunNoData (){ - service1.stubFor(WireMock.get(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-vnfs")).willReturn( - WireMock.aResponse() - .withStatus(404))); - service2.stubFor(WireMock.put(WireMock.urlEqualTo("/restconf/config/GENERIC-RESOURCE-API:preload-information")).withRequestBody(WireMock.equalTo(preloadInformationRequestJson)).willReturn( - WireMock.aResponse() - .withStatus(200))); - RestconfClient sourceClient = new RestconfClient("http://localhost:8081","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"); - migrator.setSourceClient(sourceClient); - RestconfClient targetClient = new RestconfClient("http://localhost:8082","admin","Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U"); - migrator.setTargetClient(targetClient); - migrator.run(Operation.MIGRATE); - } -} diff --git a/data-migrator/src/test/resources/log4j.properties b/data-migrator/src/test/resources/log4j.properties deleted file mode 100644 index 82f1f470..00000000 --- a/data-migrator/src/test/resources/log4j.properties +++ /dev/null @@ -1,29 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ONAP : SDN-C -# ================================================================================ -# Copyright (C) 2019 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========================================================= -### - -log4j.rootLogger=DEBUG,CONSOLE - -# CONSOLE is set to be a ConsoleAppender using a PatternLayout. -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.Threshold=DEBUG -log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=%p %d{yyyy-MM-dd HH:mm:ss.SSS Z} %c{1} - %m%n - - diff --git a/data-migrator/src/test/resources/migration/props/data-migrator.properties b/data-migrator/src/test/resources/migration/props/data-migrator.properties deleted file mode 100644 index d9ddadbb..00000000 --- a/data-migrator/src/test/resources/migration/props/data-migrator.properties +++ /dev/null @@ -1,27 +0,0 @@ -### -# ============LICENSE_START======================================================= -# ONAP : SDN-C -# ================================================================================ -# Copyright (C) 2019 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========================================================= -### - -org.onap.sdnc.datamigrator.source.host=http://localhost:8081 -org.onap.sdnc.datamigrator.source.user=admin -org.onap.sdnc.datamigrator.source.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -org.onap.sdnc.datamigrator.target.host=http://localhost:8082 -org.onap.sdnc.datamigrator.target.user=admin -org.onap.sdnc.datamigrator.target.password=Kp8bJ4SXszM0WXlhak3eHlcse2gAw84vaoGGmJvUy2U -org.onap.sdnc.datamigrator.data.path=C:/DATA
\ No newline at end of file diff --git a/data-migrator/src/test/resources/wiremock/preloadInformationRequest.json b/data-migrator/src/test/resources/wiremock/preloadInformationRequest.json deleted file mode 100644 index 82df627b..00000000 --- a/data-migrator/src/test/resources/wiremock/preloadInformationRequest.json +++ /dev/null @@ -1 +0,0 @@ -{"preload-information":{"preload-list":[{"preload-type":"vnf-type","preload-id":"vnf-name","preload-data":{"preload-oper-status":{"modify-timestamp":"Some modify-timestamp","create-timestamp":"Some create-timestamp","last-order-status":"Active","order-status":"Active","maintenance-indicator":"Y","last-svc-request-id":"Some last-svc-request-id"},"preload-network-topology-information":{"is-provider-network":true,"network-topology-identifier-structure":{"network-role":"Some network-role","network-technology":"Some network-technology","network-type":"Some network-type","network-name":"Some network-name"},"route-table-reference":[{"route-table-reference-fqdn":"Some route-table-reference-fqdn","route-table-reference-id":"Some route-table-reference-id"}],"network-policy":[{"network-policy-fqdn":"Some network-policy-fqdn","network-policy-id":"Some network-policy-id"}],"subnets":[{"start-address":"1.1.11.2","gateway-address":"8.0.25.2","cidr-mask":"Some cidr-mask","dhcp-end-address":"Some dhcp-end-address","subnet-name":"Some subnet-name","dhcp-start-address":"Some dhcp-start-address","ip-version":"Some ip-version","dhcp-enabled":"Y"}],"vpn-bindings":[{"vpn-binding-id":"Some vpn-binding-id","global-route-target":"Some global-route-target"}],"is-external-network":true,"is-shared-network":true,"physical-network-name":"Some physical-network-name"}}}]}}
\ No newline at end of file diff --git a/data-migrator/src/test/resources/wiremock/preloadVnfResponse.json b/data-migrator/src/test/resources/wiremock/preloadVnfResponse.json deleted file mode 100644 index 006d62f7..00000000 --- a/data-migrator/src/test/resources/wiremock/preloadVnfResponse.json +++ /dev/null @@ -1,132 +0,0 @@ -{ - "preload-vnfs": { - "vnf-preload-list": [ - { - "vnf-type": "vnf-type", - "vnf-name": "vnf-name", - "preload-data": { - "oper-status": { - "last-action": "VNFActivateRequest", - "modify-timestamp": "Some modify-timestamp", - "create-timestamp": "Some create-timestamp", - "last-order-status": "Active", - "order-status": "Active", - "maintenance-indicator": "Y", - "last-svc-request-id": "Some last-svc-request-id" - }, - "vnf-topology-information": { - "vnf-topology-identifier": { - "service-type": "Some service-type", - "service-id": "Some service-id", - "generic-vnf-name": "Some generic-vnf-name", - "generic-vnf-id": "Some generic-vnf-id", - "generic-vnf-type": "Some generic-vnf-type", - "vnf-type": "vnf-type", - "vnf-name": "vnf-name" - }, - "vnf-parameters": [ - { - "vnf-parameter-name": "Some vnf-parameter-name", - "vnf-parameter-value": "Some vnf-parameter-value" - } - ], - "vnf-assignments": { - "vnf-vms": [ - { - "vm-type": "Some vm-type", - "vm-count": 0, - "vm-names": [ - {"vm-name": "Some vm-name"} - ], - "vm-networks": [ - { - "network-role": "Some network-role", - "use-dhcp": "Y", - "floating-ip": "2.12.250.0", - "network-macs": [ - {"mac-address": "Some mac-address"} - ], - "network-ips": [ - {"ip-address": "13.2.219.8"} - ], - "interface-route-prefixes": [ - { - "interface-route-prefix-cidr": "Some interface-route-prefix-cidr", - "interface-route-prefix": "24.0.45.1" - } - ], - "ip-count": 0 - } - ] - } - ], - "vnf-status": "Some vnf-status", - "vnf-networks": [ - { - "network-role": "Some network-role", - "network-id": "Some network-id", - "ipv6-subnet-id": "Some ipv6-subnet-id", - "ipv6-subnet-name": "Some ipv6-subnet-name", - "subnet-name": "Some subnet-name", - "contrail-network-fqdn": "Some contrail-network-fqdn", - "subnet-id": "Some subnet-id", - "sriov-vlan-filter-list": [ - {"sriov-vlan-filter": "Some sriov-vlan-filter"} - ], - "network-name": "Some network-name", - "neutron-id": "Some neutron-id" - } - ], - "availability-zones": [ - {"availability-zone": "Some availability-zone"} - ] - } - }, - "network-topology-information": { - "is-provider-network": true, - "network-topology-identifier": { - "service-type": "Some service-type", - "network-role": "Some network-role", - "network-technology": "Some network-technology", - "network-type": "Some network-type", - "network-name": "Some network-name" - }, - "route-table-reference": [ - { - "route-table-reference-fqdn": "Some route-table-reference-fqdn", - "route-table-reference-id": "Some route-table-reference-id" - } - ], - "network-policy": [ - { - "network-policy-fqdn": "Some network-policy-fqdn", - "network-policy-id": "Some network-policy-id" - } - ], - "subnets": [ - { - "start-address": "1.1.11.2", - "gateway-address": "8.0.25.2", - "cidr-mask": "Some cidr-mask", - "dhcp-end-address": "Some dhcp-end-address", - "subnet-name": "Some subnet-name", - "dhcp-start-address": "Some dhcp-start-address", - "ip-version": "Some ip-version", - "dhcp-enabled": "Y" - } - ], - "vpn-bindings": [ - { - "vpn-binding-id": "Some vpn-binding-id", - "global-route-target": "Some global-route-target" - } - ], - "is-external-network": true, - "is-shared-network": true, - "physical-network-name": "Some physical-network-name" - } - } - } - ] - } -}
\ No newline at end of file |