@Test(groups = "live")
 public void testGetProjectWhenExists() {
   this.project = projectApi().get(userProject.get());
   assertNotNull(project);
   assertNotNull(project.getId());
   assertNotNull(project.getName());
 }
 /**
  * Adds an item to the Project's metadata
  *
  * <p>Beyond it's use here it is also used as a cheap way of generating Operations to both test
  * the OperationApi and the pagination system.
  */
 public static Operation addItemToMetadata(
     ProjectApi projectApi, String projectName, String key, String value) {
   Project project = projectApi.get(projectName);
   assertNotNull(project);
   ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder();
   metadataBuilder.putAll(project.getCommonInstanceMetadata().getItems());
   metadataBuilder.put(key, value);
   return projectApi.setCommonInstanceMetadata(
       projectName, metadataBuilder.build(), project.getCommonInstanceMetadata().getFingerprint());
 }
 /**
  * Deletes an item from the Project's metadata
  *
  * <p>Beyond it's use here it is also used as a cheap way of generating Operation's to both test
  * the OperationApi and the pagination system.
  */
 public static Operation deleteItemFromMetadata(
     ProjectApi projectApi, String projectName, String key) {
   Project project = projectApi.get(projectName);
   assertNotNull(project);
   ImmutableMap.Builder<String, String> metadataBuilder = ImmutableMap.builder();
   metadataBuilder.putAll(
       Maps.filterKeys(project.getCommonInstanceMetadata().getItems(), not(equalTo(key))));
   return projectApi.setCommonInstanceMetadata(
       projectName, metadataBuilder.build(), project.getCommonInstanceMetadata().getFingerprint());
 }
Ejemplo n.º 4
0
 @Override
 @Consumes(MediaType.APPLICATION_JSON)
 public Project expected() {
   return Project.builder()
       .id("13024414184846275913")
       .creationTimestamp(new Date(Long.parseLong("1351109596252")))
       .selfLink(URI.create("https://www.googleapis.com/compute/v1beta13/projects/myproject"))
       .name("myproject")
       .description("")
       .commonInstanceMetadata(
           ImmutableMap.<String, String>builder()
               .put("propA", "valueA")
               .put("propB", "valueB")
               .build())
       .addQuota("INSTANCES", 0, 8)
       .addQuota("CPUS", 0, 8)
       .addQuota("EPHEMERAL_ADDRESSES", 0, 8)
       .addQuota("DISKS", 0, 8)
       .addQuota("DISKS_TOTAL_GB", 0, 100)
       .addQuota("SNAPSHOTS", 0, 1000)
       .addQuota("NETWORKS", 1, 5)
       .addQuota("FIREWALLS", 2, 100)
       .addQuota("IMAGES", 0, 100)
       .build();
 }
 @Test(groups = "live", dependsOnMethods = "addItemToMetadata")
 public void testDeleteItemFromMetadata() {
   assertGlobalOperationDoneSucessfully(
       deleteItemFromMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY), 20);
   this.project = projectApi().get(userProject.get());
   assertNotNull(project);
   assertFalse(project.getCommonInstanceMetadata().getItems().containsKey(METADATA_ITEM_KEY));
   assertSame(this.project.getCommonInstanceMetadata().getItems().size(), initialMetadataSize);
   assertEquals(this.project.getCommonInstanceMetadata().getFingerprint(), initialFingerprint);
 }
 @Test(groups = "live", dependsOnMethods = "testGetProjectWhenExists")
 public void addItemToMetadata() {
   this.initialMetadataSize = project.getCommonInstanceMetadata().getItems().size();
   this.initialFingerprint = this.project.getCommonInstanceMetadata().getFingerprint();
   assertGlobalOperationDoneSucessfully(
       addItemToMetadata(projectApi(), userProject.get(), METADATA_ITEM_KEY, METADATA_ITEM_VALUE),
       20);
   this.project = projectApi().get(userProject.get());
   assertNotNull(project);
   assertTrue(
       this.project.getCommonInstanceMetadata().getItems().containsKey(METADATA_ITEM_KEY),
       this.project.toString());
   assertEquals(
       this.project.getCommonInstanceMetadata().getItems().get(METADATA_ITEM_KEY),
       METADATA_ITEM_VALUE);
   assertNotNull(this.project.getCommonInstanceMetadata().getFingerprint());
 }
Ejemplo n.º 7
0
 public Builder fromProject(Project in) {
   return super.fromResource(in)
       .commonInstanceMetadata(in.getCommonInstanceMetadata())
       .quotas(in.getQuotas())
       .externalIpAddresses(in.getExternalIpAddresses());
 }