cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [22/50] [abbrv] Nvp and rest refactoring and more tests
Date Thu, 20 Feb 2014 19:17:28 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
index db8637c..fb103e8 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/guru/NiciraNvpGuestNetworkGuruTest.java
@@ -99,7 +99,7 @@ public class NiciraNvpGuestNetworkGuruTest {
         guru.agentMgr = agentmgr;
         guru.networkDao = netdao;
 
-        DataCenterVO dc = mock(DataCenterVO.class);
+        final DataCenterVO dc = mock(DataCenterVO.class);
         when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
         when(dc.getGuestNetworkCidr()).thenReturn("10.1.1.1/24");
 
@@ -108,12 +108,12 @@ public class NiciraNvpGuestNetworkGuruTest {
 
     @Test
     public void testCanHandle() {
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
 
@@ -142,34 +142,34 @@ public class NiciraNvpGuestNetworkGuruTest {
 
     @Test
     public void testDesign() {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
 
-        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
         when(device.getId()).thenReturn(1L);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
         when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
 
-        DeploymentPlan plan = mock(DeploymentPlan.class);
-        Network network = mock(Network.class);
-        Account account = mock(Account.class);
+        final DeploymentPlan plan = mock(DeploymentPlan.class);
+        final Network network = mock(Network.class);
+        final Account account = mock(Account.class);
 
-        Network designednetwork = guru.design(offering, plan, network, account);
+        final Network designednetwork = guru.design(offering, plan, network, account);
         assertTrue(designednetwork != null);
         assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Lswitch);
     }
 
     @Test
     public void testDesignNoElementOnPhysicalNetwork() {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
@@ -177,22 +177,22 @@ public class NiciraNvpGuestNetworkGuruTest {
         mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
-        DeploymentPlan plan = mock(DeploymentPlan.class);
-        Network network = mock(Network.class);
-        Account account = mock(Account.class);
+        final DeploymentPlan plan = mock(DeploymentPlan.class);
+        final Network network = mock(Network.class);
+        final Account account = mock(Account.class);
 
-        Network designednetwork = guru.design(offering, plan, network, account);
+        final Network designednetwork = guru.design(offering, plan, network, account);
         assertTrue(designednetwork == null);
     }
 
     @Test
     public void testDesignNoIsolationMethodSTT() {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"VLAN"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
@@ -200,57 +200,57 @@ public class NiciraNvpGuestNetworkGuruTest {
         mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Collections.<NiciraNvpDeviceVO> emptyList());
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
-        DeploymentPlan plan = mock(DeploymentPlan.class);
-        Network network = mock(Network.class);
-        Account account = mock(Account.class);
+        final DeploymentPlan plan = mock(DeploymentPlan.class);
+        final Network network = mock(Network.class);
+        final Account account = mock(Account.class);
 
-        Network designednetwork = guru.design(offering, plan, network, account);
+        final Network designednetwork = guru.design(offering, plan, network, account);
         assertTrue(designednetwork == null);
     }
 
     @Test
     public void testDesignNoConnectivityInOffering() {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
 
-        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
         when(device.getId()).thenReturn(1L);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
 
         when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(false);
 
-        DeploymentPlan plan = mock(DeploymentPlan.class);
-        Network network = mock(Network.class);
-        Account account = mock(Account.class);
+        final DeploymentPlan plan = mock(DeploymentPlan.class);
+        final Network network = mock(Network.class);
+        final Account account = mock(Account.class);
 
-        Network designednetwork = guru.design(offering, plan, network, account);
+        final Network designednetwork = guru.design(offering, plan, network, account);
         assertTrue(designednetwork == null);
     }
 
     @Test
     public void testImplement() throws InsufficientVirtualNetworkCapcityException {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
 
-        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
         when(device.getId()).thenReturn(1L);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -259,53 +259,53 @@ public class NiciraNvpGuestNetworkGuruTest {
 
         mock(DeploymentPlan.class);
 
-        NetworkVO network = mock(NetworkVO.class);
+        final NetworkVO network = mock(NetworkVO.class);
         when(network.getName()).thenReturn("testnetwork");
         when(network.getState()).thenReturn(State.Implementing);
         when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
 
-        DeployDestination dest = mock(DeployDestination.class);
+        final DeployDestination dest = mock(DeployDestination.class);
 
-        DataCenter dc = mock(DataCenter.class);
+        final DataCenter dc = mock(DataCenter.class);
         when(dest.getDataCenter()).thenReturn(dc);
 
-        HostVO niciraHost = mock(HostVO.class);
+        final HostVO niciraHost = mock(HostVO.class);
         when(hostdao.findById(anyLong())).thenReturn(niciraHost);
         when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
         when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
         when(niciraHost.getId()).thenReturn(NETWORK_ID);
 
         when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
-        Domain dom = mock(Domain.class);
+        final Domain dom = mock(Domain.class);
         when(dom.getName()).thenReturn("domain");
-        Account acc = mock(Account.class);
+        final Account acc = mock(Account.class);
         when(acc.getAccountName()).thenReturn("accountname");
-        ReservationContext res = mock(ReservationContext.class);
+        final ReservationContext res = mock(ReservationContext.class);
         when(res.getDomain()).thenReturn(dom);
         when(res.getAccount()).thenReturn(acc);
 
-        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        final CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
         when(answer.getResult()).thenReturn(true);
         when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
         when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
 
-        Network implementednetwork = guru.implement(network, offering, dest, res);
+        final Network implementednetwork = guru.implement(network, offering, dest, res);
         assertTrue(implementednetwork != null);
         verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
     }
 
     @Test
     public void testImplementWithCidr() throws InsufficientVirtualNetworkCapcityException {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
 
-        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
         when(device.getId()).thenReturn(1L);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -314,39 +314,39 @@ public class NiciraNvpGuestNetworkGuruTest {
 
         mock(DeploymentPlan.class);
 
-        NetworkVO network = mock(NetworkVO.class);
+        final NetworkVO network = mock(NetworkVO.class);
         when(network.getName()).thenReturn("testnetwork");
         when(network.getState()).thenReturn(State.Implementing);
         when(network.getGateway()).thenReturn("10.1.1.1");
         when(network.getCidr()).thenReturn("10.1.1.0/24");
         when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
 
-        DeployDestination dest = mock(DeployDestination.class);
+        final DeployDestination dest = mock(DeployDestination.class);
 
-        DataCenter dc = mock(DataCenter.class);
+        final DataCenter dc = mock(DataCenter.class);
         when(dest.getDataCenter()).thenReturn(dc);
 
-        HostVO niciraHost = mock(HostVO.class);
+        final HostVO niciraHost = mock(HostVO.class);
         when(hostdao.findById(anyLong())).thenReturn(niciraHost);
         when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
         when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
         when(niciraHost.getId()).thenReturn(NETWORK_ID);
 
         when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
-        Domain dom = mock(Domain.class);
+        final Domain dom = mock(Domain.class);
         when(dom.getName()).thenReturn("domain");
-        Account acc = mock(Account.class);
+        final Account acc = mock(Account.class);
         when(acc.getAccountName()).thenReturn("accountname");
-        ReservationContext res = mock(ReservationContext.class);
+        final ReservationContext res = mock(ReservationContext.class);
         when(res.getDomain()).thenReturn(dom);
         when(res.getAccount()).thenReturn(acc);
 
-        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        final CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
         when(answer.getResult()).thenReturn(true);
         when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
         when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
 
-        Network implementednetwork = guru.implement(network, offering, dest, res);
+        final Network implementednetwork = guru.implement(network, offering, dest, res);
         assertTrue(implementednetwork != null);
         assertTrue(implementednetwork.getCidr().equals("10.1.1.0/24"));
         assertTrue(implementednetwork.getGateway().equals("10.1.1.1"));
@@ -355,16 +355,16 @@ public class NiciraNvpGuestNetworkGuruTest {
 
     @Test
     public void testImplementURIException() throws InsufficientVirtualNetworkCapcityException {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
 
-        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
         when(device.getId()).thenReturn(1L);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -373,53 +373,53 @@ public class NiciraNvpGuestNetworkGuruTest {
 
         mock(DeploymentPlan.class);
 
-        NetworkVO network = mock(NetworkVO.class);
+        final NetworkVO network = mock(NetworkVO.class);
         when(network.getName()).thenReturn("testnetwork");
         when(network.getState()).thenReturn(State.Implementing);
         when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
 
-        DeployDestination dest = mock(DeployDestination.class);
+        final DeployDestination dest = mock(DeployDestination.class);
 
-        DataCenter dc = mock(DataCenter.class);
+        final DataCenter dc = mock(DataCenter.class);
         when(dest.getDataCenter()).thenReturn(dc);
 
-        HostVO niciraHost = mock(HostVO.class);
+        final HostVO niciraHost = mock(HostVO.class);
         when(hostdao.findById(anyLong())).thenReturn(niciraHost);
         when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
         when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
         when(niciraHost.getId()).thenReturn(NETWORK_ID);
 
         when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
-        Domain dom = mock(Domain.class);
+        final Domain dom = mock(Domain.class);
         when(dom.getName()).thenReturn("domain");
-        Account acc = mock(Account.class);
+        final Account acc = mock(Account.class);
         when(acc.getAccountName()).thenReturn("accountname");
-        ReservationContext res = mock(ReservationContext.class);
+        final ReservationContext res = mock(ReservationContext.class);
         when(res.getDomain()).thenReturn(dom);
         when(res.getAccount()).thenReturn(acc);
 
-        CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
+        final CreateLogicalSwitchAnswer answer = mock(CreateLogicalSwitchAnswer.class);
         when(answer.getResult()).thenReturn(true);
         //when(answer.getLogicalSwitchUuid()).thenReturn("aaaaa");
         when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
 
-        Network implementednetwork = guru.implement(network, offering, dest, res);
+        final Network implementednetwork = guru.implement(network, offering, dest, res);
         assertTrue(implementednetwork == null);
         verify(agentmgr, times(1)).easySend(eq(NETWORK_ID), (Command)any());
     }
 
     @Test
     public void testShutdown() throws InsufficientVirtualNetworkCapcityException, URISyntaxException {
-        PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
+        final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
         when(physnetdao.findById((Long)any())).thenReturn(physnet);
         when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] {"STT"}));
         when(physnet.getId()).thenReturn(NETWORK_ID);
 
-        NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
+        final NiciraNvpDeviceVO device = mock(NiciraNvpDeviceVO.class);
         when(nvpdao.listByPhysicalNetwork(NETWORK_ID)).thenReturn(Arrays.asList(new NiciraNvpDeviceVO[] {device}));
         when(device.getId()).thenReturn(1L);
 
-        NetworkOffering offering = mock(NetworkOffering.class);
+        final NetworkOffering offering = mock(NetworkOffering.class);
         when(offering.getId()).thenReturn(NETWORK_ID);
         when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
         when(offering.getGuestType()).thenReturn(GuestType.Isolated);
@@ -428,7 +428,7 @@ public class NiciraNvpGuestNetworkGuruTest {
 
         mock(DeploymentPlan.class);
 
-        NetworkVO network = mock(NetworkVO.class);
+        final NetworkVO network = mock(NetworkVO.class);
         when(network.getName()).thenReturn("testnetwork");
         when(network.getState()).thenReturn(State.Implementing);
         when(network.getBroadcastDomainType()).thenReturn(BroadcastDomainType.Lswitch);
@@ -436,31 +436,31 @@ public class NiciraNvpGuestNetworkGuruTest {
         when(network.getPhysicalNetworkId()).thenReturn(NETWORK_ID);
         when(netdao.findById(NETWORK_ID)).thenReturn(network);
 
-        DeployDestination dest = mock(DeployDestination.class);
+        final DeployDestination dest = mock(DeployDestination.class);
 
-        DataCenter dc = mock(DataCenter.class);
+        final DataCenter dc = mock(DataCenter.class);
         when(dest.getDataCenter()).thenReturn(dc);
 
-        HostVO niciraHost = mock(HostVO.class);
+        final HostVO niciraHost = mock(HostVO.class);
         when(hostdao.findById(anyLong())).thenReturn(niciraHost);
         when(niciraHost.getDetail("transportzoneuuid")).thenReturn("aaaa");
         when(niciraHost.getDetail("transportzoneisotype")).thenReturn("stt");
         when(niciraHost.getId()).thenReturn(NETWORK_ID);
 
         when(netmodel.findPhysicalNetworkId(anyLong(), (String)any(), (TrafficType)any())).thenReturn(NETWORK_ID);
-        Domain dom = mock(Domain.class);
+        final Domain dom = mock(Domain.class);
         when(dom.getName()).thenReturn("domain");
-        Account acc = mock(Account.class);
+        final Account acc = mock(Account.class);
         when(acc.getAccountName()).thenReturn("accountname");
-        ReservationContext res = mock(ReservationContext.class);
+        final ReservationContext res = mock(ReservationContext.class);
         when(res.getDomain()).thenReturn(dom);
         when(res.getAccount()).thenReturn(acc);
 
-        DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
+        final DeleteLogicalSwitchAnswer answer = mock(DeleteLogicalSwitchAnswer.class);
         when(answer.getResult()).thenReturn(true);
         when(agentmgr.easySend(eq(NETWORK_ID), (Command)any())).thenReturn(answer);
 
-        NetworkProfile implementednetwork = mock(NetworkProfile.class);
+        final NetworkProfile implementednetwork = mock(NetworkProfile.class);
         when(implementednetwork.getId()).thenReturn(NETWORK_ID);
         when(implementednetwork.getBroadcastUri()).thenReturn(new URI("lswitch:aaaa"));
         when(offering.getSpecifyVlan()).thenReturn(false);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
index 84b28fb..d4c6596 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NatRuleTest.java
@@ -31,22 +31,22 @@ public class NatRuleTest {
 
     @Test
     public void testNatRuleEncoding() {
-        Gson gson =
-            new GsonBuilder().registerTypeAdapter(NatRule.class, new com.cloud.network.nicira.NiciraNvpApi.NatRuleAdapter())
+        final Gson gson =
+            new GsonBuilder().registerTypeAdapter(NatRule.class, new NiciraNvpApi.NatRuleAdapter())
                 .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
                 .create();
 
-        DestinationNatRule rn1 = new DestinationNatRule();
+        final DestinationNatRule rn1 = new DestinationNatRule();
         rn1.setToDestinationIpAddress("10.10.10.10");
         rn1.setToDestinationPort(80);
-        Match mr1 = new Match();
+        final Match mr1 = new Match();
         mr1.setSourceIpAddresses("11.11.11.11/24");
         mr1.setEthertype("IPv4");
         mr1.setProtocol(6);
         rn1.setMatch(mr1);
 
-        String jsonString = gson.toJson(rn1);
-        NatRule dnr = gson.fromJson(jsonString, NatRule.class);
+        final String jsonString = gson.toJson(rn1);
+        final NatRule dnr = gson.fromJson(jsonString, NatRule.class);
 
         assertTrue(dnr instanceof DestinationNatRule);
         assertTrue(rn1.equals(dnr));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
index 7f8f471..ec4ce09 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiIT.java
@@ -19,14 +19,15 @@
 
 package com.cloud.network.nicira;
 
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
+import java.util.UUID;
 
-import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Test;
 
@@ -84,22 +85,22 @@ public class NiciraNvpApiIT {
                     scInList = iProfile;
                 }
             }
-            Assert.assertEquals("Read a Security Profile different from the one just created and updated",
+            assertEquals("Read a Security Profile different from the one just created and updated",
                     sProfile, scInList);
 
             // Read them filtered by uuid (get one)
             profiles = api.findSecurityProfile(sProfile.getUuid());
-            Assert.assertEquals("Read a Security Profile different from the one just created and updated",
+            assertEquals("Read a Security Profile different from the one just created and updated",
                     sProfile,
                     profiles.getResults().get(0));
-            Assert.assertEquals("Read a Security Profile filtered by unique id (UUID) with more than one item",
+            assertEquals("Read a Security Profile filtered by unique id (UUID) with more than one item",
                     1, profiles.getResults().size());
 
             // We can now delete the new entity
             api.deleteSecurityProfile(sProfile.getUuid());
         } catch (final NiciraNvpApiException e) {
             e.printStackTrace();
-            assertTrue("Errors creating Security Profile", false);
+            assertTrue("Errors in Security Profile CRUD", false);
         }
     }
 
@@ -145,22 +146,203 @@ public class NiciraNvpApiIT {
                     scInList = iAcl;
                 }
             }
-            Assert.assertEquals("Read a ACL different from the one just created and updated",
+            assertEquals("Read a ACL different from the one just created and updated",
                     acl, scInList);
 
             // Read them filtered by uuid (get one)
             acls = api.findAcl(acl.getUuid());
-            Assert.assertEquals("Read a ACL different from the one just created and updated",
+            assertEquals("Read a ACL different from the one just created and updated",
                     acl,
                     acls.getResults().get(0));
-            Assert.assertEquals("Read a ACL filtered by unique id (UUID) with more than one item",
+            assertEquals("Read a ACL filtered by unique id (UUID) with more than one item",
                     1, acls.getResults().size());
 
             // We can now delete the new entity
             api.deleteAcl(acl.getUuid());
         } catch (final NiciraNvpApiException e) {
             e.printStackTrace();
-            assertTrue("Errors creating ACL", false);
+            assertTrue("Errors in ACL CRUD", false);
         }
     }
+
+    @Test
+    public void testCRUDLogicalSwitch() throws NiciraNvpApiException {
+        LogicalSwitch logicalSwitch = new LogicalSwitch();
+        logicalSwitch.setDisplayName("LogicalSwitch"+timestamp);
+        logicalSwitch.setPortIsolationEnabled(true);
+        logicalSwitch.setReplicationMode("service");
+        logicalSwitch.setTags(new ArrayList<NiciraNvpTag>());
+        logicalSwitch.getTags().add(new NiciraNvpTag("anto", "hugo"));
+
+        // In the creation we don't get to specify UUID, href or schema: they don't exist yet
+
+        try {
+            logicalSwitch = api.createLogicalSwitch(logicalSwitch);
+
+            // We can now update the new entity
+            logicalSwitch.setDisplayName("UpdatedLogicalSwitch"+timestamp);
+            api.updateLogicalSwitch(logicalSwitch, logicalSwitch.getUuid());
+
+            // Read them all
+            NiciraNvpList<LogicalSwitch> logicalSwitches = api.findLogicalSwitch();
+            for(final LogicalSwitch iLogicalSwitch : logicalSwitches.getResults()) {
+                if (iLogicalSwitch.getUuid().equalsIgnoreCase(logicalSwitch.getUuid())) {
+                    assertEquals("Read a LogicalSwitch different from the one just created and updated",
+                            logicalSwitch, iLogicalSwitch);
+                }
+            }
+
+            // Read them filtered by uuid (get one)
+            logicalSwitches = api.findLogicalSwitch(logicalSwitch.getUuid());
+            assertEquals("Read a LogicalSwitch different from the one just created and updated",
+                    logicalSwitch,
+                    logicalSwitches.getResults().get(0));
+            assertEquals("Read a LogicalSwitch filtered by unique id (UUID) with more than one item",
+                    1, logicalSwitches.getResults().size());
+
+            // Before deleting the test LogicalSwitch, test its ports
+            final List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
+            tags.add(new NiciraNvpTag("cs_account", "OwnerName"));
+
+            LogicalSwitchPort logicalSwitchPort = new LogicalSwitchPort("LSwitchPort"+timestamp, tags, true);
+            logicalSwitchPort = api.createLogicalSwitchPort(logicalSwitch.getUuid(), logicalSwitchPort);
+
+            logicalSwitchPort.setDisplayName("UpdatedLSwitchPort"+timestamp);
+            api.updateLogicalSwitchPort(logicalSwitch.getUuid(), logicalSwitchPort);
+
+            final NiciraNvpList<LogicalSwitchPort> logicalSwitchePorts =
+                    api.findLogicalSwitchPortsByUuid(logicalSwitch.getUuid(), logicalSwitchPort.getUuid());
+            for(final LogicalSwitchPort iLSwitchPort : logicalSwitchePorts.getResults()) {
+                if (iLSwitchPort.getUuid().equalsIgnoreCase(logicalSwitchPort.getUuid())) {
+                    assertEquals("Read a LogicalSwitchPort different from the one just created and updated",
+                            logicalSwitchPort, iLSwitchPort);
+                }
+            }
+
+            // And finally test attachments
+            final String attachmentUuid = UUID.randomUUID().toString();
+            final VifAttachment vifAttachment = new VifAttachment(attachmentUuid);
+            api.updateLogicalSwitchPortAttachment(logicalSwitch.getUuid(), logicalSwitchPort.getUuid(),
+                    vifAttachment);
+
+            assertEquals("Read a LogicalSwitchPort by vifAttachment different than expected",
+                    api.findLogicalSwitchPortUuidByVifAttachmentUuid(logicalSwitch.getUuid(), vifAttachment.getVifUuid()),
+                            logicalSwitchPort.getUuid());
+
+            api.deleteLogicalSwitchPort(logicalSwitch.getUuid(), logicalSwitchPort.getUuid());
+
+            // We can now delete the new entity
+            api.deleteLogicalSwitch(logicalSwitch.getUuid());
+        } catch (final NiciraNvpApiException e) {
+            e.printStackTrace();
+            assertTrue("Errors in LogicalSwitch CRUD", false);
+        }
+    }
+
+    @Test
+    public void testCRUDLogicalRouter() throws NiciraNvpApiException {
+        LogicalRouter logicalRouter = new LogicalRouter();
+        logicalRouter.setDisplayName("LogicalRouter"+timestamp);
+        logicalRouter.setDistributed(true);
+        logicalRouter.setNatSynchronizationEnabled(true);
+        logicalRouter.setReplicationMode(LogicalRouter.REPLICATION_MODE_SERVICE);
+        final RoutingConfig routingConfig = new SingleDefaultRouteImplicitRoutingConfig(
+                new RouterNextHop("192.168.10.20"));
+        logicalRouter.setRoutingConfig(routingConfig);
+
+        // In the creation we don't get to specify UUID, href or schema: they don't exist yet
+
+        try {
+            logicalRouter = api.createLogicalRouter(logicalRouter);
+
+            // We can now update the new entity
+            logicalRouter.setDisplayName("UpdatedLogicalSwitch"+timestamp);
+            api.updateLogicalRouter(logicalRouter, logicalRouter.getUuid());
+
+            // Read them all
+            NiciraNvpList<LogicalRouter> logicalRouters = api.findLogicalRouter();
+            LogicalRouter lsInList = null;
+            for(final LogicalRouter iLogicalRouter : logicalRouters.getResults()) {
+                if (iLogicalRouter.getUuid().equalsIgnoreCase(logicalRouter.getUuid())) {
+                    lsInList = iLogicalRouter;
+                }
+            }
+            assertEquals("Read a LogicalRouter different from the one just created and updated",
+                    logicalRouter, lsInList);
+
+            // Read them filtered by uuid (get one)
+            logicalRouters = api.findLogicalRouter(logicalRouter.getUuid());
+            assertEquals("Read a LogicalRouter different from the one just created and updated",
+                    logicalRouter,
+                    logicalRouters.getResults().get(0));
+            assertEquals("Read a LogicalRouter filtered by unique id (UUID) with more than one item",
+                    1, logicalRouters.getResults().size());
+
+            assertEquals("", logicalRouters.getResults().get(0),
+                    api.findOneLogicalRouterByUuid(logicalRouter.getUuid()));
+
+            // Before deleting the test LogicalRouter, test its ports
+            final List<NiciraNvpTag> tags = new ArrayList<NiciraNvpTag>();
+            tags.add(new NiciraNvpTag("cs_account", "OwnerName"));
+
+            LogicalRouterPort logicalRouterPort = new LogicalRouterPort();
+            logicalRouterPort.setDisplayName("LRouterPort"+timestamp);
+            logicalRouterPort.setTags(tags);
+            logicalRouterPort.setAdminStatusEnabled(true);
+            logicalRouterPort.setPortno(1024);
+            logicalRouterPort.setMacAddress("00:00:00:00:00:00");
+
+            final List<String> ipAddresses = new ArrayList<String>();
+            // Add some ips to this list
+            logicalRouterPort.setIpAddresses(ipAddresses);
+            logicalRouterPort = api.createLogicalRouterPort(logicalRouter.getUuid(), logicalRouterPort);
+
+            logicalRouterPort.setDisplayName("UpdatedLRouterPort"+timestamp);
+            api.updateLogicalRouterPort(logicalRouter.getUuid(), logicalRouterPort);
+
+            final NiciraNvpList<LogicalRouterPort> logicalRouterePorts =
+                    api.findLogicalRouterPortsByUuid(logicalRouter.getUuid(), logicalRouterPort.getUuid());
+            for(final LogicalRouterPort iLRouterPort : logicalRouterePorts.getResults()) {
+                if (iLRouterPort.getUuid().equalsIgnoreCase(logicalRouterPort.getUuid())) {
+                    assertEquals("Read a LogicalRouterPort different from the one just created and updated",
+                            logicalRouterPort, iLRouterPort);
+                }
+            }
+
+            UUID.randomUUID().toString();
+
+            // Test CRUD for Nat Rules
+            SourceNatRule snr = new SourceNatRule();
+            snr.setToSourceIpAddressMin("192.168.10.10");
+            snr.setToSourceIpAddressMax("192.168.10.20");
+            snr.setOrder(200);
+            final Match match = new Match();
+            match.setSourceIpAddresses("192.168.150.150");
+            snr.setMatch(match);
+            snr = (SourceNatRule) api.createLogicalRouterNatRule(logicalRouter.getUuid(), snr);
+            snr.setToSourceIpAddressMax("192.168.10.30");
+            api.updateLogicalRouterNatRule(logicalRouter.getUuid(), snr);
+
+            api.findNatRulesByLogicalRouterUuid(logicalRouter.getUuid());
+            api.deleteLogicalRouterNatRule(logicalRouter.getUuid(), snr.getUuid());
+
+            api.deleteLogicalRouterPort(logicalRouter.getUuid(), logicalRouterPort.getUuid());
+
+            // We can now delete the new entity
+            api.deleteLogicalRouter(logicalRouter.getUuid());
+        } catch (final NiciraNvpApiException e) {
+            e.printStackTrace();
+            assertTrue("Errors in LogicalRouter CRUD", false);
+        }
+    }
+
+    @Test
+    public void testGetControlClusterStatus() throws NiciraNvpApiException {
+        final ControlClusterStatus controlClusterStatus = api.getControlClusterStatus();
+        final String clusterStatus = controlClusterStatus.getClusterStatus();
+        final boolean correctStatus = (clusterStatus.equalsIgnoreCase("stable") ||
+                clusterStatus.equalsIgnoreCase("joining") || clusterStatus.equalsIgnoreCase("unstable"));
+        assertTrue("Not recognizable cluster status", correctStatus);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
index 13d970c..fe41545 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraNvpApiTest.java
@@ -19,457 +19,289 @@
 
 package com.cloud.network.nicira;
 
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
 
 import java.io.IOException;
-import java.util.Collections;
 
-import org.apache.commons.httpclient.Header;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.methods.DeleteMethod;
-import org.apache.commons.httpclient.methods.GetMethod;
-import org.apache.commons.httpclient.methods.PostMethod;
-import org.apache.commons.httpclient.methods.PutMethod;
-import org.apache.commons.httpclient.params.HttpClientParams;
-import org.apache.commons.httpclient.NameValuePair;
-import org.apache.http.HttpStatus;
-import org.junit.Before;
 import org.junit.Test;
 
-public class NiciraNvpApiTest {
-    protected static final String UUID = "aaaa";
-    protected static final String UUID2 = "bbbb";
-    protected static final String UUID_SEC_PROFILE_URI = NiciraNvpApi.SEC_PROFILE_URI_PREFIX + "/aaaa";
-    protected static final String SCHEMA = "myTestSchema";
-    protected static final String SCHEMA2 = "myTestSchema2";
-    protected static final String HREF = "myTestHref";
-    protected static final String HREF2 = "myTestHref2";
-    protected static final String DISPLAY_NAME = "myTestName";
-    protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
-    protected static final String SEC_PROFILE_JSON_RESPONSE =
-            "{\"uuid\" : \"aaaa\","
-            + "\"display_name\" : \"myTestName\","
-            + "\"href\" : \"myTestHref\","
-            + "\"schema\" : \"myTestSchema\"}";
-
-    protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
-            + "\"display_name\" : \"myTestName\","
-            + "\"href\" : \"myTestHref\","
-            + "\"schema\" : \"myTestSchema\"},"
-            + "{ \"uuid\" : \"bbbb\","
-            + "\"display_name\" : \"myTestName2\","
-            + "\"href\" : \"myTestHref2\","
-            + "\"schema\" : \"myTestSchema2\"}],"
-            + "\"result_count\": 2}";
-
-    NiciraNvpApi api;
-    HttpClient client = mock(HttpClient.class);
-    HttpMethod method;
-    String type;
-    String uri;
-
-    @Before
-    public void setUp() {
-        final HttpClientParams hmp = mock(HttpClientParams.class);
-        when(client.getParams()).thenReturn(hmp);
-        api = new NiciraNvpApi() {
-            @Override
-            protected HttpClient createHttpClient() {
-                return client;
-            }
-
-            @Override
-            protected HttpMethod createMethod(final String newType, final String newUri) {
-                type = newType;
-                uri = newUri;
-                return method;
-            }
-        };
-        api.setAdminCredentials("admin", "adminpass");
-        api.setControllerAddress("localhost");
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteLoginWithoutHostname() throws NiciraNvpApiException {
-        api.setControllerAddress(null);
-        api.login();
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteLoginWithoutCredentials() throws NiciraNvpApiException {
-        api.setAdminCredentials(null, null);
-        api.login();
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteUpdateObjectWithoutHostname() throws NiciraNvpApiException {
-        api.setControllerAddress(null);
-        api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteUpdateObjectWithoutCredentials() throws NiciraNvpApiException {
-        api.setAdminCredentials(null, null);
-        api.executeUpdateObject(new String(), "/", Collections.<String, String> emptyMap());
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteCreateObjectWithoutHostname() throws NiciraNvpApiException {
-        api.setControllerAddress(null);
-        api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteCreateObjectWithoutCredentials() throws NiciraNvpApiException {
-        api.setAdminCredentials(null, null);
-        api.executeCreateObject(new String(), String.class, "/", Collections.<String, String> emptyMap());
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteDeleteObjectWithoutHostname() throws NiciraNvpApiException {
-        api.setControllerAddress(null);
-        api.executeDeleteObject("/");
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteDeleteObjectWithoutCredentials() throws NiciraNvpApiException {
-        api.setAdminCredentials(null, null);
-        api.executeDeleteObject("/");
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteRetrieveObjectWithoutHostname() throws NiciraNvpApiException {
-        api.setControllerAddress(null);
-        api.executeRetrieveObject(String.class, "/", Collections.<String, String> emptyMap());
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteRetrieveObjectWithoutCredentials() throws NiciraNvpApiException {
-        api.setAdminCredentials(null, null);
-        api.executeDeleteObject("/");
-    }
-
-    @Test
-    public void executeMethodTest() throws NiciraNvpApiException {
-        final GetMethod gm = mock(GetMethod.class);
-
-        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        api.executeMethod(gm);
-        verify(gm, times(1)).getStatusCode();
-    }
-
-    /* Bit of a roundabout way to ensure that login is called after an un authorized result
-     * It not possible to properly mock login()
-     */
-    @Test(expected = NiciraNvpApiException.class)
-    public void executeMethodTestWithLogin() throws NiciraNvpApiException, HttpException, IOException {
-        final GetMethod gm = mock(GetMethod.class);
-        when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
-        when(gm.getStatusCode()).thenReturn(HttpStatus.SC_UNAUTHORIZED).thenReturn(HttpStatus.SC_UNAUTHORIZED);
-        api.executeMethod(gm);
-        verify(gm, times(1)).getStatusCode();
-    }
-
-    @Test
-    public void testExecuteCreateObject() throws NiciraNvpApiException, IOException {
-        LogicalSwitch ls = new LogicalSwitch();
-        method = mock(PostMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
-        when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
-        ls = api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-        assertTrue(UUID.equals(ls.getUuid()));
-        verify(method, times(1)).releaseConnection();
-
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteCreateObjectFailure() throws NiciraNvpApiException, IOException {
-        LogicalSwitch ls = new LogicalSwitch();
-        method = mock(PostMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-        final Header header = mock(Header.class);
-        when(header.getValue()).thenReturn("text/html");
-        when(method.getResponseHeader("Content-Type")).thenReturn(header);
-        when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-        when(method.isRequestSent()).thenReturn(true);
-        try {
-            ls = api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteCreateObjectException() throws NiciraNvpApiException, IOException {
-        LogicalSwitch ls = new LogicalSwitch();
-        when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
-        method = mock(PostMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-        final Header header = mock(Header.class);
-        when(header.getValue()).thenReturn("text/html");
-        when(method.getResponseHeader("Content-Type")).thenReturn(header);
-        when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-        try {
-            ls = api.executeCreateObject(ls, LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
-    }
+import com.google.gson.Gson;
+import com.google.gson.JsonParseException;
 
-    @Test
-    public void testExecuteUpdateObject() throws NiciraNvpApiException, IOException {
-        final LogicalSwitch ls = new LogicalSwitch();
-        method = mock(PutMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-        verify(method, times(1)).releaseConnection();
-        verify(client, times(1)).executeMethod(method);
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteUpdateObjectFailure() throws NiciraNvpApiException, IOException {
-        final LogicalSwitch ls = new LogicalSwitch();
-        method = mock(PutMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-        final Header header = mock(Header.class);
-        when(header.getValue()).thenReturn("text/html");
-        when(method.getResponseHeader("Content-Type")).thenReturn(header);
-        when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-        when(method.isRequestSent()).thenReturn(true);
-        try {
-            api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
-    }
-
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteUpdateObjectException() throws NiciraNvpApiException, IOException {
-        final LogicalSwitch ls = new LogicalSwitch();
-        method = mock(PutMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        when(client.executeMethod((HttpMethod)any())).thenThrow(new IOException());
-        try {
-            api.executeUpdateObject(ls, "/", Collections.<String, String> emptyMap());
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
-    }
-
-    @Test
-    public void testExecuteDeleteObject() throws NiciraNvpApiException, IOException {
-        method = mock(DeleteMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-        api.executeDeleteObject("/");
-        verify(method, times(1)).releaseConnection();
-        verify(client, times(1)).executeMethod(method);
-    }
+public class NiciraNvpApiTest {
+//    protected static final String UUID = "aaaa";
+//    protected static final String UUID2 = "bbbb";
+//    protected static final String UUID_SEC_PROFILE_URI = NiciraNvpApi.SEC_PROFILE_URI_PREFIX + "/aaaa";
+//    protected static final String SCHEMA = "myTestSchema";
+//    protected static final String SCHEMA2 = "myTestSchema2";
+//    protected static final String HREF = "myTestHref";
+//    protected static final String HREF2 = "myTestHref2";
+//    protected static final String DISPLAY_NAME = "myTestName";
+//    protected static final String UUID_JSON_RESPONSE = "{\"uuid\" : \"aaaa\"}";
+//    protected static final String SEC_PROFILE_JSON_RESPONSE =
+//            "{\"uuid\" : \"aaaa\","
+//            + "\"display_name\" : \"myTestName\","
+//            + "\"href\" : \"myTestHref\","
+//            + "\"schema\" : \"myTestSchema\"}";
+//
+//    protected static final String SEC_PROFILE_LIST_JSON_RESPONSE = "{\"results\" : [{\"uuid\" : \"aaaa\","
+//            + "\"display_name\" : \"myTestName\","
+//            + "\"href\" : \"myTestHref\","
+//            + "\"schema\" : \"myTestSchema\"},"
+//            + "{ \"uuid\" : \"bbbb\","
+//            + "\"display_name\" : \"myTestName2\","
+//            + "\"href\" : \"myTestHref2\","
+//            + "\"schema\" : \"myTestSchema2\"}],"
+//            + "\"result_count\": 2}";
+//
+//    NiciraNvpApi api;
+//    HttpClient client = mock(HttpClient.class);
+//    HttpMethod method;
+//    String type;
+//    String uri;
+//
+//    @Before
+//    public void setUp() {
+//        final HttpClientParams hmp = mock(HttpClientParams.class);
+//        when(client.getParams()).thenReturn(hmp);
+//        api = new NiciraNvpApi();
+//
+//        api.restConnector = new RESTServiceConnector() {
+//            @Override
+//            public HttpClient createHttpClient() {
+//                return client;
+//            }
+//
+//            @Override
+//            public HttpMethod createMethod(final String newType, final String newUri) {
+//                type = newType;
+//                uri = newUri;
+//                return method;
+//            }
+//        };
+//
+//        api.setAdminCredentials("admin", "adminpass");
+//        api.setControllerAddress("localhost");
+//    }
+//
+//    @Test
+//    public void testFindSecurityProfile() throws NiciraNvpApiException, IOException {
+//        // Prepare
+//        method = mock(GetMethod.class);
+//        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+//        when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
+//        final NameValuePair[] queryString = new NameValuePair[]{
+//                new NameValuePair("fields","*")};
+//
+//        // Execute
+//        final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile();
+//
+//        // Assert
+//        verify(method, times(1)).releaseConnection();
+//        verify(method, times(1)).setQueryString(queryString);
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                UUID, actualProfiles.getResults().get(0).getUuid());
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                HREF, actualProfiles.getResults().get(0).getHref());
+//        assertEquals("Wrong Schema in the newly created SecurityProfile",
+//                SCHEMA, actualProfiles.getResults().get(0).getSchema());
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                UUID2, actualProfiles.getResults().get(1).getUuid());
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                HREF2, actualProfiles.getResults().get(1).getHref());
+//        assertEquals("Wrong Schema in the newly created SecurityProfile",
+//                SCHEMA2, actualProfiles.getResults().get(1).getSchema());
+//        assertEquals("Wrong Schema in the newly created SecurityProfile",
+//                2, actualProfiles.getResultCount());
+//        assertEquals("Wrong URI for SecurityProfile creation REST service",
+//                NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+//        assertEquals("Wrong URI for SecurityProfile creation REST service",
+//                NiciraNvpApi.GET_METHOD_TYPE, type);
+//    }
+//
+//    @Test
+//    public void testFindSecurityProfileByUuid() throws NiciraNvpApiException, IOException {
+//        // Prepare
+//        method = mock(GetMethod.class);
+//        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+//        when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
+//        final NameValuePair[] queryString = new NameValuePair[]{
+//                new NameValuePair("uuid", UUID),
+//                new NameValuePair("fields","*")
+//        };
+//
+//        // Execute
+//        final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
+//
+//        // Assert
+//        verify(method, times(1)).releaseConnection();
+//        verify(method, times(1)).setQueryString(queryString);
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                UUID, actualProfiles.getResults().get(0).getUuid());
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                HREF, actualProfiles.getResults().get(0).getHref());
+//        assertEquals("Wrong Schema in the newly created SecurityProfile",
+//                SCHEMA, actualProfiles.getResults().get(0).getSchema());
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                UUID2, actualProfiles.getResults().get(1).getUuid());
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                HREF2, actualProfiles.getResults().get(1).getHref());
+//        assertEquals("Wrong Schema in the newly created SecurityProfile",
+//                SCHEMA2, actualProfiles.getResults().get(1).getSchema());
+//        assertEquals("Wrong Schema in the newly created SecurityProfile",
+//                2, actualProfiles.getResultCount());
+//        assertEquals("Wrong URI for SecurityProfile creation REST service",
+//                NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+//        assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+//                NiciraNvpApi.GET_METHOD_TYPE, type);
+//    }
+//
+//    @Test
+//    public void testCreateSecurityProfile() throws NiciraNvpApiException, IOException {
+//        // Prepare
+//        final SecurityProfile inputSecProfile = new SecurityProfile();
+//        method = mock(PostMethod.class);
+//        when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
+//        when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_JSON_RESPONSE);
+//
+//        // Execute
+//        final SecurityProfile actualSecProfile = api.createSecurityProfile(inputSecProfile);
+//
+//        // Assert
+//        verify(method, times(1)).releaseConnection();
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                UUID, actualSecProfile.getUuid());
+//        assertEquals("Wrong Uuid in the newly created SecurityProfile",
+//                HREF, actualSecProfile.getHref());
+//        assertEquals("Wrong Schema in the newly created SecurityProfile",
+//                SCHEMA, actualSecProfile.getSchema());
+//        assertEquals("Wrong URI for SecurityProfile creation REST service",
+//                NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
+//        assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+//                NiciraNvpApi.POST_METHOD_TYPE, type);
+//    }
+//
+//    @Test
+//    public void testUpdateSecurityProfile() throws NiciraNvpApiException, IOException {
+//        // Prepare
+//        final SecurityProfile inputSecProfile = new SecurityProfile();
+//        method = mock(PutMethod.class);
+//        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+//
+//        // Execute
+//        api.updateSecurityProfile(inputSecProfile, UUID);
+//
+//        // Assert
+//        verify(method, times(1)).releaseConnection();
+//        assertEquals("Wrong URI for SecurityProfile creation REST service",
+//                UUID_SEC_PROFILE_URI, uri);
+//        assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
+//                NiciraNvpApi.PUT_METHOD_TYPE, type);
+//    }
+//
+//    @Test
+//    public void testDeleteSecurityProfile() throws NiciraNvpApiException, IOException {
+//        // Prepare
+//        method = mock(DeleteMethod.class);
+//        when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+//
+//        // Execute
+//        api.deleteSecurityProfile(UUID);
+//
+//        // Assert
+//        verify(method, times(1)).releaseConnection();
+//        assertEquals("Wrong URI for SecurityProfile deletion REST service", UUID_SEC_PROFILE_URI, uri);
+//        assertEquals("Wrong HTTP method for SecurityProfile deletion REST service", NiciraNvpApi.DELETE_METHOD_TYPE, type);
+//    }
+
+    @Test(expected = JsonParseException.class)
+    public void testRoutingConfigAdapterNoType() throws NiciraNvpApiException, IOException {
+        // Prepare
+        final NiciraNvpApi api = new NiciraNvpApi();
+        final Gson gson = api.restConnector.getGson();
 
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteDeleteObjectFailure() throws NiciraNvpApiException, IOException {
-        method = mock(DeleteMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-        final Header header = mock(Header.class);
-        when(header.getValue()).thenReturn("text/html");
-        when(method.getResponseHeader("Content-Type")).thenReturn(header);
-        when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-        when(method.isRequestSent()).thenReturn(true);
-        try {
-            api.executeDeleteObject("/");
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
-    }
+        // Execute
+        gson.fromJson("{}", RoutingConfig.class);
 
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteDeleteObjectException() throws NiciraNvpApiException, IOException {
-        method = mock(DeleteMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
-        when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
-        try {
-            api.executeDeleteObject("/");
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
+        // Assert: JsonParseException should be thrown
     }
 
-    @Test
-    public void testExecuteRetrieveObject() throws NiciraNvpApiException, IOException {
-        method = mock(GetMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
-        api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-        verify(method, times(1)).releaseConnection();
-        verify(client, times(1)).executeMethod(method);
-    }
+    @Test(expected = JsonParseException.class)
+    public void testRoutingConfigAdapterWrongType() throws NiciraNvpApiException, IOException {
+        // Prepare
+        final NiciraNvpApi api = new NiciraNvpApi();
+        final Gson gson = api.restConnector.getGson();
 
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteRetrieveObjectFailure() throws NiciraNvpApiException, IOException {
-        method = mock(GetMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_INTERNAL_SERVER_ERROR);
-        when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
-        final Header header = mock(Header.class);
-        when(header.getValue()).thenReturn("text/html");
-        when(method.getResponseHeader("Content-Type")).thenReturn(header);
-        when(method.getResponseBodyAsString()).thenReturn("Off to timbuktu, won't be back later.");
-        when(method.isRequestSent()).thenReturn(true);
-        try {
-            api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
-    }
+        // Execute
+        gson.fromJson("{type : \"WrongType\"}", RoutingConfig.class);
 
-    @Test(expected = NiciraNvpApiException.class)
-    public void testExecuteRetrieveObjectException() throws NiciraNvpApiException, IOException {
-        method = mock(GetMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        when(method.getResponseBodyAsString()).thenReturn(UUID_JSON_RESPONSE);
-        when(client.executeMethod((HttpMethod)any())).thenThrow(new HttpException());
-        try {
-            api.executeRetrieveObject(LogicalSwitch.class, "/", Collections.<String, String> emptyMap());
-        } finally {
-            verify(method, times(1)).releaseConnection();
-        }
+        // Assert: JsonParseException should be thrown
     }
 
-    @Test
-    public void testFindSecurityProfile() throws NiciraNvpApiException, IOException {
+    @Test()
+    public void testRoutingConfigAdapter() throws NiciraNvpApiException, IOException {
         // Prepare
-        method = mock(GetMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
-        final NameValuePair[] queryString = new NameValuePair[]{
-                new NameValuePair("fields","*")};
+        final NiciraNvpApi api = new NiciraNvpApi();
+        final Gson gson = api.restConnector.getGson();
 
         // Execute
-        final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile();
+        final SingleDefaultRouteImplicitRoutingConfig singleDefaultRouteImplicitRoutingConfig =
+                (SingleDefaultRouteImplicitRoutingConfig) gson.fromJson("{type : \"SingleDefaultRouteImplicitRoutingConfig\"}", RoutingConfig.class);
 
-        // Assert
-        verify(method, times(1)).releaseConnection();
-        verify(method, times(1)).setQueryString(queryString);
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                UUID, actualProfiles.getResults().get(0).getUuid());
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                HREF, actualProfiles.getResults().get(0).getHref());
-        assertEquals("Wrong Schema in the newly created SecurityProfile",
-                SCHEMA, actualProfiles.getResults().get(0).getSchema());
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                UUID2, actualProfiles.getResults().get(1).getUuid());
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                HREF2, actualProfiles.getResults().get(1).getHref());
-        assertEquals("Wrong Schema in the newly created SecurityProfile",
-                SCHEMA2, actualProfiles.getResults().get(1).getSchema());
-        assertEquals("Wrong Schema in the newly created SecurityProfile",
-                2, actualProfiles.getResultCount());
-        assertEquals("Wrong URI for SecurityProfile creation REST service",
-                NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
-        assertEquals("Wrong URI for SecurityProfile creation REST service",
-                NiciraNvpApi.GET_METHOD_TYPE, type);
+        // Assert: JsonParseException should be thrown
+        assertEquals("", SingleDefaultRouteImplicitRoutingConfig.class, singleDefaultRouteImplicitRoutingConfig.getClass());
     }
 
-    @Test
-    public void testFindSecurityProfileByUuid() throws NiciraNvpApiException, IOException {
+    @Test(expected = JsonParseException.class)
+    public void testNatRuleAdapterNoType() throws NiciraNvpApiException, IOException {
         // Prepare
-        method = mock(GetMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
-        when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_LIST_JSON_RESPONSE);
-        final NameValuePair[] queryString = new NameValuePair[]{
-                new NameValuePair("uuid", UUID),
-                new NameValuePair("fields","*")
-        };
+        final NiciraNvpApi api = new NiciraNvpApi();
+        final Gson gson = api.restConnector.getGson();
 
         // Execute
-        final NiciraNvpList<SecurityProfile> actualProfiles = api.findSecurityProfile(UUID);
+        gson.fromJson("{}", NatRule.class);
 
-        // Assert
-        verify(method, times(1)).releaseConnection();
-        verify(method, times(1)).setQueryString(queryString);
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                UUID, actualProfiles.getResults().get(0).getUuid());
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                HREF, actualProfiles.getResults().get(0).getHref());
-        assertEquals("Wrong Schema in the newly created SecurityProfile",
-                SCHEMA, actualProfiles.getResults().get(0).getSchema());
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                UUID2, actualProfiles.getResults().get(1).getUuid());
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                HREF2, actualProfiles.getResults().get(1).getHref());
-        assertEquals("Wrong Schema in the newly created SecurityProfile",
-                SCHEMA2, actualProfiles.getResults().get(1).getSchema());
-        assertEquals("Wrong Schema in the newly created SecurityProfile",
-                2, actualProfiles.getResultCount());
-        assertEquals("Wrong URI for SecurityProfile creation REST service",
-                NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
-        assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
-                NiciraNvpApi.GET_METHOD_TYPE, type);
+        // Assert: JsonParseException should be thrown
     }
 
-    @Test
-    public void testCreateSecurityProfile() throws NiciraNvpApiException, IOException {
+    @Test(expected = JsonParseException.class)
+    public void testNatRuleAdapterWrongType() throws NiciraNvpApiException, IOException {
         // Prepare
-        final SecurityProfile inputSecProfile = new SecurityProfile();
-        method = mock(PostMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_CREATED);
-        when(method.getResponseBodyAsString()).thenReturn(SEC_PROFILE_JSON_RESPONSE);
+        final NiciraNvpApi api = new NiciraNvpApi();
+        final Gson gson = api.restConnector.getGson();
 
         // Execute
-        final SecurityProfile actualSecProfile = api.createSecurityProfile(inputSecProfile);
+        gson.fromJson("{type : \"WrongType\"}", NatRule.class);
 
-        // Assert
-        verify(method, times(1)).releaseConnection();
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                UUID, actualSecProfile.getUuid());
-        assertEquals("Wrong Uuid in the newly created SecurityProfile",
-                HREF, actualSecProfile.getHref());
-        assertEquals("Wrong Schema in the newly created SecurityProfile",
-                SCHEMA, actualSecProfile.getSchema());
-        assertEquals("Wrong URI for SecurityProfile creation REST service",
-                NiciraNvpApi.SEC_PROFILE_URI_PREFIX, uri);
-        assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
-                NiciraNvpApi.POST_METHOD_TYPE, type);
+        // Assert: JsonParseException should be thrown
     }
 
-    @Test
-    public void testUpdateSecurityProfile() throws NiciraNvpApiException, IOException {
+    @Test()
+    public void testRoutingConfigAdapterWithSourceNatRule() throws NiciraNvpApiException, IOException {
         // Prepare
-        final SecurityProfile inputSecProfile = new SecurityProfile();
-        method = mock(PutMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_OK);
+        final NiciraNvpApi api = new NiciraNvpApi();
+        final Gson gson = api.restConnector.getGson();
 
         // Execute
-        api.updateSecurityProfile(inputSecProfile, UUID);
+        final SourceNatRule sourceNatRule =
+                (SourceNatRule) gson.fromJson("{type : \"SourceNatRule\"}", NatRule.class);
 
-        // Assert
-        verify(method, times(1)).releaseConnection();
-        assertEquals("Wrong URI for SecurityProfile creation REST service",
-                UUID_SEC_PROFILE_URI, uri);
-        assertEquals("Wrong HTTP method for SecurityProfile creation REST service",
-                NiciraNvpApi.PUT_METHOD_TYPE, type);
+        // Assert: JsonParseException should be thrown
+        assertEquals("", SourceNatRule.class, sourceNatRule.getClass());
     }
 
-    @Test
-    public void testDeleteSecurityProfile() throws NiciraNvpApiException, IOException {
+    @Test()
+    public void testRoutingConfigAdapterWithDestinationNatRule() throws NiciraNvpApiException, IOException {
         // Prepare
-        method = mock(DeleteMethod.class);
-        when(method.getStatusCode()).thenReturn(HttpStatus.SC_NO_CONTENT);
+        final NiciraNvpApi api = new NiciraNvpApi();
+        final Gson gson = api.restConnector.getGson();
 
         // Execute
-        api.deleteSecurityProfile(UUID);
+        final DestinationNatRule destinationNatRule =
+                (DestinationNatRule) gson.fromJson("{type : \"DestinationNatRule\"}", NatRule.class);
 
-        // Assert
-        verify(method, times(1)).releaseConnection();
-        assertEquals("Wrong URI for SecurityProfile deletion REST service",
-                UUID_SEC_PROFILE_URI, uri);
-        assertEquals("Wrong HTTP method for SecurityProfile deletion REST service",
-                NiciraNvpApi.DELETE_METHOD_TYPE, type);
+        // Assert: JsonParseException should be thrown
+        assertEquals("", DestinationNatRule.class, destinationNatRule.getClass());
     }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/510972ab/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
index 58dcedc..7a31264 100644
--- a/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
+++ b/plugins/network-elements/nicira-nvp/test/com/cloud/network/nicira/NiciraTagTest.java
@@ -26,21 +26,21 @@ import org.junit.Test;
 public class NiciraTagTest {
     @Test
     public void testCreateTag() {
-        NiciraNvpTag tag = new NiciraNvpTag("scope", "tag");
+        final NiciraNvpTag tag = new NiciraNvpTag("scope", "tag");
         assertEquals("scope part set", "scope", tag.getScope());
         assertEquals("tag part set", "tag", tag.getTag());
     }
 
     @Test
     public void testCreateLongTag() {
-        NiciraNvpTag tag = new NiciraNvpTag("scope", "verylongtagthatshouldattheminimumexceedthefortycharacterlenght");
+        final NiciraNvpTag tag = new NiciraNvpTag("scope", "verylongtagthatshouldattheminimumexceedthefortycharacterlenght");
         assertEquals("scope part set", "scope", tag.getScope());
         assertEquals("tag part set", "verylongtagthatshouldattheminimumexceedt", tag.getTag());
     }
 
     @Test
     public void testSetTag() {
-        NiciraNvpTag tag = new NiciraNvpTag();
+        final NiciraNvpTag tag = new NiciraNvpTag();
         tag.setScope("scope");
         tag.setTag("tag");
         assertEquals("scope part set", "scope", tag.getScope());
@@ -49,7 +49,7 @@ public class NiciraTagTest {
 
     @Test
     public void testSetLongTag() {
-        NiciraNvpTag tag = new NiciraNvpTag();
+        final NiciraNvpTag tag = new NiciraNvpTag();
         tag.setScope("scope");
         tag.setTag("verylongtagthatshouldattheminimumexceedthefortycharacterlenght");
         assertEquals("scope part set", "scope", tag.getScope());


Mime
View raw message