private void checkServiceOffering(ServiceOffering offering) {
   assertNotNull(offering.getId());
   assertEquals(offering.getCpuNumber(), 2);
   assertEquals(offering.getCpuSpeed(), 1024);
   assertEquals(offering.getMemory(), 2048);
   assertTrue(offering.supportsHA());
   assertEquals(offering.getStorageType(), StorageType.LOCAL);
 }
 @Override
 public boolean equals(Object obj) {
   if (this == obj) return true;
   if (obj == null || getClass() != obj.getClass()) return false;
   ServiceOffering that = ServiceOffering.class.cast(obj);
   return Objects.equal(this.id, that.id)
       && Objects.equal(this.name, that.name)
       && Objects.equal(this.displayText, that.displayText)
       && Objects.equal(this.created, that.created)
       && Objects.equal(this.domain, that.domain)
       && Objects.equal(this.domainId, that.domainId)
       && Objects.equal(this.cpuNumber, that.cpuNumber)
       && Objects.equal(this.cpuSpeed, that.cpuSpeed)
       && Objects.equal(this.memory, that.memory)
       && Objects.equal(this.haSupport, that.haSupport)
       && Objects.equal(this.storageType, that.storageType)
       && Objects.equal(this.getTags(), that.getTags())
       && Objects.equal(this.defaultUse, that.defaultUse)
       && Objects.equal(this.systemOffering, that.systemOffering)
       && Objects.equal(this.cpuUseLimited, that.cpuUseLimited)
       && Objects.equal(this.networkRate, that.networkRate)
       && Objects.equal(this.systemVmType, that.systemVmType);
 }
  @Test(groups = "live", enabled = true)
  public void testCreateServiceOffering() throws Exception {
    skipIfNotGlobalAdmin();

    String name = prefix + "-test-create-service-offering";
    String displayText = name + "-display";
    ServiceOffering offering = null;
    try {
      offering =
          globalAdminClient
              .getOfferingApi()
              .createServiceOffering(
                  name,
                  displayText,
                  2,
                  1024,
                  2048,
                  highlyAvailable(true).storageType(StorageType.LOCAL));
      Logger.CONSOLE.info("Created Service Offering: " + offering);

      assertEquals(offering.getName(), name);
      assertEquals(offering.getDisplayText(), displayText);
      checkServiceOffering(offering);

      offering =
          globalAdminClient
              .getOfferingApi()
              .updateServiceOffering(
                  offering.getId(),
                  UpdateServiceOfferingOptions.Builder.name(name + "-2")
                      .displayText(displayText + "-2"));

      assertEquals(offering.getName(), name + "-2");
      assertEquals(offering.getDisplayText(), displayText + "-2");
      checkServiceOffering(offering);

    } finally {
      if (offering != null) {
        globalAdminClient.getOfferingApi().deleteServiceOffering(offering.getId());
      }
    }
  }
 @Override
 public int compareTo(ServiceOffering o) {
   return id.compareTo(o.getId());
 }
 public T fromServiceOffering(ServiceOffering in) {
   return this.id(in.getId())
       .name(in.getName())
       .displayText(in.getDisplayText())
       .created(in.getCreated())
       .domain(in.getDomain())
       .domainId(in.getDomainId())
       .cpuNumber(in.getCpuNumber())
       .cpuSpeed(in.getCpuSpeed())
       .memory(in.getMemory())
       .supportsHA(in.supportsHA())
       .storageType(in.getStorageType())
       .tags(in.getTags())
       .defaultUse(in.isDefaultUse())
       .systemOffering(in.isSystemOffering())
       .cpuUseLimited(in.isCpuUseLimited())
       .networkRate(in.getNetworkRate())
       .systemVmType(in.isSystemVmType());
 }