gpt4 book ai didi

io.sphere.sdk.zones.Zone类的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 15:23:31 26 4
gpt4 key购买 nike

本文整理了Java中io.sphere.sdk.zones.Zone类的一些代码示例,展示了Zone类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Zone类的具体详情如下:
包路径:io.sphere.sdk.zones.Zone
类名称:Zone

Zone介绍

[英]Zones define Shipping Rates for a set of Locations.
[中]分区定义了一组位置的运费。

代码示例

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

@Override
default Reference<Zone> toReference() {
  return Reference.of(referenceTypeId(), getId(), this);
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

/**
 * Looks up the locations and checks if the country is present. It does not matter if the location has a state specified.
 *
 * @param countryCode the country to search for
 * @return true if the country is somehow in the locations.
 */
default boolean contains(final CountryCode countryCode) {
  return getLocations().stream().anyMatch(location -> location.getCountry().equals(countryCode));
}

代码示例来源:origin: io.sphere.sdk.jvm/models

@Override
default Reference<Zone> toReference() {
  return Reference.of(typeId(), getId(), this);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
  public void createByZone() {
    final ZoneDraft draft = SphereJsonUtils.readObjectFromResource("drafts-tests/zone.json", ZoneDraft.class);
    withZone(client(), draft, zone -> {
      assertThat(zone.getName()).isEqualTo("demo zone");
      assertThat(zone.getLocations()).isEqualTo(asSet(Location.of(CH, "Vaud"), Location.of(CH)));
    });
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
  public void fetchById() throws Exception {
    ZoneFixtures.withUpdateableZone(client(), zone -> {
      final Zone fetchedZone = client().executeBlocking(ZoneByIdGet.of(zone.getId()));
      assertThat(fetchedZone.getId()).isEqualTo(zone.getId());
      return zone;
    }, CountryCode.BA);
  }
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

static Reference<Zone> referenceOfId(final String id) {
    return Reference.of(referenceTypeId(), id);
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void updateByKey() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zone -> {
    final String newKey = randomKey();
    assertThat(zone.getKey()).isNotEqualTo(newKey);
    final ZoneUpdateCommand command = ZoneUpdateCommand.of(zone, SetKey.of(newKey));
    final Zone updatedZone = client().executeBlocking(command);
    assertThat(updatedZone.getKey()).isEqualTo(newKey);
    final String newKey2 = randomKey();
    final ZoneUpdateCommand commandByKey = ZoneUpdateCommand.ofKey(updatedZone.getKey(),updatedZone.getVersion(), SetKey.of(newKey2));
    final Zone updatedZone2 = client().executeBlocking(commandByKey);
    assertThat(updatedZone2.getKey()).isEqualTo(newKey2);
    return updatedZone2;
  }, CountryCode.AM);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void changeName() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zone -> {
    final String newName = randomString();
    assertThat(zone.getName()).isNotEqualTo(newName);
    final ZoneUpdateCommand command = ZoneUpdateCommand.of(zone, ChangeName.of(newName));
    final Zone updatedZone = client().executeBlocking(command);
    assertThat(updatedZone.getName()).isEqualTo(newName);
    return updatedZone;
  }, CountryCode.AM);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void setKey() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zone -> {
    final String newKey = randomKey();
    assertThat(zone.getKey()).isNotEqualTo(newKey);
    final ZoneUpdateCommand command = ZoneUpdateCommand.of(zone, SetKey.of(newKey));
    final Zone updatedZone = client().executeBlocking(command);
    assertThat(updatedZone.getKey()).isEqualTo(newKey);
    return updatedZone;
  }, CountryCode.AM);
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void setDescription() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zone -> {
    final String newDescription = randomString();
    assertThat(zone.getDescription()).isNotEqualTo(newDescription);
    final ZoneUpdateCommand command = ZoneUpdateCommand.of(zone, SetDescription.of(newDescription));
    final Zone updatedZone = client().executeBlocking(command);
    assertThat(updatedZone.getDescription()).isEqualTo(newDescription);
    return updatedZone;
  }, CountryCode.AN);
}

代码示例来源:origin: com.commercetools.sdk.jvm.core/commercetools-models

/**
   * Creates a reference for one item of this class by a known ID.
   *
   * <p>An example for categories but this applies for other resources, too:</p>
   * {@include.example io.sphere.sdk.categories.CategoryTest#referenceOfId()}
   *
   * <p>If you already have a resource object, then use {@link #toReference()} instead:</p>
   *
   * {@include.example io.sphere.sdk.categories.CategoryTest#toReference()}
   *
   * @param id the ID of the resource which should be referenced.
   * @return reference
   */
  static Reference<Zone> referenceOfId(final String id) {
    return Reference.of(referenceTypeId(), id);
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void execution() throws Exception {
  final Set<CountryCode> euAndSwissCountries = asSet(AT, BE, CH);//not complete, but you get the idea
  final String key = randomKey();
  final Set<Location> locations = euAndSwissCountries.stream().map(country -> Location.of(country)).collect(toSet());
  final ZoneDraft draft = ZoneDraftBuilder.of("zone1",locations ).description("EU and Swiss").key(key).build();
  final ZoneCreateCommand createCommand = ZoneCreateCommand.of(draft);
  final Zone zone = client().executeBlocking(createCommand);
  assertThat(zone.getKey()).isEqualTo(key);
  //end example parsing here
  client().executeBlocking(ZoneDeleteCommand.ofKey(zone.getKey(),zone.getVersion()));
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
public void queryByName() throws Exception {
  ZoneFixtures.withUpdateableZone(client(), zoneA -> {
    ZoneFixtures.withUpdateableZone(client(), zoneB -> {
      final PagedQueryResult<Zone> result = client().executeBlocking(ZoneQuery.of().byName(zoneA.getName()));
      assertThat(result.getResults()).isEqualTo(asList(zoneA));
      return zoneB;
    }, CD);
    return zoneA;
  }, CC);
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

@Override
default Reference<Zone> toReference() {
  return Reference.of(referenceTypeId(), getId(), this);
}

代码示例来源:origin: io.sphere.sdk.jvm/models

/**
   * Looks up the locations and checks if the country is present. It does not matter if the location has a state specified.
   *
   * @param countryCode the country to search for
   * @return true if the country is somehow in the locations.
   */
  default boolean contains(final CountryCode countryCode) {
    return getLocations().stream().anyMatch(location -> location.getCountry().equals(countryCode));
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

/**
   * Creates a reference for one item of this class by a known ID.
   *
   * <p>An example for categories but this applies for other resources, too:</p>
   * {@include.example io.sphere.sdk.categories.CategoryTest#referenceOfId()}
   *
   * <p>If you already have a resource object, then use {@link #toReference()} instead:</p>
   *
   * {@include.example io.sphere.sdk.categories.CategoryTest#toReference()}
   *
   * @param id the ID of the resource which should be referenced.
   * @return reference
   */
  static Reference<Zone> referenceOfId(final String id) {
    return Reference.of(referenceTypeId(), id);
  }
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Override
default Reference<Zone> toReference() {
  return Reference.of(referenceTypeId(), getId(), this);
}

代码示例来源:origin: io.sphere.sdk.jvm/sphere-models

/**
 * Looks up the locations and checks if the country is present. It does not matter if the location has a state specified.
 *
 * @param countryCode the country to search for
 * @return true if the country is somehow in the locations.
 */
default boolean contains(final CountryCode countryCode) {
  return getLocations().stream().anyMatch(location -> location.getCountry().equals(countryCode));
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

/**
 * Looks up the locations and checks if the country is present. It does not matter if the location has a state specified.
 *
 * @param countryCode the country to search for
 * @return true if the country is somehow in the locations.
 */
default boolean contains(final CountryCode countryCode) {
  return getLocations().stream().anyMatch(location -> location.getCountry().equals(countryCode));
}

代码示例来源:origin: commercetools/commercetools-jvm-sdk

@Test
  public void addLocationAndRemoveLocation() throws Exception {
    ZoneFixtures.withUpdateableZone(client(), zone -> {
      //adding a location
      final Location newLocation = Location.of(CountryCode.AQ, "state");
      assertThat(zone.getLocations().contains(newLocation)).isFalse();
      final ZoneUpdateCommand addCommand = ZoneUpdateCommand.of(zone, AddLocation.of(newLocation));
      final Zone zoneWithNewLocation = client().executeBlocking(addCommand);
      assertThat(zoneWithNewLocation.getLocations()).contains(newLocation);

      //removing a location
      final ZoneUpdateCommand removeCommand = ZoneUpdateCommand.of(zoneWithNewLocation, RemoveLocation.of(newLocation));
      final Zone zoneWithoutNewLocation = client().executeBlocking(removeCommand);
      assertThat(zoneWithoutNewLocation.getLocations().contains(newLocation)).isFalse();

      return zoneWithoutNewLocation;
    }, CountryCode.AO);
  }
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com