brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From drigod...@apache.org
Subject [3/4] brooklyn-server git commit: added a new test for default azure arm network
Date Thu, 22 Jun 2017 09:08:27 GMT
added a new test for default azure arm network


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/ab17a2af
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/ab17a2af
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/ab17a2af

Branch: refs/heads/master
Commit: ab17a2af78941efe0d6564782e78a8671c8683f1
Parents: 72d8233
Author: graeme.miller <graeme.miller@cloudsoftcorp.com>
Authored: Wed Jun 21 15:02:43 2017 +0100
Committer: graeme.miller <graeme.miller@cloudsoftcorp.com>
Committed: Wed Jun 21 15:02:43 2017 +0100

----------------------------------------------------------------------
 .../DefaultAzureArmNetworkCreatorTest.java      | 41 ++++++++++++++++++++
 1 file changed, 41 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/ab17a2af/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/creator/DefaultAzureArmNetworkCreatorTest.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/creator/DefaultAzureArmNetworkCreatorTest.java
b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/creator/DefaultAzureArmNetworkCreatorTest.java
index a2c4fc6..832776e 100644
--- a/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/creator/DefaultAzureArmNetworkCreatorTest.java
+++ b/locations/jclouds/src/test/java/org/apache/brooklyn/location/jclouds/networking/creator/DefaultAzureArmNetworkCreatorTest.java
@@ -37,6 +37,8 @@ import org.mockito.MockitoAnnotations;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import com.google.common.collect.ImmutableMap;
+
 import org.jclouds.azurecompute.arm.AzureComputeApi;
 import org.jclouds.azurecompute.arm.domain.Subnet;
 import org.jclouds.azurecompute.arm.features.ResourceGroupApi;
@@ -130,6 +132,45 @@ public class DefaultAzureArmNetworkCreatorTest {
     }
 
     @Test
+    public void testVanillaWhereTemplateOptionsAlreadySpecified() {
+        //Setup config bag
+        ConfigBag configBag = ConfigBag.newInstance();
+        configBag.put(CLOUD_REGION_ID, TEST_LOCATION);
+        configBag.put(TEMPLATE_OPTIONS, ImmutableMap.of("unrelated-key", "unrelated-value"));
+
+        //Setup mocks
+        when(computeService.getContext().unwrapApi(AzureComputeApi.class)).thenReturn(azureComputeApi);
+        when(azureComputeApi.getSubnetApi(TEST_RESOURCE_GROUP, TEST_NETWORK_NAME)).thenReturn(subnetApi);
+        when(subnetApi.get(TEST_SUBNET_NAME)).thenReturn(null).thenReturn(subnet); //null
first time, subnet next
+        when(subnet.id()).thenReturn(TEST_SUBNET_ID);
+
+        when(azureComputeApi.getResourceGroupApi()).thenReturn(resourceGroupApi);
+        when(resourceGroupApi.get(TEST_RESOURCE_GROUP)).thenReturn(null);
+
+        when(azureComputeApi.getVirtualNetworkApi(TEST_RESOURCE_GROUP)).thenReturn(virtualNetworkApi);
+
+
+        //Test
+        DefaultAzureArmNetworkCreator.createDefaultNetworkAndAddToTemplateOptionsIfRequired(computeService,
configBag);
+
+        //verify
+        verify(subnetApi, times(2)).get(TEST_SUBNET_NAME);
+        verify(subnet).id();
+        verify(azureComputeApi, times(2)).getSubnetApi(TEST_RESOURCE_GROUP, TEST_NETWORK_NAME);
+
+        verify(azureComputeApi, times(2)).getResourceGroupApi();
+        verify(resourceGroupApi).get(TEST_RESOURCE_GROUP);
+        verify(azureComputeApi).getVirtualNetworkApi(TEST_RESOURCE_GROUP);
+
+        Map<String, Object> templateOptions = configBag.get(TEMPLATE_OPTIONS);
+        assertEquals(templateOptions.get("unrelated-key"), "unrelated-value");
+
+        Map<String, Object> ipOptions = (Map<String, Object>)templateOptions.get("ipOptions");
+        assertEquals(ipOptions.get("subnet"), TEST_SUBNET_ID);
+        assertEquals(ipOptions.get("allocateNewPublicIp"), true);
+    }
+
+    @Test
     public void testNetworkInConfig() {
         ConfigBag configBag = ConfigBag.newInstance();
         configBag.put(CLOUD_REGION_ID, TEST_LOCATION);


Mime
View raw message