Repository: jclouds-labs
Updated Branches:
  refs/heads/master 5742745e0 -> 2f1103873


http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentTemplateBuilderTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentTemplateBuilderTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentTemplateBuilderTest.java
deleted file mode 100644
index 1657899..0000000
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/DeploymentTemplateBuilderTest.java
+++ /dev/null
@@ -1,287 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-package org.jclouds.azurecompute.arm.features;
-
-import java.util.List;
-import java.util.Map;
-
-import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
-import org.jclouds.azurecompute.arm.domain.DeploymentBody;
-import org.jclouds.azurecompute.arm.domain.ImageReference;
-import org.jclouds.azurecompute.arm.domain.IpConfiguration;
-import org.jclouds.azurecompute.arm.domain.IpConfigurationProperties;
-import org.jclouds.azurecompute.arm.domain.NetworkInterfaceCardProperties;
-import org.jclouds.azurecompute.arm.domain.PublicIPAddressProperties;
-import org.jclouds.azurecompute.arm.domain.ResourceDefinition;
-import org.jclouds.azurecompute.arm.domain.StorageService;
-import 
org.jclouds.azurecompute.arm.domain.StorageService.StorageServiceProperties;
-import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.jclouds.azurecompute.arm.util.DeploymentTemplateBuilder;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.domain.internal.TemplateImpl;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-import com.google.common.collect.Iterables;
-
-import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "unit", testName = "DeploymentTemplateBuilderTest", 
singleThreaded = true)
-public class DeploymentTemplateBuilderTest extends BaseAzureComputeApiMockTest 
{
-
-   final String group = "jcgroup";
-   final String vnetName = group + "virtualnetwork";
-   final String subnetId = "";
-
-   @Test
-   public void testResourceGroup() {
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithEmptyOptions();
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-      List<ResourceDefinition> resources = 
deploymentBody.template().resources();
-      Map<String, String> variables = deploymentBody.template().variables();
-
-      ResourceDefinition resource = getResourceByType(resources, 
"Microsoft.Storage/storageAccounts");
-
-      StorageServiceProperties properties = (StorageServiceProperties) 
resource.properties();
-      assertEquals(properties.accountType(), 
StorageService.AccountType.Standard_LRS);
-      assertTrue(variables.containsKey(parseVariableName(resource.name())));
-   }
-
-   @Test
-   void testPublicIpAddress() {
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithEmptyOptions();
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-      List<ResourceDefinition> resources = 
deploymentBody.template().resources();
-      Map<String, String> variables = deploymentBody.template().variables();
-
-      ResourceDefinition resource = getResourceByType(resources, 
"Microsoft.Network/publicIPAddresses");
-
-      PublicIPAddressProperties properties = (PublicIPAddressProperties) 
resource.properties();
-      assertEquals(properties.publicIPAllocationMethod(), "Dynamic");
-      assertTrue(variables.containsKey(parseVariableName(resource.name())));
-   }
-
-   @Test
-   void testNetworkInterfaceCard() {
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithEmptyOptions();
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-      List<ResourceDefinition> resources = 
deploymentBody.template().resources();
-      Map<String, String> variables = deploymentBody.template().variables();
-
-      ResourceDefinition resource = getResourceByType(resources, 
"Microsoft.Network/networkInterfaces");
-
-      NetworkInterfaceCardProperties properties = 
(NetworkInterfaceCardProperties) resource.properties();
-      List<IpConfiguration> ipConfigs = properties.ipConfigurations();
-      assertTrue(ipConfigs.size() > 0);
-      IpConfigurationProperties ipProperties = ipConfigs.get(0).properties();
-      assertEquals(ipProperties.privateIPAllocationMethod(), "Dynamic");
-      assertNotNull(ipProperties.publicIPAddress());
-      assertNotNull(ipProperties.subnet());
-
-      assertTrue(variables.containsKey(parseVariableName(resource.name())));
-   }
-
-   @Test
-   void testVirtualMachine() {
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithEmptyOptions();
-      Template template = builder.getTemplate();
-
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-      List<ResourceDefinition> resources = 
deploymentBody.template().resources();
-      Map<String, String> variables = deploymentBody.template().variables();
-
-      ResourceDefinition resource = getResourceByType(resources, 
"Microsoft.Compute/virtualMachines");
-      assertNotNull(resource);
-
-      VirtualMachineProperties properties = (VirtualMachineProperties) 
resource.properties();
-      assertEquals(properties.hardwareProfile().vmSize(), 
template.getHardware().getId());
-
-      ImageReference image = properties.storageProfile().imageReference();
-      assertEquals(image.publisher(), template.getImage().getProviderId());
-      assertEquals(image.offer(), template.getImage().getName());
-      assertEquals(image.sku(), template.getImage().getVersion());
-      assertEquals(image.version(), "latest");
-
-      assertTrue(variables.containsKey(parseVariableName(resource.name())));
-   }
-
-   @Test
-   void testAddStorageResourceWhenNameIsLongerThan24Chars() {
-      String name = "thishasmorethan24characters";
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithEmptyOptions(name);
-
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-      
assertTrue(Iterables.contains(deploymentBody.template().variables().keySet(), 
"storageAccountName"));
-      String storageAccountName = 
deploymentBody.template().variables().get("storageAccountName");
-      assertEquals(storageAccountName.length(), 24);
-      assertEquals(storageAccountName.substring(0, 10), "thishasmor");
-      assertEquals(storageAccountName.substring(storageAccountName.length() - 
10, storageAccountName.length()), "characters");
-   }
-
-   @Test
-   void testAddStorageResourceWhenNameIsExactly24Chars() {
-      String name = "ithasexactly24characters";
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithEmptyOptions(name);
-
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-      
assertTrue(Iterables.contains(deploymentBody.template().variables().keySet(), 
"storageAccountName"));
-      
assertEquals(deploymentBody.template().variables().get("storageAccountName").length(),
 24);
-      
assertEquals(deploymentBody.template().variables().get("storageAccountName"), 
name);
-   }
-
-   @Test
-   void testAddStorageResourceWhenNameIsLessThan3Chars() {
-      String name = "3c";
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithEmptyOptions(name);
-
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-      
assertTrue(Iterables.contains(deploymentBody.template().variables().keySet(), 
"storageAccountName"));
-      
assertEquals(deploymentBody.template().variables().get("storageAccountName").length(),
 6);
-      
assertEquals(deploymentBody.template().variables().get("storageAccountName").substring(0,
 2), name);
-   }
-
-   @Test
-   void testCustomOptions(){
-      final String dnsLabelPrefix = "mydnslabel";
-      final String customData = "echo customData";
-      final String customData64 = "ZWNobyBjdXN0b21EYXRh";
-      final String keyvaultString = "/url/to/vault/:publickeysecret";
-
-      AzureTemplateOptions options = new AzureTemplateOptions()
-            .customData(customData)
-            .DNSLabelPrefix(dnsLabelPrefix)
-            .keyVaultIdAndSecret(keyvaultString);
-
-      options.virtualNetworkName(vnetName);
-      options.subnetId(subnetId);
-
-      assertEquals(options.as(AzureTemplateOptions.class).getCustomData(), 
customData);
-      assertEquals(options.getDNSLabelPrefix(), dnsLabelPrefix);
-      
assertEquals(options.as(AzureTemplateOptions.class).getKeyVaultIdAndSecret(), 
keyvaultString);
-
-      DeploymentTemplateBuilder builder = 
getMockDeploymentTemplateBuilderWithOptions(options);
-
-      DeploymentBody deploymentBody = builder.getDeploymentTemplate();
-
-      List<ResourceDefinition> resources = 
deploymentBody.template().resources();
-      ResourceDefinition publicIpResource = getResourceByType(resources, 
"Microsoft.Network/publicIPAddresses");
-      assertNotNull(publicIpResource);
-
-      PublicIPAddressProperties ipProperties = (PublicIPAddressProperties) 
publicIpResource.properties();
-      assertEquals(ipProperties.dnsSettings().domainNameLabel(), 
dnsLabelPrefix);
-
-      ResourceDefinition vmResource = getResourceByType(resources, 
"Microsoft.Compute/virtualMachines");
-      assertNotNull(vmResource);
-
-      VirtualMachineProperties virtualMachineProperties = 
(VirtualMachineProperties) vmResource.properties();
-      assertEquals(virtualMachineProperties.osProfile().customData(), 
customData64);
-
-      //populated when keyvault is used to get public key.
-      
assertNotNull(virtualMachineProperties.osProfile().linuxConfiguration().ssh().publicKeys());
-   }
-
-   @Test(expectedExceptions = IllegalArgumentException.class)
-   void testSimplifyPortsWithPortsNull() {
-      int[] ports = null;
-      DeploymentTemplateBuilder.simplifyPorts(ports);
-   }
-
-   @Test(expectedExceptions = IllegalArgumentException.class)
-   void testSimplifyPortsWithPortsEmpty() {
-      int[] ports = new int[0];
-      DeploymentTemplateBuilder.simplifyPorts(ports);
-   }
-
-   @Test
-   void testSimplifyPorts() {
-      int[] ports = {8084, 22, 8081, 8080, 8082};
-      List<String> ranges = DeploymentTemplateBuilder.simplifyPorts(ports);
-      assertEquals(ranges.size(), 3);
-      assertEquals(ranges.get(0), "22");
-      assertEquals(ranges.get(1), "8080-8082");
-      assertEquals(ranges.get(2), "8084");
-   }
-
-   private Template getMockTemplate(TemplateOptions options) {
-      ((AzureTemplateOptions)options).virtualNetworkName(vnetName);
-      ((AzureTemplateOptions)options).subnetId(subnetId);
-
-      Location provider = (new 
LocationBuilder()).scope(LocationScope.PROVIDER).id("azurecompute-arm").description("azurecompute-arm").build();
-      Location region = (new 
LocationBuilder()).scope(LocationScope.REGION).id("northeurope").description("North
 Europe").parent(provider).build();
-      OperatingSystem os = 
OperatingSystem.builder().name("osName").version("osVersion").description("osDescription").arch("X86_32").build();
-      //Note that version is set to "latest"
-      Image image = (new 
ImageBuilder()).id("imageId").providerId("imageId").name("imageName").description("imageDescription").version("sku").operatingSystem(os).status(Image.Status.AVAILABLE).location(region).build();
-      Hardware hardware = (new HardwareBuilder()).id("Standard_A0").build();
-      return new TemplateImpl(image, hardware, region, options);
-   }
-
-   private DeploymentTemplateBuilder 
getMockDeploymentTemplateBuilderWithEmptyOptions() {
-      return getMockDeploymentTemplateBuilderWithEmptyOptions("mydeployment");
-   }
-
-   private DeploymentTemplateBuilder 
getMockDeploymentTemplateBuilderWithEmptyOptions(String name) {
-      AzureTemplateOptions options = new AzureTemplateOptions();
-      options.virtualNetworkName(vnetName);
-      options.subnetId(subnetId);
-
-      Template template = getMockTemplate(options);
-      DeploymentTemplateBuilder templateBuilder = 
api.deploymentTemplateFactory().create(group, name, template);
-      return templateBuilder;
-   }
-
-   private DeploymentTemplateBuilder 
getMockDeploymentTemplateBuilderWithOptions(TemplateOptions options) {
-      return getMockDeploymentTemplateBuilderWithOptions("mydeployment", 
options);
-   }
-
-   private DeploymentTemplateBuilder 
getMockDeploymentTemplateBuilderWithOptions(String name, TemplateOptions 
options) {
-      ((AzureTemplateOptions)options).virtualNetworkName(vnetName);
-      ((AzureTemplateOptions)options).subnetId(subnetId);
-
-      Template template = getMockTemplate(options);
-      DeploymentTemplateBuilder templateBuilder = 
api.deploymentTemplateFactory().create(group, name, template);
-      return templateBuilder;
-   }
-
-   private ResourceDefinition getResourceByType(List<ResourceDefinition> 
resources, String type) {
-      for (ResourceDefinition r : resources) {
-         if (r.type().equals(type)) {
-            return r;
-         }
-      }
-      Assert.fail("Resource with type: " + type + " not found");
-      return null;
-   }
-
-   private String parseVariableName(String variable) {
-      String[] parts = variable.split("\'");
-      assertTrue(parts.length == 3);
-      return parts[1];
-   }
-}
-

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiMockTest.java
index adefd95..2d43694 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/NetworkSecurityGroupApiMockTest.java
@@ -83,8 +83,6 @@ public class NetworkSecurityGroupApiMockTest extends 
BaseAzureComputeApiMockTest
    }
 
    public void getNetworkSecurityGroup() throws InterruptedException {
-      NetworkSecurityGroup nsg = createGroup();
-
       
server.enqueue(jsonResponse("/networksecuritygroupget.json").setResponseCode(200));
 
       final NetworkSecurityGroupApi nsgApi = 
api.getNetworkSecurityGroupApi(resourcegroup);

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
index 436cb91..b510580 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/PublicIPAddressApiMockTest.java
@@ -147,8 +147,7 @@ public class PublicIPAddressApiMockTest extends 
BaseAzureComputeApiMockTest {
       PublicIPAddressProperties properties = 
PublicIPAddressProperties.create(null, null, "Static", 4, null,
               DnsSettings.create("foobar", 
"foobar.northeurope.cloudapp.azure.com", null));
 
-      PublicIPAddress ip = ipApi.createOrUpdate(publicIpName, location, tags, 
properties);
-
+      ipApi.createOrUpdate(publicIpName, location, tags, properties);
    }
 
    public void deletePublicIPAddress() throws InterruptedException {

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
index 70f2ad6..3c90d42 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/ResourceProviderAPIMockTest.java
@@ -31,7 +31,6 @@ public class ResourceProviderAPIMockTest extends 
BaseAzureComputeApiMockTest {
 
    final String apiVersion = "2015-01-01";
    final String resource = "Microsoft.Compute";
-   private final String vm_resource = "virtualMachines";
 
    public void getPublicIPAddressInfo() throws InterruptedException {
       server.enqueue(jsonResponse("/getresourceprovidermetadata.json"));

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
index 39ecd2b..e3fdf6d 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/StorageAccountApiMockTest.java
@@ -235,41 +235,6 @@ public class StorageAccountApiMockTest extends 
BaseAzureComputeApiMockTest {
               
"/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE?api-version=2015-06-15");
    }
 
-   private StorageService getStrorageAccount() {
-      DateService DATE_SERVICE = new SimpleDateFormatDateService();
-      Map<String, String> endpoints = new HashMap<String, String>();
-      endpoints.put("blob", "https://TESTSTORAGE.blob.core.windows.net/";);
-      endpoints.put("file", "https://TESTSTORAGE.file.core.windows.net/";);
-      endpoints.put("queue", "https://TESTSTORAGE.queue.core.windows.net/";);
-      endpoints.put("table", "https://TESTSTORAGE.table.core.windows.net/";);
-      Map<String, String> secondaryEndpoints = new HashMap<String, String>();
-      secondaryEndpoints.put("blob", 
"https://TESTSTORAGE-secondary.blob.core.windows.net/";);
-      secondaryEndpoints.put("queue", 
"https://TESTSTORAGE-secondary.queue.core.windows.net/";);
-      secondaryEndpoints.put("table", 
"https://TESTSTORAGE-secondary.table.core.windows.net/";);
-
-
-      String location = "westus";
-      String secondaryLocation = "eastus";
-      final StorageService.StorageServiceProperties props = 
StorageService.StorageServiceProperties.create(
-              StorageService.AccountType.Standard_RAGRS,
-              
DATE_SERVICE.iso8601DateOrSecondsDateParse("2016-02-24T13:04:45.0890883Z"),
-              endpoints,
-              location,
-              StorageService.Status.Succeeded,
-              secondaryEndpoints, secondaryLocation,
-              StorageService.RegionStatus.Available,
-              StorageService.RegionStatus.Available);
-
-      final Map<String, String> tags = ImmutableMap.of(
-              "key1", "value1",
-              "key2", "value2");
-
-      return StorageService.create(
-              "/subscriptions/SUBSCRIPTIONID/resourceGroups/resourceGroup" +
-                      
"/providers/Microsoft.Storage/storageAccounts/TESTSTORAGE",
-              "TESTSTORAGE", location, tags, null, props);
-   }
-
    private List<StorageService> expected() throws MalformedURLException {
       DateService DATE_SERVICE = new SimpleDateFormatDateService();
       Map<String, String> endpoints = new HashMap<String, String>();

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiMockTest.java
index bfcf188..0113201 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/SubnetApiMockTest.java
@@ -16,18 +16,17 @@
  */
 package org.jclouds.azurecompute.arm.features;
 
-import com.squareup.okhttp.mockwebserver.RecordedRequest;
-import org.jclouds.azurecompute.arm.domain.Subnet;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
-import org.testng.annotations.Test;
-
-import java.util.List;
-
 import static com.google.common.collect.Iterables.isEmpty;
 import static org.testng.Assert.assertEquals;
 import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
 import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
+
+import java.util.List;
+
+import org.jclouds.azurecompute.arm.domain.Subnet;
+import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
+import org.testng.annotations.Test;
 
 
 @Test(groups = "unit", testName = "SubnetApiMockTest", singleThreaded = true)
@@ -135,6 +134,6 @@ public class SubnetApiMockTest extends 
BaseAzureComputeApiMockTest {
       assertFalse(status);
 
       String path = 
String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworks/%s/subnets/%s?%s",
 subscriptionid, resourcegroup, virtualNetwork, subnetName, apiVersion);
-      RecordedRequest rr = assertSent(server, "DELETE", path);
+      assertSent(server, "DELETE", path);
    }
 }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/TemplateToDeploymentTemplateLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/TemplateToDeploymentTemplateLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/TemplateToDeploymentTemplateLiveTest.java
deleted file mode 100644
index 3b87663..0000000
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/TemplateToDeploymentTemplateLiveTest.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You 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.
- */
-package org.jclouds.azurecompute.arm.features;
-
-import java.net.URI;
-
-import org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions;
-import org.jclouds.azurecompute.arm.domain.Deployment;
-import org.jclouds.azurecompute.arm.domain.DeploymentBody;
-import org.jclouds.azurecompute.arm.domain.DeploymentProperties;
-import org.jclouds.azurecompute.arm.domain.Subnet;
-import org.jclouds.azurecompute.arm.domain.VirtualNetwork;
-import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
-import org.jclouds.azurecompute.arm.util.DeploymentTemplateBuilder;
-import org.jclouds.compute.domain.Hardware;
-import org.jclouds.compute.domain.HardwareBuilder;
-import org.jclouds.compute.domain.Image;
-import org.jclouds.compute.domain.ImageBuilder;
-import org.jclouds.compute.domain.OperatingSystem;
-import org.jclouds.compute.domain.OsFamily;
-import org.jclouds.compute.domain.Template;
-import org.jclouds.compute.domain.internal.TemplateImpl;
-import org.jclouds.compute.options.TemplateOptions;
-import org.jclouds.domain.Location;
-import org.jclouds.domain.LocationBuilder;
-import org.jclouds.domain.LocationScope;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.BeforeClass;
-import org.testng.annotations.Test;
-
-import com.google.common.net.UrlEscapers;
-
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
-
-@Test(groups = "live", testName = "TemplateToDeploymentTemplateLiveTest", 
singleThreaded = true)
-public class TemplateToDeploymentTemplateLiveTest extends 
BaseAzureComputeApiLiveTest {
-
-   private int maxTestDuration = 400;
-   private int pollingInterval = 3; // how frequently to poll for create status
-   private String resourceGroupName;
-   private String deploymentName;
-   private String vnetName;
-   private String subnetId;
-   private String virtualNetworkName;
-
-   @BeforeClass
-   @Override
-   public void setup() {
-      super.setup();
-      resourceGroupName = String.format("rg-%s-%s", 
this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name"));
-      assertNotNull(createResourceGroup(resourceGroupName));
-      virtualNetworkName = String.format("vn-%s-%s", 
this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name"));
-
-      //Subnets belong to a virtual network so that needs to be created first
-      VirtualNetwork vn = createDefaultVirtualNetwork(resourceGroupName, 
virtualNetworkName, "10.2.0.0/16", LOCATION);
-      assertNotNull(vn);
-      vnetName = vn.name();
-
-      //Subnet needs to be up & running before NIC can be created
-      String subnetName = String.format("s-%s-%s", 
this.getClass().getSimpleName().toLowerCase(), System.getProperty("user.name"));
-      Subnet subnet = createDefaultSubnet(resourceGroupName, subnetName, 
virtualNetworkName, "10.2.0.0/23");
-      assertNotNull(subnet);
-      assertNotNull(subnet.id());
-      subnetId = subnet.id();
-   }
-
-   @AfterClass
-   @Override
-   protected void tearDown() {
-      super.tearDown();
-      URI uri = deleteResourceGroup(resourceGroupName);
-      assertResourceDeleted(uri);
-   }
-
-   @Test
-   public void testValidateDeploymentTemplateLinuxNodeWithOptions() {
-      Long now = System.currentTimeMillis();
-      deploymentName = "jc" + now;
-
-      AzureTemplateOptions options = new AzureTemplateOptions();
-      options.virtualNetworkName(vnetName);
-      options.subnetId(subnetId);
-
-      options.inboundPorts(22, 8080);
-
-      DeploymentTemplateBuilder templateBuilder = 
getDeploymentTemplateBuilderWithOptions(options);
-
-      DeploymentBody deploymentTemplateBody = 
templateBuilder.getDeploymentTemplate();
-
-      DeploymentProperties properties = 
DeploymentProperties.create(deploymentTemplateBody);
-
-      String deploymentTemplate = 
templateBuilder.getDeploymentTemplateJson(properties);
-      deploymentTemplate = 
UrlEscapers.urlFormParameterEscaper().escape(deploymentTemplate);
-
-      //Validates that template is syntactically correct
-      Deployment deployment = api().validate(deploymentName, 
deploymentTemplate);
-      assertNotNull(deployment);
-   }
-
-   @Test
-   public void testValidateDeploymentTemplateLinuxNode() {
-      Long now = System.currentTimeMillis();
-      deploymentName = "jc" + now;
-
-      DeploymentTemplateBuilder templateBuilder = 
getDeploymentTemplateBuilderWithEmptyOptions();
-
-      DeploymentBody deploymentTemplateBody = 
templateBuilder.getDeploymentTemplate();
-
-      DeploymentProperties properties = 
DeploymentProperties.create(deploymentTemplateBody);
-
-      String deploymentTemplate = 
templateBuilder.getDeploymentTemplateJson(properties);
-      deploymentTemplate = 
UrlEscapers.urlFormParameterEscaper().escape(deploymentTemplate);
-
-      //Validates that template is syntactically correct
-      Deployment deployment = api().validate(deploymentName, 
deploymentTemplate);
-      assertNotNull(deployment);
-   }
-
-   @Test
-   public void testValidateDeploymentTemplateWithCustomOptions() {
-      Long now = System.currentTimeMillis();
-      deploymentName = "jc" + now;
-
-      String rsakey = new String("ssh-rsa 
AAAAB3NzaC1yc2EAAAABJQAAAQEAmfk/QSF0pvnrpdz+Ah2KulGruKU+8FFBdlw938MpOysRdmp7uwpH6Z7+5VNGNdxFIAyc/W3UaZXF9hTsU8+78TlwkZpsr2mzU+ycu37XLAQ8Uv7hjsAN0DkKKPrZ9lgUUfZVKV/8E/JIAs03gIbL6zO3y7eYJQ5fNeZb+nji7tQT+YLpGq/FDegvraPKVMQbCSCZhsHyWhdPLyFlu9/30npZ0ahYOPI/KyZxFDtM/pHp88+ZAk9Icq5owaLRWcJQqrBGWqjbZnHtjdDqvHZ+C0wPhdJZPyfkHOrSYTwSQBXfX4JLRRCz3J1jf62MbQWT1o6Y4JEs1ZP1Skxu6zR96Q==
 mocktest");
-      TemplateOptions options = new AzureTemplateOptions()
-              .DNSLabelPrefix("mydnslabel")
-              .virtualNetworkAddressPrefix("10.0.0.0/20")
-              .subnetAddressPrefix("10.0.0.0/25")
-              .authorizePublicKey(rsakey);
-
-      ((AzureTemplateOptions)options).virtualNetworkName(vnetName);
-      ((AzureTemplateOptions)options).subnetId(subnetId);
-
-      DeploymentTemplateBuilder templateBuilder = 
getDeploymentTemplateBuilderWithOptions(options);
-
-      DeploymentBody deploymentTemplateBody = 
templateBuilder.getDeploymentTemplate();
-
-      DeploymentProperties properties = 
DeploymentProperties.create(deploymentTemplateBody);
-
-      String deploymentTemplate = 
templateBuilder.getDeploymentTemplateJson(properties);
-      deploymentTemplate = 
UrlEscapers.urlFormParameterEscaper().escape(deploymentTemplate);
-
-      Deployment deployment = api().validate(deploymentName, 
deploymentTemplate);
-      assertNotNull(deployment);
-   }
-
-   @Test
-   public void testValidateDeploymentTemplateLinuxNodeWithSSH() {
-      Long now = System.currentTimeMillis();
-      deploymentName = "jc" + now;
-
-      String rsakey = new String("ssh-rsa 
AAAAB3NzaC1yc2EAAAABJQAAAQEAmfk/QSF0pvnrpdz+Ah2KulGruKU+8FFBdlw938MpOysRdmp7uwpH6Z7+5VNGNdxFIAyc/W3UaZXF9hTsU8+78TlwkZpsr2mzU+ycu37XLAQ8Uv7hjsAN0DkKKPrZ9lgUUfZVKV/8E/JIAs03gIbL6zO3y7eYJQ5fNeZb+nji7tQT+YLpGq/FDegvraPKVMQbCSCZhsHyWhdPLyFlu9/30npZ0ahYOPI/KyZxFDtM/pHp88+ZAk9Icq5owaLRWcJQqrBGWqjbZnHtjdDqvHZ+C0wPhdJZPyfkHOrSYTwSQBXfX4JLRRCz3J1jf62MbQWT1o6Y4JEs1ZP1Skxu6zR96Q==
 mocktest");
-
-      AzureTemplateOptions options = new AzureTemplateOptions();
-      options.virtualNetworkName(vnetName);
-      options.subnetId(subnetId);
-
-      options.authorizePublicKey(rsakey);
-      DeploymentTemplateBuilder templateBuilder = 
getDeploymentTemplateBuilderWithOptions(options);
-
-      DeploymentBody deploymentTemplateBody = 
templateBuilder.getDeploymentTemplate();
-
-      DeploymentProperties properties = 
DeploymentProperties.create(deploymentTemplateBody);
-
-      String deploymentTemplate = 
templateBuilder.getDeploymentTemplateJson(properties);
-      deploymentTemplate = 
UrlEscapers.urlFormParameterEscaper().escape(deploymentTemplate);
-
-      Deployment deployment = api().validate(deploymentName, 
deploymentTemplate);
-      assertNotNull(deployment);
-   }
-
-   @Test
-   public void testCreateDeploymentTemplateLinuxNode() {
-      Long now = System.currentTimeMillis();
-      deploymentName = "jc" + now;
-
-      String rsakey = new String("ssh-rsa 
AAAAB3NzaC1yc2EAAAABJQAAAQEAmfk/QSF0pvnrpdz+Ah2KulGruKU+8FFBdlw938MpOysRdmp7uwpH6Z7+5VNGNdxFIAyc/W3UaZXF9hTsU8+78TlwkZpsr2mzU+ycu37XLAQ8Uv7hjsAN0DkKKPrZ9lgUUfZVKV/8E/JIAs03gIbL6zO3y7eYJQ5fNeZb+nji7tQT+YLpGq/FDegvraPKVMQbCSCZhsHyWhdPLyFlu9/30npZ0ahYOPI/KyZxFDtM/pHp88+ZAk9Icq5owaLRWcJQqrBGWqjbZnHtjdDqvHZ+C0wPhdJZPyfkHOrSYTwSQBXfX4JLRRCz3J1jf62MbQWT1o6Y4JEs1ZP1Skxu6zR96Q==
 mocktest");
-
-      AzureTemplateOptions options = new AzureTemplateOptions();
-      options.virtualNetworkName(vnetName);
-      options.subnetId(subnetId);
-
-      options.authorizePublicKey(rsakey);
-      options.inboundPorts(22, 8080);
-      DeploymentTemplateBuilder templateBuilder = 
getDeploymentTemplateBuilderWithOptions(options);
-
-      DeploymentBody deploymentTemplateBody = 
templateBuilder.getDeploymentTemplate();
-      DeploymentProperties properties = 
DeploymentProperties.create(deploymentTemplateBody);
-
-      String deploymentTemplate = 
templateBuilder.getDeploymentTemplateJson(properties);
-      deploymentTemplate = 
UrlEscapers.urlFormParameterEscaper().escape(deploymentTemplate);
-
-      //creates an actual VM using deployment template
-      Deployment deployment = api().create(deploymentName, deploymentTemplate);
-
-      Deployment.ProvisioningState state = 
Deployment.ProvisioningState.fromValue(deployment.properties().provisioningState());
-      int testTime = 0;
-      while (testTime < maxTestDuration) {
-         if ((state == Deployment.ProvisioningState.SUCCEEDED) ||
-                 (state == Deployment.ProvisioningState.CANCELED) ||
-                 (state == Deployment.ProvisioningState.DELETED) ||
-                 (state == Deployment.ProvisioningState.FAILED)) {
-            break;
-         }
-
-         // sleep a little bit before polling, timeout after a fixed time
-         try {
-            Thread.sleep(pollingInterval * 1000);
-         } catch (InterruptedException e) {
-            e.printStackTrace();
-         }
-         testTime += pollingInterval;
-
-         deployment = api().get(deploymentName);
-         assertNotNull(deployment);
-         state = 
Deployment.ProvisioningState.fromValue(deployment.properties().provisioningState());
-      }
-      assertTrue(state == Deployment.ProvisioningState.SUCCEEDED);
-      assertNotNull(deployment);
-   }
-
-   private Template getTemplate(TemplateOptions options) {
-      Location provider = (new 
LocationBuilder()).scope(LocationScope.PROVIDER).id("azurecompute-arm").description("azurecompute-arm").build();
-      Location region = (new 
LocationBuilder()).scope(LocationScope.REGION).id(LOCATION).description(LOCATIONDESCRIPTION).parent(provider).build();
-
-      OperatingSystem os = OperatingSystem.builder()
-              .family(OsFamily.UBUNTU)
-              .description("14.04.3-LTS")
-              .is64Bit(true)
-              .build();
-
-      Image image = (new ImageBuilder())
-              .id("UbuntuServer14.04.3-LTS")
-              .providerId("Canonical")
-              .name("UbuntuServer")
-              .description("14.04.3-LTS")
-              .version("14.04.3-LTS")
-              .operatingSystem(os)
-              .status(Image.Status.AVAILABLE)
-              .location(region)
-              .build();
-
-      Hardware hardware = (new HardwareBuilder()).id("Standard_A0").build();
-      return new TemplateImpl(image, hardware, region, options);
-   }
-
-   private DeploymentTemplateBuilder 
getDeploymentTemplateBuilderWithEmptyOptions() {
-      AzureTemplateOptions options = new AzureTemplateOptions();
-      options.virtualNetworkName(vnetName);
-      options.subnetId(subnetId);
-
-      Template template = getTemplate(options);
-      DeploymentTemplateBuilder templateBuilder = 
api.deploymentTemplateFactory().create(resourceGroupName, deploymentName, 
template);
-      return templateBuilder;
-   }
-
-   private DeploymentTemplateBuilder 
getDeploymentTemplateBuilderWithOptions(TemplateOptions options) {
-      Template template = getTemplate(options);
-      DeploymentTemplateBuilder templateBuilder = 
api.deploymentTemplateFactory().create(resourceGroupName, deploymentName, 
template);
-      return templateBuilder;
-   }
-
-   private DeploymentApi api() {
-      return api.getDeploymentApi(resourceGroupName);
-   }
-}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
index 2702370..0973693 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiLiveTest.java
@@ -16,6 +16,10 @@
  */
 package org.jclouds.azurecompute.arm.features;
 
+import static org.jclouds.util.Predicates2.retry;
+import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertTrue;
+
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -41,6 +45,7 @@ import org.jclouds.azurecompute.arm.domain.Subnet;
 import org.jclouds.azurecompute.arm.domain.VHD;
 import org.jclouds.azurecompute.arm.domain.VirtualMachine;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
+import 
org.jclouds.azurecompute.arm.domain.VirtualMachineInstance.VirtualMachineStatus.PowerState;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
 import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiLiveTest;
 import org.testng.Assert;
@@ -48,16 +53,9 @@ import org.testng.annotations.AfterClass;
 import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
-import com.google.common.base.Function;
 import com.google.common.base.Predicate;
-import com.google.common.collect.FluentIterable;
 import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Iterables;
-import com.google.gson.internal.LinkedTreeMap;
-
-import static org.jclouds.util.Predicates2.retry;
-import static org.testng.Assert.assertNotNull;
-import static org.testng.Assert.assertTrue;
 
 @Test(groups = "live", testName = "VirtualMachineApiLiveTest")
 public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest {
@@ -125,7 +123,7 @@ public class VirtualMachineApiLiveTest extends 
BaseAzureComputeApiLiveTest {
       }, 60 * 20 * 1000).apply(vmName);
       assertTrue(jobDone, "create operation did not complete in the configured 
timeout");
 
-      String status = api().get(vmName).properties().provisioningState();
+      VirtualMachineProperties.ProvisioningState status = 
api().get(vmName).properties().provisioningState();
       // Cannot be creating anymore. Should be succeeded or running but not 
failed.
       assertTrue(!status.equals("Creating"));
       assertTrue(!status.equals("Failed"));
@@ -146,21 +144,21 @@ public class VirtualMachineApiLiveTest extends 
BaseAzureComputeApiLiveTest {
    @Test(dependsOnMethods = "testStart")
    public void testStop() {
       api().stop(vmName);
-      assertTrue(stateReached("PowerState", "VM stopped"), "stop operation did 
not complete in the configured timeout");
+      assertTrue(stateReached(PowerState.STOPPED), "stop operation did not 
complete in the configured timeout");
    }
 
    @Test(dependsOnMethods = "testGet")
    public void testStart() {
       api().start(vmName);
-      assertTrue(stateReached("PowerState", "VM running"), "start operation 
did not complete in the configured timeout");
+      assertTrue(stateReached(PowerState.RUNNING), "start operation did not 
complete in the configured timeout");
    }
 
    @Test(dependsOnMethods = "testStop")
    public void testRestart() {
       api().start(vmName);
-      assertTrue(stateReached("PowerState", "VM running"), "start operation 
did not complete in the configured timeout");
+      assertTrue(stateReached(PowerState.RUNNING), "start operation did not 
complete in the configured timeout");
       api().restart(vmName);
-      assertTrue(stateReached("PowerState", "VM running"), "restart operation 
did not complete in the configured timeout");
+      assertTrue(stateReached(PowerState.RUNNING), "restart operation did not 
complete in the configured timeout");
    }
 
    @Test(dependsOnMethods = "testCreate")
@@ -180,10 +178,11 @@ public class VirtualMachineApiLiveTest extends 
BaseAzureComputeApiLiveTest {
    @Test(dependsOnMethods = "testRestart")
    public void testGeneralize() throws IllegalStateException {
       api().stop(vmName);
-      assertTrue(stateReached("PowerState", "VM stopped"), "restart operation 
did not complete in the configured timeout");
+      assertTrue(stateReached(PowerState.STOPPED), "restart operation did not 
complete in the configured timeout");
       api().generalize(vmName);
    }
 
+   @SuppressWarnings("unchecked")
    @Test(dependsOnMethods = "testGeneralize")
    public void testCapture() throws IllegalStateException {
       URI uri = api().capture(vmName, vmName, vmName);
@@ -192,17 +191,17 @@ public class VirtualMachineApiLiveTest extends 
BaseAzureComputeApiLiveTest {
          List<ResourceDefinition> definitions = 
api.getJobApi().captureStatus(uri);
          if (definitions != null) {
             for (ResourceDefinition definition : definitions) {
-               LinkedTreeMap<String, String> properties = 
(LinkedTreeMap<String, String>) definition.properties();
+               Map<String, String> properties = (Map<String, String>) 
definition.properties();
                Object storageObject = properties.get("storageProfile");
-               LinkedTreeMap<String, String> properties2 = 
(LinkedTreeMap<String, String>) storageObject;
+               Map<String, String> properties2 = (Map<String, String>) 
storageObject;
                Object osDiskObject = properties2.get("osDisk");
-               LinkedTreeMap<String, String> osProperties = 
(LinkedTreeMap<String, String>) osDiskObject;
+               Map<String, String> osProperties = (Map<String, String>) 
osDiskObject;
                Object dataDisksObject = properties2.get("dataDisks");
-               ArrayList<Object> dataProperties = (ArrayList<Object>) 
dataDisksObject;
-               LinkedTreeMap<String, String> datadiskObject = 
(LinkedTreeMap<String, String>) dataProperties.get(0);
+               List<Object> dataProperties = (List<Object>) dataDisksObject;
+               Map<String, String> datadiskObject = (Map<String, String>) 
dataProperties.get(0);
 
-               Assert.assertNotNull(osProperties.get("name"));
-               Assert.assertNotNull(datadiskObject.get("name"));
+               assertNotNull(osProperties.get("name"));
+               assertNotNull(datadiskObject.get("name"));
             }
          }
       }
@@ -245,7 +244,7 @@ public class VirtualMachineApiLiveTest extends 
BaseAzureComputeApiLiveTest {
               DiagnosticsProfile.BootDiagnostics.create(true, blob);
       DiagnosticsProfile diagnosticsProfile = 
DiagnosticsProfile.create(bootDiagnostics);
       VirtualMachineProperties properties = 
VirtualMachineProperties.create(null,
-              null, null, hwProf, storageProfile, osProfile, networkProfile, 
diagnosticsProfile, "Creating");
+              null, null, hwProf, storageProfile, osProfile, networkProfile, 
diagnosticsProfile, VirtualMachineProperties.ProvisioningState.CREATING);
       return properties;
    }
 
@@ -261,37 +260,15 @@ public class VirtualMachineApiLiveTest extends 
BaseAzureComputeApiLiveTest {
       return 
api.getNetworkInterfaceCardApi(resourceGroupName).createOrUpdate(networkInterfaceCardName,
 locationName, networkInterfaceCardProperties, tags);
    }
 
-   private boolean deleteStorageService(String resourceGroupName, String 
storageServiceName) {
-      return 
api.getStorageAccountApi(resourceGroupName).delete(storageServiceName);
-   }
-
-   private boolean waitForState(String name, final String state, final String 
displayStatus) {
-      return FluentIterable.from(api().getInstanceDetails(name).statuses())
-              .filter(new 
Predicate<VirtualMachineInstance.VirtualMachineStatus>() {
-                 @Override
-                 public boolean 
apply(VirtualMachineInstance.VirtualMachineStatus input) {
-                    return input.code().substring(0, 10).equals(state);
-                 }
-              })
-              .transform(new 
Function<VirtualMachineInstance.VirtualMachineStatus, String>() {
-                 @Override
-                 public String 
apply(VirtualMachineInstance.VirtualMachineStatus input) {
-                    return input.displayStatus();
-                 }
-              })
-              .anyMatch(new Predicate<String>() {
-                 @Override
-                 public boolean apply(String input) {
-                    return input.equals(displayStatus);
-                 }
-              });
+   private boolean waitForState(String name, final PowerState state) {
+      return api().getInstanceDetails(name).powerState().equals(state);
    }
 
-   private boolean stateReached(final String state, final String 
displayStatus) {
+   private boolean stateReached(final PowerState state) {
       return retry(new Predicate<String>() {
          @Override
          public boolean apply(String name) {
-            return waitForState(name, state, displayStatus);
+            return waitForState(name, state);
          }
       }, 60 * 4 * 1000).apply(vmName);
    }

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
index f6583c8..bb36dc5 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualMachineApiMockTest.java
@@ -16,35 +16,36 @@
  */
 package org.jclouds.azurecompute.arm.features;
 
-import com.google.common.collect.ImmutableList;
-import com.squareup.okhttp.mockwebserver.MockResponse;
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.jclouds.azurecompute.arm.domain.DataDisk;
+import org.jclouds.azurecompute.arm.domain.DiagnosticsProfile;
 import org.jclouds.azurecompute.arm.domain.HardwareProfile;
 import org.jclouds.azurecompute.arm.domain.IdReference;
 import org.jclouds.azurecompute.arm.domain.ImageReference;
-import org.jclouds.azurecompute.arm.domain.VirtualMachine;
-import org.jclouds.azurecompute.arm.domain.VHD;
+import org.jclouds.azurecompute.arm.domain.NetworkProfile;
 import org.jclouds.azurecompute.arm.domain.OSDisk;
 import org.jclouds.azurecompute.arm.domain.OSProfile;
-import org.jclouds.azurecompute.arm.domain.DiagnosticsProfile;
-import org.jclouds.azurecompute.arm.domain.NetworkProfile;
 import org.jclouds.azurecompute.arm.domain.StorageProfile;
-import org.jclouds.azurecompute.arm.domain.DataDisk;
+import org.jclouds.azurecompute.arm.domain.VHD;
+import org.jclouds.azurecompute.arm.domain.VirtualMachine;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineInstance;
 import org.jclouds.azurecompute.arm.domain.VirtualMachineProperties;
 import org.jclouds.azurecompute.arm.internal.BaseAzureComputeApiMockTest;
 import org.testng.annotations.Test;
 
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Date;
-import java.text.SimpleDateFormat;
-import java.text.DateFormat;
+import com.google.common.collect.ImmutableList;
+import com.squareup.okhttp.mockwebserver.MockResponse;
 
 import static com.google.common.collect.Iterables.isEmpty;
 import static org.testng.Assert.assertEquals;
-import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertNotNull;
+import static org.testng.Assert.assertNull;
 import static org.testng.Assert.assertTrue;
 
 @Test(groups = "unit", testName = "VirtualMachineApiMockTest", singleThreaded 
= true)
@@ -55,14 +56,14 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       assertEquals(vmAPI.get("windowsmachine"), getVM());
       assertSent(server, "GET", 
"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
 +
-              "/virtualMachines/windowsmachine?api-version=2015-06-15");
+              "/virtualMachines/windowsmachine?api-version=2016-03-30");
    }
    public void testGetEmpty() throws Exception {
       server.enqueue(new MockResponse().setResponseCode(404));
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       assertNull(vmAPI.get("windowsmachine"));
       assertSent(server, "GET", 
"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
 +
-              "/virtualMachines/windowsmachine?api-version=2015-06-15");
+              "/virtualMachines/windowsmachine?api-version=2016-03-30");
    }
 
    public void testGetInstanceDetails() throws Exception {
@@ -76,7 +77,7 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
       assertEquals(actual.statuses().get(0).level(), 
expected.statuses().get(0).level());
       //assertEquals(actual.statuses().get(0).time().toString(), 
expected.statuses().get(0).time().toString());
       assertSent(server, "GET", 
"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
 +
-              
"/virtualMachines/windowsmachine/instanceView?api-version=2015-06-15");
+              
"/virtualMachines/windowsmachine/instanceView?api-version=2016-03-30");
    }
 
    public void testGetInstanceDetailsEmpty() throws Exception {
@@ -84,7 +85,7 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
       final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
       assertNull(vmAPI.getInstanceDetails("windowsmachine"));
       assertSent(server, "GET", 
"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
 +
-              
"/virtualMachines/windowsmachine/instanceView?api-version=2015-06-15");
+              
"/virtualMachines/windowsmachine/instanceView?api-version=2016-03-30");
    }
 
    public void testList() throws Exception {
@@ -109,7 +110,7 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
       VirtualMachine vm = vmAPI.create("windowsmachine", "westus", 
getProperties());
       assertEquals(vm, getVM());
       assertSent(server, "PUT", 
"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
 +
-              
"/virtualMachines/windowsmachine?api-version=2015-06-15&validating=false",
+              
"/virtualMachines/windowsmachine?validating=false&api-version=2016-03-30",
               "{\"location\":\"westus\",\"properties\":" +
                       "{\"vmId\":\"27ee085b-d707-xxxx-yyyy-2370e2eb1cc1\"," +
                       "\"hardwareProfile\":{\"vmSize\":\"Standard_D1\"}," +
@@ -118,7 +119,7 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
                       
"\"vhd\":{\"uri\":\"https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd\"},\"caching\":\"ReadWrite\",\"createOption\":\"FromImage\"},\"dataDisks\":[]},";
 +
                       
"\"osProfile\":{\"computerName\":\"windowsmachine\",\"adminUsername\":\"azureuser\",\"windowsConfiguration\":{\"provisionVMAgent\":false,\"enableAutomaticUpdates\":true}},"
 +
                       
"\"networkProfile\":{\"networkInterfaces\":[{\"id\":\"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167\"}]},"
 +
-                      
"\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":true,\"storageUri\":\"https://groupname2760.blob.core.windows.net/\"}},\"provisioningState\":\"Creating\"}}";);
+                      
"\"diagnosticsProfile\":{\"bootDiagnostics\":{\"enabled\":true,\"storageUri\":\"https://groupname2760.blob.core.windows.net/\"}},\"provisioningState\":\"CREATING\"}}";);
 
    }
 
@@ -133,7 +134,7 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
       assertNull(uri);
 
       assertSent(server, "DELETE", 
"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
 +
-              "/virtualMachines/windowsmachine?api-version=2015-06-15");
+              "/virtualMachines/windowsmachine?api-version=2016-03-30");
    }
    public void testDelete() throws Exception {
       server.enqueue(response202WithHeader());
@@ -146,7 +147,7 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
       assertNotNull(uri);
 
       assertSent(server, "DELETE", 
"/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
 +
-              "/virtualMachines/windowsmachine?api-version=2015-06-15");
+              "/virtualMachines/windowsmachine?api-version=2016-03-30");
    }
 
    public void testStart() throws Exception {
@@ -231,7 +232,7 @@ public class VirtualMachineApiMockTest extends 
BaseAzureComputeApiMockTest {
               "https://groupname2760.blob.core.windows.net/";);
       DiagnosticsProfile diagnosticsProfile = 
DiagnosticsProfile.create(bootDiagnostics);
       VirtualMachineProperties properties = 
VirtualMachineProperties.create("27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
-              null, null, hwProf, storageProfile, osProfile, networkProfile, 
diagnosticsProfile, "Creating");
+              null, null, hwProf, storageProfile, osProfile, networkProfile, 
diagnosticsProfile, VirtualMachineProperties.ProvisioningState.CREATING);
       return properties;
    }
 

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
index 99b0b57..79b48ef 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/features/VirtualNetworkApiMockTest.java
@@ -101,7 +101,7 @@ public class VirtualNetworkApiMockTest extends 
BaseAzureComputeApiMockTest {
                       
VirtualNetwork.AddressSpace.create(Arrays.asList("10.2.0.0/16")), null);
 
 
-      VirtualNetwork vn = vnApi.createOrUpdate(virtualNetwork, location, 
virtualNetworkProperties);
+      vnApi.createOrUpdate(virtualNetwork, location, virtualNetworkProperties);
 
       String path = 
String.format("/subscriptions/%s/resourcegroups/%s/providers/Microsoft.Network/virtualNetworks/%s?%s",
 subscriptionid, resourcegroup, virtualNetwork, apiVersion);
       String json = 
String.format("{\"location\":\"%s\",\"properties\":{\"addressSpace\":{\"addressPrefixes\":[\"%s\"]}}}",
 location, "10.2.0.0/16");

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/filters/ApiVersionFilterTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/filters/ApiVersionFilterTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/filters/ApiVersionFilterTest.java
new file mode 100644
index 0000000..f3b15ce
--- /dev/null
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/filters/ApiVersionFilterTest.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.jclouds.azurecompute.arm.filters;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static 
org.jclouds.azurecompute.arm.config.AzureComputeProperties.API_VERSION_PREFIX;
+import static org.jclouds.reflect.Reflection2.method;
+import static org.testng.Assert.assertEquals;
+
+import java.util.Properties;
+
+import javax.inject.Named;
+
+import org.jclouds.http.HttpRequest;
+import org.jclouds.http.HttpResponse;
+import org.jclouds.internal.FilterStringsBoundToInjectorByName;
+import org.jclouds.reflect.Invocation;
+import org.jclouds.rest.config.InvocationConfig;
+import org.jclouds.rest.internal.GeneratedHttpRequest;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import com.google.common.collect.ImmutableList;
+import com.google.inject.AbstractModule;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+import com.google.inject.name.Names;
+
+@Test(groups = "unit", testName = "ApiVersionFilterTest", singleThreaded = 
true)
+public class ApiVersionFilterTest {
+
+   public interface VersionedApi {
+      HttpResponse noName();
+
+      @Named("named:get")
+      HttpResponse named();
+   }
+
+   private Invocation noName;
+   private Invocation named;
+   private InvocationConfig config;
+
+   @BeforeMethod
+   public void setup() {
+      noName = Invocation.create(method(VersionedApi.class, "noName"), 
ImmutableList.of());
+      named = Invocation.create(method(VersionedApi.class, "named"), 
ImmutableList.of());
+
+      config = createMock(InvocationConfig.class);
+      expect(config.getCommandName(noName)).andReturn("VersionedApi.noName");
+      expect(config.getCommandName(named)).andReturn("named:get");
+      replay(config);
+   }
+
+   @Test(expectedExceptions = IllegalArgumentException.class)
+   public void testFailIfNoGeneratedHttpRequest() {
+      ApiVersionFilter filter = new ApiVersionFilter(config, 
filterStringsBoundToInjectorByName(new Properties()));
+      
filter.filter(HttpRequest.builder().method("GET").endpoint("http://localhost";).build());
+   }
+
+   @Test
+   public void testOverrideMethodVersion() {
+      Properties props = new Properties();
+      props.setProperty(API_VERSION_PREFIX + "named:get", "namedversion");
+      props.setProperty(API_VERSION_PREFIX + "VersionedApi.noName", 
"noNameversion");
+      ApiVersionFilter filter = new ApiVersionFilter(config, 
filterStringsBoundToInjectorByName(props));
+
+      HttpRequest request = 
GeneratedHttpRequest.builder().method("GET").endpoint("http://localhost";)
+            .invocation(noName).addQueryParam("api-version", "original", 
"original2").build();
+      HttpRequest filtered = filter.filter(request);
+      assertEquals(filtered.getEndpoint().getQuery(), 
"api-version=noNameversion");
+
+      request = 
GeneratedHttpRequest.builder().method("GET").endpoint("http://localhost";).invocation(named)
+            .addQueryParam("api-version", "original", "original2").build();
+      filtered = filter.filter(request);
+      assertEquals(filtered.getEndpoint().getQuery(), 
"api-version=namedversion");
+   }
+
+   @Test
+   public void testFallbackToClassName() {
+      Properties props = new Properties();
+      props.setProperty(API_VERSION_PREFIX + "VersionedApi", "classversion");
+      ApiVersionFilter filter = new ApiVersionFilter(config, 
filterStringsBoundToInjectorByName(props));
+
+      HttpRequest request = 
GeneratedHttpRequest.builder().method("GET").endpoint("http://localhost";)
+            .invocation(noName).addQueryParam("api-version", "original", 
"original2").build();
+      HttpRequest filtered = filter.filter(request);
+      assertEquals(filtered.getEndpoint().getQuery(), 
"api-version=classversion");
+
+      request = 
GeneratedHttpRequest.builder().method("GET").endpoint("http://localhost";).invocation(named)
+            .addQueryParam("api-version", "original", "original2").build();
+      filtered = filter.filter(request);
+      assertEquals(filtered.getEndpoint().getQuery(), 
"api-version=classversion");
+   }
+
+   @Test
+   public void testNothingChangesIfNoCustomVersion() {
+      ApiVersionFilter filter = new ApiVersionFilter(config, 
filterStringsBoundToInjectorByName(new Properties()));
+
+      HttpRequest request = 
GeneratedHttpRequest.builder().method("GET").endpoint("http://localhost";).invocation(named)
+            .addQueryParam("api-version", "foo").build();
+      HttpRequest filtered = filter.filter(request);
+      assertEquals(filtered.getEndpoint().getQuery(), "api-version=foo");
+   }
+
+   private FilterStringsBoundToInjectorByName 
filterStringsBoundToInjectorByName(final Properties props) {
+      Injector injector = Guice.createInjector(new AbstractModule() {
+         protected void configure() {
+            Names.bindProperties(binder(), props);
+         }
+      });
+      return new FilterStringsBoundToInjectorByName(injector);
+   }
+}

http://git-wip-us.apache.org/repos/asf/jclouds-labs/blob/2f110387/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiMockTest.java
----------------------------------------------------------------------
diff --git 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiMockTest.java
 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiMockTest.java
index 82af978..dc4ad28 100644
--- 
a/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiMockTest.java
+++ 
b/azurecompute-arm/src/test/java/org/jclouds/azurecompute/arm/internal/BaseAzureComputeApiMockTest.java
@@ -28,6 +28,7 @@ import org.jclouds.ContextBuilder;
 import org.jclouds.azurecompute.arm.AzureComputeApi;
 import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;
 import org.jclouds.concurrent.config.ExecutorServiceModule;
+import org.jclouds.rest.ApiContext;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 
@@ -50,6 +51,7 @@ public class BaseAzureComputeApiMockTest {
 
    protected MockWebServer server;
    protected AzureComputeApi api;
+   protected ApiContext<AzureComputeApi> context;
 
    // So that we can ignore formatting.
    private final JsonParser parser = new JsonParser();
@@ -58,16 +60,21 @@ public class BaseAzureComputeApiMockTest {
    public void start() throws IOException {
       server = new MockWebServer();
       server.play();
-      Properties properties = new Properties();
-      properties.put(CREDENTIAL_TYPE, BEARER_TOKEN_CREDENTIALS.toString());
-      properties.put("oauth.endpoint", 
"https://login.microsoftonline.com/tenant-id/oauth2/token";);
       AzureComputeProviderMetadata pm = 
AzureComputeProviderMetadata.builder().build();
-      api = ContextBuilder.newBuilder(pm)
+      context = ContextBuilder.newBuilder(pm)
               .credentials("", MOCK_BEARER_TOKEN)
               .endpoint(server.getUrl("/").toString() + 
"subscriptions/SUBSCRIPTIONID")
               .modules(modules)
-              .overrides(properties)
-              .buildApi(AzureComputeApi.class);
+              .overrides(setupProperties())
+              .build();
+      api = context.getApi();
+   }
+   
+   protected Properties setupProperties() {
+      Properties properties = new Properties();
+      properties.put(CREDENTIAL_TYPE, BEARER_TOKEN_CREDENTIALS.toString());
+      properties.put("oauth.endpoint", 
"https://login.microsoftonline.com/tenant-id/oauth2/token";);
+      return properties;
    }
 
    @AfterMethod(alwaysRun = true)

Reply via email to