diff options
author | ChrisC <cc697w@intl.att.com> | 2017-01-31 11:40:03 +0100 |
---|---|---|
committer | ChrisC <cc697w@intl.att.com> | 2017-01-31 12:59:33 +0100 |
commit | 025301d08b061482c1f046d562bf017c8cbcfe8d (patch) | |
tree | 68a2a549736c9bf0f7cd4e71c76e40ef7e2606f2 /adapters/mso-network-adapter/src/test | |
parent | 2754ad52f833278a5c925bd788a16d1dce16a598 (diff) |
Initial OpenECOMP MSO commit
Change-Id: Ia6a7574859480717402cc2f22534d9973a78fa6d
Signed-off-by: ChrisC <cc697w@intl.att.com>
Diffstat (limited to 'adapters/mso-network-adapter/src/test')
-rw-r--r-- | adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java | 266 | ||||
-rw-r--r-- | adapters/mso-network-adapter/src/test/resources/logback-test.xml | 48 |
2 files changed, 314 insertions, 0 deletions
diff --git a/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java new file mode 100644 index 0000000000..41cc3f5533 --- /dev/null +++ b/adapters/mso-network-adapter/src/test/java/org/openecomp/mso/adapters/network/NetworkAdapterTest.java @@ -0,0 +1,266 @@ +/*- + * ============LICENSE_START======================================================= + * OPENECOMP - MSO + * ================================================================================ + * Copyright (C) 2017 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.openecomp.mso.adapters.network; + + +import static org.junit.Assert.assertTrue; + +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +import javax.xml.ws.Holder; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.mockito.Mock; +import org.mockito.Mockito; + +import org.openecomp.mso.adapters.network.exceptions.NetworkException; +import org.openecomp.mso.db.catalog.CatalogDatabase; +import org.openecomp.mso.db.catalog.beans.NetworkResource; +import org.openecomp.mso.entity.MsoRequest; +import org.openecomp.mso.openstack.beans.NetworkStatus; +import org.openecomp.mso.openstack.beans.Subnet; +import org.openecomp.mso.openstack.beans.NetworkRollback; + +public class NetworkAdapterTest { + + @Mock + private static MsoNetworkAdapterImpl adapter; + + @Mock + private static CatalogDatabase db; + + @BeforeClass + public static final void prepare () { + adapter = Mockito.spy (new MsoNetworkAdapterImpl ()); + db = Mockito.mock (CatalogDatabase.class); + NetworkResource networkResource = new NetworkResource (); + networkResource.setNetworkType ("PROVIDER"); + networkResource.setNeutronNetworkType ("PROVIDER"); + networkResource.setId (1); + networkResource.setOrchestrationMode ("toto"); + Mockito.when (db.getNetworkResource ("PROVIDER")).thenReturn (networkResource); + Mockito.when (adapter.getCatalogDb()).thenReturn (db); + } + + @Test + public void createTest () { + + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + subnets.add (new Subnet ()); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + try { + adapter.createNetwork ("toto", + "tenant", + "PROVIDER", + "networkName", + "physicalNetworkName", + vlans, + Boolean.TRUE, + Boolean.TRUE, + subnets, + msoRequest, + networkId, + neutronNetworkId, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void createTest2 () { + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + List <String> routeTargets = new LinkedList <> (); + subnets.add (new Subnet ()); + List <String> policyFqdns = new LinkedList <> (); + policyFqdns.add("pfqdn1"); + policyFqdns.add("pfqdn2"); + List <String> routeTableFqdns = new LinkedList <> (); + routeTableFqdns.add("rtfqdn1"); + routeTableFqdns.add("rtfqdn2"); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + Holder <String> networkFqdn= new Holder <> (); + try { + adapter.createNetworkContrail ("toto", + "tenant", + "PROVIDER", + "networkName", + routeTargets, + "shared", + "external", + Boolean.TRUE, + Boolean.TRUE, + subnets, + policyFqdns, + routeTableFqdns, + msoRequest, + networkId, + neutronNetworkId, + networkFqdn, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void updateTest () { + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + subnets.add (new Subnet ()); + MsoRequest msoRequest = new MsoRequest (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + try { + adapter.updateNetwork ("toto", + "tenant", + "PROVIDER", + "networkId", + "networkName", + "physicalNetworkName", + vlans, + subnets, + msoRequest, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void updateTest2 () { + List <Integer> vlans = new LinkedList <> (); + vlans.add (1); + vlans.add (2); + List <Subnet> subnets = new LinkedList <> (); + List <String> routeTargets = new LinkedList <> (); + subnets.add (new Subnet ()); + List <String> policyFqdns = new LinkedList <> (); + policyFqdns.add("pfqdn1"); + List <String> routeTableFqdns = new LinkedList <> (); + routeTableFqdns.add("rtfqdn1"); + routeTableFqdns.add("rtfqdn2"); + MsoRequest msoRequest = new MsoRequest (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + Holder <NetworkRollback> rollback = new Holder <> (); + try { + adapter.updateNetworkContrail ("toto", + "tenant", + "PROVIDER", + "networkId", + "networkName", + routeTargets, + "shared", + "external", + subnets, + policyFqdns, + routeTableFqdns, + msoRequest, + subnetIdMap, + rollback); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } + + @Test + public void queryTest () { + Holder <List <Integer>> vlans = new Holder <> (); + Holder <NetworkStatus> status = new Holder <> (); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <Boolean> result = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + try { + adapter.queryNetwork (null, + "tenant", + "networkName", + msoRequest, + result, + networkId, + neutronNetworkId, + status, + vlans, + subnetIdMap); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Missing mandatory parameter")); + } + } + + @Test + public void queryTest2 () { + Holder <List <String>> routeTargets = new Holder <> (); + Holder <NetworkStatus> status = new Holder <> (); + MsoRequest msoRequest = new MsoRequest (); + Holder <String> networkId = new Holder <> (); + Holder <Boolean> result = new Holder <> (); + Holder <String> neutronNetworkId = new Holder <> (); + Holder <Map <String, String>> subnetIdMap = new Holder <> (); + try { + adapter.queryNetworkContrail (null, + "tenant", + "networkName", + msoRequest, + result, + networkId, + neutronNetworkId, + status, + routeTargets, + subnetIdMap); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Missing mandatory parameter")); + } + } + + @Test + public void deleteTest () { + Holder <Boolean> networkDeleted = new Holder<> (); + MsoRequest msoRequest = new MsoRequest (); + try { + adapter.deleteNetwork ("toto", "tenant", "PROVIDER", "networkId", msoRequest, networkDeleted); + } catch (NetworkException e) { + assertTrue (e.getMessage ().contains ("Configuration Error")); + } + } +} diff --git a/adapters/mso-network-adapter/src/test/resources/logback-test.xml b/adapters/mso-network-adapter/src/test/resources/logback-test.xml new file mode 100644 index 0000000000..d2c17192ea --- /dev/null +++ b/adapters/mso-network-adapter/src/test/resources/logback-test.xml @@ -0,0 +1,48 @@ +<!-- + ============LICENSE_START======================================================= + ECOMP MSO + ================================================================================ + Copyright (C) 2017 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========================================================= + --> + +<configuration > + + + <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> + <encoder> + <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern> + </encoder> + </appender> + + + <logger name="com.att.eelf.audit" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.metrics" level="info" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <logger name="com.att.eelf.error" level="trace" additivity="false"> + <appender-ref ref="STDOUT" /> + </logger> + + <root level="info"> + <appender-ref ref="STDOUT" /> + </root> + + +</configuration> |