Skip to content
This repository has been archived by the owner on Jul 25, 2020. It is now read-only.

Commit

Permalink
Adds missing mock test
Browse files Browse the repository at this point in the history
Fixes returning codes from API methods to 202
  • Loading branch information
danielestevez committed Jul 9, 2018
1 parent a7be178 commit 0218ee2
Showing 1 changed file with 20 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@
*/
package org.jclouds.azurecompute.arm.features;

import static com.google.common.collect.Iterables.isEmpty;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;

import java.net.URI;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
Expand Down Expand Up @@ -53,12 +59,6 @@
import com.google.common.collect.ImmutableMap;
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.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;

@Test(groups = "unit", testName = "VirtualMachineApiMockTest", singleThreaded = true)
public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {

Expand Down Expand Up @@ -213,7 +213,7 @@ public void testDelete() throws Exception {
}

public void testStart() throws Exception {
server.enqueue(new MockResponse().setResponseCode(204));
server.enqueue(response202WithHeader());

final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");

Expand All @@ -224,7 +224,7 @@ public void testStart() throws Exception {
}

public void testRestart() throws Exception {
server.enqueue(new MockResponse().setResponseCode(204));
server.enqueue(response202WithHeader());

final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");

Expand All @@ -235,7 +235,7 @@ public void testRestart() throws Exception {
}

public void testStop() throws Exception {
server.enqueue(new MockResponse().setResponseCode(204));
server.enqueue(response202WithHeader());

final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");

Expand All @@ -245,6 +245,17 @@ public void testStop() throws Exception {
+ "/virtualMachines/windowsmachine/powerOff?api-version=2016-04-30-preview");
}

public void testDeallocate() throws Exception {
server.enqueue(response202WithHeader());

final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");

vmAPI.deallocate("windowsmachine");

assertSent(server, "POST", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
+ "/virtualMachines/windowsmachine/deallocate?api-version=2016-04-30-preview");
}

public void testGeneralize() throws Exception {
server.enqueue(new MockResponse().setResponseCode(200));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
Expand Down

0 comments on commit 0218ee2

Please sign in to comment.