Search in sources :

Example 16 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class FloatingIPTests method deallocateFloatingIP.

@Test(dataProvider = "floatingIPs")
public void deallocateFloatingIP(String ip) {
    // Test deallocate success
    respondWith(202);
    ActionResponse successResponse = osv3().compute().floatingIps().deallocateIP(ip);
    assertNotNull(successResponse);
    assertTrue(successResponse.isSuccess());
    String jsonResponse = String.format("{\"itemNotFound\": {" + "\"message\": \"Floating ip not found for id %s\", " + "\"code\": 404}}", ip);
    // Test deallocate error
    respondWith(404, jsonResponse);
    ActionResponse failureResponse = osv3().compute().floatingIps().deallocateIP(ip);
    assertNotNull(failureResponse);
    assertFalse(failureResponse.isSuccess());
    assertEquals(failureResponse.getCode(), 404);
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse) Test(org.testng.annotations.Test) AbstractTest(org.openstack4j.api.AbstractTest)

Example 17 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class FloatingIPTests method removeFloatingIP.

@Test(dataProvider = "floatingIPs")
public void removeFloatingIP(String ip) {
    String serverId = "255b83fd-1193-44a8-aba5-9887b347a41d";
    // Test remove floatingIP success
    respondWith(202);
    ActionResponse successResponse = osv3().compute().floatingIps().removeFloatingIP(serverId, ip);
    assertNotNull(successResponse);
    assertTrue(successResponse.isSuccess());
    // Test remove floatingIP fail -- Floating ip existed but not bind to server or server instance not existed
    String jsonResponse = String.format("{\"itemNotFound\": {" + "\"message\": \"Floating ip %s is not associated with instance %s.\", " + "\"code\": 409}}", ip, serverId);
    respondWith(409, jsonResponse);
    ActionResponse failureResponse = osv3().compute().floatingIps().removeFloatingIP(serverId, ip);
    assertNotNull(failureResponse);
    assertFalse(failureResponse.isSuccess());
    assertEquals(failureResponse.getCode(), 409);
    // Test remove floatingIP fail -- floatingIP not existed
    String jsonResponse2 = String.format("{\"itemNotFound\": {" + "\"message\": \"floating ip not found\", " + "\"code\": 404}}");
    respondWith(404, jsonResponse2);
    ActionResponse failureResponse2 = osv3().compute().floatingIps().removeFloatingIP(serverId, ip);
    assertNotNull(failureResponse2);
    assertFalse(failureResponse2.isSuccess());
    assertEquals(failureResponse2.getCode(), 404);
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse) Test(org.testng.annotations.Test) AbstractTest(org.openstack4j.api.AbstractTest)

Example 18 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class PolicyTargetServiceTest method testDeletePolicyTarget.

@Test
public void testDeletePolicyTarget() {
    respondWith(200);
    String id = "0d65eebe-4efe-456e-aec3-7856e4e839b4";
    ActionResponse result = osv2().gbp().policyTarget().delete(id);
    assertTrue(result.isSuccess());
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse) AbstractTest(org.openstack4j.api.AbstractTest) Test(org.testng.annotations.Test)

Example 19 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class DesignateZoneServiceTest method zoneDeleteTest.

public void zoneDeleteTest() throws Exception {
    respondWith(204);
    ActionResponse zoneDeleteResponse = osv3().dns().zones().delete(ZONE_ID);
    assertTrue(zoneDeleteResponse.isSuccess());
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse)

Example 20 with ActionResponse

use of org.openstack4j.model.common.ActionResponse in project openstack4j by ContainX.

the class ExternalPolicyServiceTest method testDeleteExternalPolicy.

@Test
public void testDeleteExternalPolicy() {
    respondWith(200);
    String id = "8d14b663-c67d-4fa7-b23f-0732cb9aa292";
    ActionResponse result = osv2().gbp().externalPolicy().delete(id);
    assertTrue(result.isSuccess());
}
Also used : ActionResponse(org.openstack4j.model.common.ActionResponse) AbstractTest(org.openstack4j.api.AbstractTest) Test(org.testng.annotations.Test)

Aggregations

ActionResponse (org.openstack4j.model.common.ActionResponse)123 AbstractTest (org.openstack4j.api.AbstractTest)54 Test (org.testng.annotations.Test)54 Message (org.apache.camel.Message)25 ArrayList (java.util.ArrayList)2 CreateUpdateContainerOptions (org.openstack4j.model.storage.object.options.CreateUpdateContainerOptions)2 TroveBuilders (org.openstack4j.openstack.trove.builder.TroveBuilders)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 File (java.io.File)1 InputStream (java.io.InputStream)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 RecordedRequest (okhttp3.mockwebserver.RecordedRequest)1 ResponseToActionResponse (org.openstack4j.core.transport.functions.ResponseToActionResponse)1 Action (org.openstack4j.model.compute.Action)1 User (org.openstack4j.model.identity.v3.User)1 Volume (org.openstack4j.model.storage.block.Volume)1 VolumeSnapshot (org.openstack4j.model.storage.block.VolumeSnapshot)1 KeystoneUser (org.openstack4j.openstack.identity.v3.domain.KeystoneUser)1 TroveDatabase (org.openstack4j.openstack.trove.domain.TroveDatabase)1