Пример #1
0
  public void testGetInstanceFail() {
    URI endpoint = URI.create("http://172.16.0.1:8776/v1/3456/instances/12312");
    InstanceApi api =
        requestsSendResponses(
                keystoneAuthWithUsernameAndPasswordAndTenantName,
                responseWithKeystoneAccess,
                authenticatedGET().endpoint(endpoint).build(),
                HttpResponse.builder().statusCode(404).build())
            .getInstanceApi("RegionOne");

    assertNull(api.get("12312"));
  }
Пример #2
0
  public void testGetInstance() {
    URI endpoint =
        URI.create("http://172.16.0.1:8776/v1/3456/instances/44b277eb-39be-4921-be31-3d61b43651d7");
    InstanceApi api =
        requestsSendResponses(
                keystoneAuthWithUsernameAndPasswordAndTenantName,
                responseWithKeystoneAccess,
                authenticatedGET().endpoint(endpoint).build(),
                HttpResponse.builder()
                    .statusCode(200)
                    .payload(payloadFromResource("/instance_get.json"))
                    .build())
            .getInstanceApi("RegionOne");

    Instance instance = api.get("44b277eb-39be-4921-be31-3d61b43651d7");
    assertEquals(instance.getName(), "json_rack_instance");
    assertEquals(instance.getId(), "44b277eb-39be-4921-be31-3d61b43651d7");
    assertEquals(instance.getLinks().size(), 2);
    assertEquals(
        instance.getHostname(), "e09ad9a3f73309469cf1f43d11e79549caf9acf2.rackspaceclouddb.com");
  }