cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From muralire...@apache.org
Subject [22/50] [abbrv] git commit: updated refs/heads/regionvpc to edf12eb
Date Tue, 11 Mar 2014 14:26:44 GMT
findbugs: String for Service type mismatch (plus test for dummy  data)

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/1075bed0
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/1075bed0
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/1075bed0

Branch: refs/heads/regionvpc
Commit: 1075bed06c32f14152a8c5c7e534955392e5f662
Parents: 07102b4
Author: Daan Hoogland <daan@onecht.net>
Authored: Mon Mar 10 10:44:10 2014 +0100
Committer: Daan Hoogland <daan@onecht.net>
Committed: Mon Mar 10 10:44:10 2014 +0100

----------------------------------------------------------------------
 .../com/cloud/network/vpc/VpcManagerImpl.java   |  4 +-
 .../cloud/network/vpc/VpcManagerImplTest.java   | 53 ++++++++++++++++++++
 2 files changed, 55 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1075bed0/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 403b95e..762cc6f 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -424,14 +424,14 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager,
VpcProvis
         List<VpcOfferingServiceMapVO> map = _vpcOffSvcMapDao.listByVpcOffId(vpcOffId);
 
         for (VpcOfferingServiceMapVO instance : map) {
-            String service = instance.getService();
+            Service service = Service.getService(instance.getService());
             Set<Provider> providers;
             providers = serviceProviderMap.get(service);
             if (providers == null) {
                 providers = new HashSet<Provider>();
             }
             providers.add(Provider.getProvider(instance.getProvider()));
-            serviceProviderMap.put(Service.getService(service), providers);
+            serviceProviderMap.put(service, providers);
         }
 
         return serviceProviderMap;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/1075bed0/server/test/com/cloud/network/vpc/VpcManagerImplTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/network/vpc/VpcManagerImplTest.java b/server/test/com/cloud/network/vpc/VpcManagerImplTest.java
new file mode 100644
index 0000000..a0237b4
--- /dev/null
+++ b/server/test/com/cloud/network/vpc/VpcManagerImplTest.java
@@ -0,0 +1,53 @@
+package com.cloud.network.vpc;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.cloudstack.context.CallContext;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.MockitoAnnotations;
+
+import static org.mockito.Mockito.when;
+
+import com.cloud.network.Network.Provider;
+import com.cloud.network.Network.Service;
+import com.cloud.network.vpc.dao.VpcOfferingServiceMapDao;
+import com.cloud.user.Account;
+import com.cloud.user.User;
+
+public class VpcManagerImplTest {
+
+    @Mock
+    VpcOfferingServiceMapDao vpcOffSvcMapDao;
+    VpcManagerImpl manager;
+
+    @Before
+    public void setup()
+    {
+        MockitoAnnotations.initMocks(this);
+        manager = new VpcManagerImpl();
+        manager._vpcOffSvcMapDao = vpcOffSvcMapDao;
+    }
+    @Test
+    public void getVpcOffSvcProvidersMapForEmptyServiceTest() {
+        long vpcOffId = 1L;
+        List<VpcOfferingServiceMapVO> list = new ArrayList<VpcOfferingServiceMapVO>();
+        list.add(Mockito.mock(VpcOfferingServiceMapVO.class));
+        when(manager._vpcOffSvcMapDao.listByVpcOffId(vpcOffId)).thenReturn(list);
+
+        Map<Service, Set<Provider>> map = manager.getVpcOffSvcProvidersMap(vpcOffId);
+
+        assertNotNull(map);
+        assertEquals(map.size(),1);
+    }
+
+}


Mime
View raw message