nacx requested changes on this pull request.


> +   }
+
+   public void testGet_NetworkProfile() throws InterruptedException {
+      
server.enqueue(jsonResponse("/virtualmachinescalesetget.json").setResponseCode(200));
+      final VirtualMachineScaleSetApi vmssAPI = 
api.getVirtualMachineScaleSetApi(resourcegroup);
+      assertEquals(vmssAPI.get(vmssname).properties().virtualMachineProfile()
+         .networkProfile()
+         .networkInterfaceConfigurations()
+         .size(), 1);
+
+      assertSent(server,
+              "GET",
+              
"/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup/providers/" +
+                      "Microsoft.Compute"
+              + "/VirtualMachineScaleSets/" + vmssname + 
"?api-version=2017-03-30");
+   }

All these additional tests are redundant since they call the same "get" API 
method than the one tested in the "testGet" test. If you want to validate 
additional fields from the returned object, are more assertions to the 
"testGet" instead of adding one test for each property you want to validate.

> +   }
+
+   public void testCreateOrUpdate() throws InterruptedException {
+      server.enqueue(
+              jsonResponse(
+                      
"/virtualmachinescalesetresponsecreateorupdate.json").setResponseCode(200));
+      final VirtualMachineScaleSetApi vmssAPI = 
api.getVirtualMachineScaleSetApi(resourcegroup);
+      VirtualMachineScaleSet vmss = CreateOrUpdateVMSS(vmssAPI);
+
+      assertNotNull(vmss);
+      assertSent(server,
+              "PUT",
+              
"/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup/providers/" +
+                      "Microsoft.Compute"
+                      + "/VirtualMachineScaleSets/" + vmssname + 
"?api-version=2017-03-30");
+   }

For requests that generate a body you also need to verify it. Check how it is 
done in the example test class I provided.

> +                                              null))),
+                              VirtualMachineScaleSetOSProfile.create(
+                                      "jclouds-vmssname",
+                                      "jclouds",
+                                      "jClouds1!",
+                                      
VirtualMachineScaleSetOSProfile.LinuxConfiguration.create(
+                                              "False",
+                                              null),
+                                      null,
+                                      new ArrayList<Secrets>()),
+                              getNetworkProfile(),
+                              getExtensionProfile()
+
+                      )
+              ));
+   }

Same here. Use just one "testCreate" complete enough to validate all properties 
you want to validate and remove all the redundant ones.

> +
+   public void testDeleteWhen404() throws InterruptedException {
+      
server.enqueue(jsonResponse("/virtualmachinescalesetlist.json").setResponseCode(404));
+      final VirtualMachineScaleSetApi vmssAPI = 
api.getVirtualMachineScaleSetApi(resourcegroup);
+      vmssAPI.delete(vmssname);
+      assertSent(server,
+              "DELETE",
+              
"/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup/providers/" +
+                      "Microsoft.Compute"
+              + "/VirtualMachineScaleSets/" + vmssname + 
"?api-version=2017-03-30");
+   }
+
+   public void testDelete() throws InterruptedException {
+      server.enqueue(response202WithHeader());
+      final VirtualMachineScaleSetApi vmssAPI = 
api.getVirtualMachineScaleSetApi(resourcegroup);
+      vmssAPI.delete(vmssname);

Verify that returns a non-null URI.

> +      final VirtualMachineScaleSetApi vmssAPI = 
> api.getVirtualMachineScaleSetApi(
+              resourcegroup + "1");
+      List<VirtualMachineScaleSet> vmssList = vmssAPI.list();
+      assertSent(server,
+              "GET",
+              
"/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/" +
+                      "Microsoft.Compute"
+              + "/VirtualMachineScaleSets?api-version=2017-03-30");
+      assertTrue(isEmpty(vmssList));
+   }
+
+
+   public void testDeleteWhen404() throws InterruptedException {
+      
server.enqueue(jsonResponse("/virtualmachinescalesetlist.json").setResponseCode(404));
+      final VirtualMachineScaleSetApi vmssAPI = 
api.getVirtualMachineScaleSetApi(resourcegroup);
+      vmssAPI.delete(vmssname);

Verify that returns null

> +      String subnetName = String.format("s-%s-%s", 
> this.getClass().getSimpleName().toLowerCase(), 
> System.getProperty("user.name"));
+      this.subnet = createDefaultSubnet(resourceGroupName, subnetName, 
virtualNetworkName, "10.2.0.0/23");
+      assertNotNull(subnet);
+      assertNotNull(subnet.id());
+      this.subnetId = subnet.id();
+
+
+      vmssName = String.format("%3.24s", System.getProperty("user.name") + 
RAND + this.getClass().getSimpleName()).toLowerCase().substring(0, 15);
+   }
+
+   @Test
+   public void testCreate() {
+      VirtualMachineScaleSet vmss = api().createOrUpdate(vmssName, 
LOCATIONDESCRIPTION, getSKU(),
+         Collections.<String, String>emptyMap(), getProperties());
+      assertTrue(!vmss.name().isEmpty());
+   }

Tests for the list, get and delete operations are still missing.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds-labs/pull/412#pullrequestreview-75032142

Reply via email to