Package org.jclouds.vcloud.director.v1_5.user

Examples of org.jclouds.vcloud.director.v1_5.user.VCloudDirectorApi


            .entries(ImmutableSet.of(itemMetadataEntry()))
            .build();

   @Test
   public void testGetCatalogItemMetadataHref() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadata, getItemMetadataResponse);
      assertEquals(api.getMetadataApi(itemHref).get(), expected);
   }
View Full Code Here


            .payload(payloadFromResourceWithContentType("/catalog/mergeMetadataTask.xml", TASK + ";version=1.5"))
            .build();
     
   @Test
   public void testMergeCatalogItemMetadataHref() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, mergeItemMetadata, mergeItemMetadataResponse);
      assertEquals(api.getMetadataApi(itemHref).putAll(ImmutableMap.of("KEY", "VALUE")), mergeMetadataTask());
   }
View Full Code Here

            .payload(payloadFromResourceWithContentType("/catalog/catalogItemMetadataValue.xml", METADATA_VALUE + ";version=1.5"))
            .build();
  
   @Test
   public void testGetCatalogItemMetadataEntryHref() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, getItemMetadataValue, getItemMetadataValueResponse);
      assertEquals(api.getMetadataApi(itemHref).get("KEY"), "VALUE");
   }
View Full Code Here

            .payload(payloadFromResourceWithContentType("/catalog/setMetadataValueTask.xml", TASK + ";version=1.5"))
            .build();
  
   @Test
   public void testSetCatalogItemMetadataEntryHref() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, putItemMetadata, putItemMetadataResponse);
      assertEquals(api.getMetadataApi(itemHref).put("KEY", "KITTENS"), setMetadataValueTask());
   }
View Full Code Here

            .payload(payloadFromResourceWithContentType("/catalog/removeMetadataEntryTask.xml", TASK))
            .build();  
  
   @Test
   public void testRemoveCatalogItemMetadataEntryHref() {
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse, removeItemMetadataEntry, removeItemMetadataEntryResponse);
      assertEquals(api.getMetadataApi(itemHref).remove("KEY"), removeTask());
   }
View Full Code Here

  
   @Test
   public void testAddMedia() {
      URI uploadLink = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/media");

      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse,
            new VcloudHttpRequestPrimer()
               .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/media")
               .acceptMedia(VCloudDirectorMediaType.MEDIA)
               .xmlFilePayload("/media/addMediaSource.xml", VCloudDirectorMediaType.MEDIA)
               .httpRequestBuilder().build(),
            new VcloudHttpResponsePrimer()
               .xmlFilePayload("/media/addMedia.xml", VCloudDirectorMediaType.MEDIA)
               .httpResponseBuilder().statusCode(201).build());
     
      Media source = Media.builder()
         .size(0)
         .imageType(ImageType.ISO)
         .name("Test media 1")
         .type("application/vnd.vmware.vcloud.media+xml")
         .description("Test media generated by testCreateMedia()")
         .build();
      Media expected = addMedia();
     
      assertEquals(api.getMediaApi().add(uploadLink, source), expected);
   }
View Full Code Here

  
   @Test
   public void testCloneMedia() {
      URI vdcURI = URI.create(endpoint + "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f");

      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse,
            new VcloudHttpRequestPrimer()
               .apiCommand("POST", "/vdc/e9cd3387-ac57-4d27-a481-9bee75e0690f/action/cloneMedia")
               .acceptMedia(VCloudDirectorMediaType.MEDIA)
               .xmlFilePayload("/media/cloneMediaParams.xml", VCloudDirectorMediaType.CLONE_MEDIA_PARAMS)
               .httpRequestBuilder().build(),
            new VcloudHttpResponsePrimer()
               .xmlFilePayload("/media/cloneMedia.xml", VCloudDirectorMediaType.MEDIA)
               .httpResponseBuilder().statusCode(201).build());
     
      CloneMediaParams params = CloneMediaParams.builder()
         .name("moved test media")
         .description("moved by testCloneMedia()")
         .source(Reference.builder()
               .type("application/vnd.vmware.vcloud.media+xml")
               .name("copied test media")
               .href(URI.create("https://mycloud.greenhousedata.com/api/media/da8361af-cccd-4103-a71c-493513c49094"))
               .build())
         .isSourceDelete(false)
         .build();
      Media expected = cloneMedia();
     
      assertEquals(api.getMediaApi().clone(vdcURI, params), expected);
   }
View Full Code Here

  
   @Test
   public void testGetMedia() {
      URI mediaUri = URI.create(endpoint + "/media/794eb334-754e-4917-b5a0-5df85cbd61d1");

      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse,
            new VcloudHttpRequestPrimer()
               .apiCommand("GET", "/media/794eb334-754e-4917-b5a0-5df85cbd61d1")
               .acceptAnyMedia()
               .httpRequestBuilder().build(),
            new VcloudHttpResponsePrimer()
               .xmlFilePayload("/media/media.xml", VCloudDirectorMediaType.MEDIA)
               .httpResponseBuilder().build());
     
      Media expected = getMedia();
      assertEquals(api.getMediaApi().get(mediaUri), expected);
   }
View Full Code Here

  
   @Test
   public void testResponse400ForInvalidMedia() {
      URI mediaUri = URI.create(endpoint + "/media/NOTAUUID");
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse,
            new VcloudHttpRequestPrimer()
               .apiCommand("GET", "/media/NOTAUUID")
               .acceptAnyMedia()
               .httpRequestBuilder().build(),
            new VcloudHttpResponsePrimer()
               .xmlFilePayload("/media/error400.xml", VCloudDirectorMediaType.ERROR)
               .httpResponseBuilder().statusCode(400).build());
      Error expected = Error.builder()
            .message("validation error on field 'id': String value has invalid format or length")
            .majorErrorCode(400)
            .minorErrorCode("BAD_REQUEST")
            .build();
      
      try {
         api.getMediaApi().get(mediaUri);
         fail("Should give HTTP 400 error");
      } catch (VCloudDirectorException vde) {
         assertEquals(vde.getError(), expected);
      } catch (Exception e) {
         fail("Should have thrown a VCloudDirectorException", e);
View Full Code Here

   @Test
   public void testNullResponseForCatalogIdUsedAsMediaId() {
      URI mediaUri = URI.create(endpoint + "/media/e9cd3387-ac57-4d27-a481-9bee75e0690f");
      VCloudDirectorApi api = requestsSendResponses(loginRequest, sessionResponse,
            new VcloudHttpRequestPrimer()
               .apiCommand("GET", "/media/e9cd3387-ac57-4d27-a481-9bee75e0690f")
               .acceptAnyMedia()
               .httpRequestBuilder().build(),
            new VcloudHttpResponsePrimer()
               .xmlFilePayload("/media/error403-catalog.xml", VCloudDirectorMediaType.ERROR)
               .httpResponseBuilder().statusCode(403).build());
      assertNull(api.getMediaApi().get(mediaUri));
   }
View Full Code Here

TOP

Related Classes of org.jclouds.vcloud.director.v1_5.user.VCloudDirectorApi

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.