Package org.jclouds.dmtf.cim

Examples of org.jclouds.dmtf.cim.ResourceAllocationSettingData


      // Copy existing section and edit fields
      VirtualHardwareSection oldSection = vmApi.getVirtualHardwareSection(vmUrn);
      Set<? extends ResourceAllocationSettingData> oldItems = oldSection.getItems();
      Set<ResourceAllocationSettingData> newItems = Sets.newLinkedHashSet(oldItems);
      ResourceAllocationSettingData oldMemory = Iterables.find(oldItems,
               new Predicate<ResourceAllocationSettingData>() {
                  @Override
                  public boolean apply(ResourceAllocationSettingData rasd) {
                     return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
                  }
               });
      ResourceAllocationSettingData newMemory = oldMemory.toBuilder().elementName("1024 MB of memory")
               .virtualQuantity(new BigInteger("1024")).build();
      newItems.remove(oldMemory);
      newItems.add(newMemory);
      VirtualHardwareSection newSection = oldSection.toBuilder().items(newItems).build();

      // The method under test
      Task editVirtualHardwareSection = vmApi.editVirtualHardwareSection(vmUrn, newSection);
      assertTrue(retryTaskSuccess.apply(editVirtualHardwareSection),
               String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSection"));

      // Retrieve the modified section
      VirtualHardwareSection modifiedSection = vmApi.getVirtualHardwareSection(vmUrn);

      // Check the retrieved object is well formed
      checkVirtualHardwareSection(modifiedSection);

      // Check the modified section fields are set correctly
      ResourceAllocationSettingData modifiedMemory = Iterables.find(modifiedSection.getItems(),
               new Predicate<ResourceAllocationSettingData>() {
                  @Override
                  public boolean apply(ResourceAllocationSettingData rasd) {
                     return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
                  }
               });
      assertEquals(modifiedMemory.getVirtualQuantity(), new BigInteger("1024"));
      assertEquals(modifiedMemory, newMemory);
      assertEquals(modifiedSection, newSection);
   }
View Full Code Here


      // Copy existing section and edit fields
      VirtualHardwareSection oldSection = vmApi.getVirtualHardwareSection(vmUrn);
      Set<? extends ResourceAllocationSettingData> oldItems = oldSection.getItems();
      Set<ResourceAllocationSettingData> newItems = Sets.newLinkedHashSet(oldItems);
      ResourceAllocationSettingData oldMemory = Iterables.find(oldItems,
               new Predicate<ResourceAllocationSettingData>() {
                  @Override
                  public boolean apply(ResourceAllocationSettingData rasd) {
                     return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
                  }
               });
      ResourceAllocationSettingData newMemory = oldMemory.toBuilder().elementName("1024 MB of memory")
               .virtualQuantity(new BigInteger("1024")).build();
      newItems.remove(oldMemory);
      newItems.add(newMemory);
      VirtualHardwareSection newSection = oldSection.toBuilder().items(newItems).build();

      // The method under test
      Task editVirtualHardwareSection = vmApi.editVirtualHardwareSection(vmUrn, newSection);
      assertTrue(retryTaskSuccess.apply(editVirtualHardwareSection),
               String.format(TASK_COMPLETE_TIMELY, "editVirtualHardwareSection"));

      // Retrieve the modified section
      VirtualHardwareSection modifiedSection = vmApi.getVirtualHardwareSection(vmUrn);

      // Check the retrieved object is well formed
      checkVirtualHardwareSection(modifiedSection);

      // Check the modified section fields are set correctly
      ResourceAllocationSettingData modifiedMemory = Iterables.find(modifiedSection.getItems(),
               new Predicate<ResourceAllocationSettingData>() {
                  @Override
                  public boolean apply(ResourceAllocationSettingData rasd) {
                     return rasd.getResourceType() == ResourceAllocationSettingData.ResourceType.MEMORY;
                  }
               });
      assertEquals(modifiedMemory.getVirtualQuantity(), new BigInteger("1024"));
      assertEquals(modifiedMemory, newMemory);
      assertEquals(modifiedSection, newSection);
   }
View Full Code Here

TOP

Related Classes of org.jclouds.dmtf.cim.ResourceAllocationSettingData

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.