当前位置: 首页>>代码示例>>Java>>正文


Java Money类代码示例

本文整理汇总了Java中org.joda.money.Money的典型用法代码示例。如果您正苦于以下问题:Java Money类的具体用法?Java Money怎么用?Java Money使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Money类属于org.joda.money包,在下文中一共展示了Money类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testFailure_wrongCurrency_v12

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v12() throws Exception {
  createTld("tld", TldState.LANDRUSH);
  setEppInput("domain_create_landrush_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  clock.advanceOneMilli();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:DomainApplicationCreateFlowTest.java

示例2: testSuccess_eapFeeApplied_v06

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testSuccess_eapFeeApplied_v06() throws Exception {
  setEppInput("domain_create_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
  persistContactsAndHosts();
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setEapFeeSchedule(
              ImmutableSortedMap.of(
                  START_OF_TIME,
                  Money.of(USD, 0),
                  clock.nowUtc().minusDays(1),
                  Money.of(USD, 100),
                  clock.nowUtc().plusDays(1),
                  Money.of(USD, 0)))
          .build());
  doSuccessfulTest(
      "tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:DomainCreateFlowTest.java

示例3: testSuccess_eapFeeApplied_v11

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testSuccess_eapFeeApplied_v11() throws Exception {
  setEppInput("domain_create_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
  persistContactsAndHosts();
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setEapFeeSchedule(
              ImmutableSortedMap.of(
                  START_OF_TIME,
                  Money.of(USD, 0),
                  clock.nowUtc().minusDays(1),
                  Money.of(USD, 100),
                  clock.nowUtc().plusDays(1),
                  Money.of(USD, 0)))
          .build());
  doSuccessfulTest(
      "tld", "domain_create_response_eap_fee.xml", ImmutableMap.of("FEE_VERSION", "0.11"));
}
 
开发者ID:google,项目名称:nomulus,代码行数:20,代码来源:DomainCreateFlowTest.java

示例4: testBadTimeOrdering_causesError

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testBadTimeOrdering_causesError() throws Exception {
  IllegalStateException thrown =
      expectThrows(
          IllegalStateException.class,
          () ->
              new RegistrarBillingEntry.Builder()
                  .setPrevious(
                      new RegistrarBillingEntry.Builder()
                          .setPrevious(null)
                          .setParent(loadRegistrar("NewRegistrar"))
                          .setCreated(DateTime.parse("1984-12-18TZ"))
                          .setDescription("USD Invoice for December")
                          .setAmount(Money.parse("USD 10.00"))
                          .build())
                  .setParent(loadRegistrar("NewRegistrar"))
                  .setCreated(DateTime.parse("1984-12-17TZ"))
                  .setTransactionId("goblin")
                  .setDescription("USD Invoice for August")
                  .setAmount(Money.parse("USD 3.50"))
                  .build());
  assertThat(thrown).hasMessageThat().contains("Created timestamp not after previous");
}
 
开发者ID:google,项目名称:nomulus,代码行数:24,代码来源:RegistrarBillingEntryTest.java

示例5: testFailure_wrongCurrency_v06

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v06() throws Exception {
  setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainCreateFlowTest.java

示例6: createFromLine

import org.joda.money.Money; //导入依赖的package包/类
@Override
@Nullable
PremiumListEntry createFromLine(String originalLine) {
  List<String> lineAndComment = splitOnComment(originalLine);
  if (lineAndComment.isEmpty()) {
    return null;
  }
  String line = lineAndComment.get(0);
  String comment = lineAndComment.get(1);
  List<String> parts = Splitter.on(',').trimResults().splitToList(line);
  checkArgument(parts.size() == 2, "Could not parse line in premium list: %s", originalLine);
  return new PremiumListEntry.Builder()
      .setLabel(parts.get(0))
      .setPrice(Money.parse(parts.get(1)))
      .setComment(comment)
      .build();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:PremiumList.java

示例7: testGetPremiumPrice_cachedSecondTime

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testGetPremiumPrice_cachedSecondTime() throws Exception {
  assertThat(getPremiumPrice("rich", Registry.get("tld"))).hasValue(Money.parse("USD 1999"));
  assertThat(getPremiumPrice("rich", Registry.get("tld"))).hasValue(Money.parse("USD 1999"));
  assertThat(premiumListChecks)
      .hasValueForLabels(1, "tld", "tld", UNCACHED_POSITIVE.toString())
      .and()
      .hasValueForLabels(1, "tld", "tld", CACHED_POSITIVE.toString())
      .and()
      .hasNoOtherValues();
  assertThat(premiumListProcessingTime)
      .hasAnyValueForLabels("tld", "tld", UNCACHED_POSITIVE.toString())
      .and()
      .hasAnyValueForLabels("tld", "tld", CACHED_POSITIVE.toString())
      .and()
      .hasNoOtherValues();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:PremiumListUtilsTest.java

示例8: testSuccess_eapFee_beforeEntireSchedule

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testSuccess_eapFee_beforeEntireSchedule() throws Exception {
  persistContactsAndHosts();
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setEapFeeSchedule(
              ImmutableSortedMap.of(
                  START_OF_TIME,
                  Money.of(USD, 0),
                  clock.nowUtc().plusDays(1),
                  Money.of(USD, 10),
                  clock.nowUtc().plusDays(2),
                  Money.of(USD, 0)))
          .build());
  doSuccessfulTest("tld", "domain_create_response.xml");
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainCreateFlowTest.java

示例9: testFailure_changeBillingMethodWhenBalanceIsNonZero

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testFailure_changeBillingMethodWhenBalanceIsNonZero() throws Exception {
  createTlds("xn--q9jyb4c");
  Registrar registrar = loadRegistrar("NewRegistrar");
  persistResource(
      new RegistrarBillingEntry.Builder()
          .setPrevious(null)
          .setParent(registrar)
          .setCreated(DateTime.parse("1984-12-18TZ"))
          .setDescription("USD Invoice for December")
          .setAmount(Money.parse("USD 10.00"))
          .build());
  assertThat(registrar.getBillingMethod()).isEqualTo(BillingMethod.EXTERNAL);
  IllegalStateException thrown =
      expectThrows(
          IllegalStateException.class,
          () -> runCommand("--billing_method=braintree", "--force", "NewRegistrar"));
  assertThat(thrown)
      .hasMessageThat()
      .isEqualTo(
          "Refusing to change billing method on Registrar 'NewRegistrar' from EXTERNAL to "
              + "BRAINTREE because current balance is non-zero: {USD=USD 10.00}");
}
 
开发者ID:google,项目名称:nomulus,代码行数:24,代码来源:UpdateRegistrarCommandTest.java

示例10: runWrongCurrencyTest

import org.joda.money.Money; //导入依赖的package包/类
private void runWrongCurrencyTest(Map<String, String> substitutions) throws Exception {
  setEppInput("domain_update_restore_request_fee.xml", substitutions);
  persistPendingDeleteDomain();
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:17,代码来源:DomainRestoreRequestFlowTest.java

示例11: testSuccess_nonUsdBillingCostFlag

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testSuccess_nonUsdBillingCostFlag() throws Exception {
  persistResource(
      Registry.get("xn--q9jyb4c")
          .asBuilder()
          .setCurrency(JPY)
          .setCreateBillingCost(Money.ofMajor(JPY, 1))
          .setRestoreBillingCost(Money.ofMajor(JPY, 1))
          .setRenewBillingCostTransitions(
              ImmutableSortedMap.of(START_OF_TIME, Money.ofMajor(JPY, 1)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(JPY)))
          .setServerStatusChangeBillingCost(Money.ofMajor(JPY, 1))
          .build());
  runCommandForced(
      "--create_billing_cost=\"JPY 12345\"",
      "--restore_billing_cost=\"JPY 67890\"",
      "--renew_billing_cost_transitions=\"0=JPY 101112\"",
      "--server_status_change_cost=\"JPY 97865\"",
      "xn--q9jyb4c");
  assertThat(Registry.get("xn--q9jyb4c").getStandardCreateCost())
      .isEqualTo(Money.ofMajor(JPY, 12345));
  assertThat(Registry.get("xn--q9jyb4c").getStandardRestoreCost())
      .isEqualTo(Money.ofMajor(JPY, 67890));
  assertThat(Registry.get("xn--q9jyb4c").getStandardRenewCost(START_OF_TIME))
      .isEqualTo(Money.ofMajor(JPY, 101112));
}
 
开发者ID:google,项目名称:nomulus,代码行数:27,代码来源:UpdateTldCommandTest.java

示例12: testSuccess_autoRenewGracePeriod_priceChanges_v11

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testSuccess_autoRenewGracePeriod_priceChanges_v11() throws Exception {
  removeServiceExtensionUri(ServiceExtension.FEE_0_12.getUri());
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setRenewBillingCostTransitions(
              ImmutableSortedMap.of(
                  START_OF_TIME,
                  Money.of(USD, 11),
                  TIME_BEFORE_FLOW.minusDays(5),
                  Money.of(USD, 20)))
          .build());
  setUpAutorenewGracePeriod();
  clock.advanceOneMilli();
  runFlowAssertResponse(loadFile("domain_delete_response_autorenew_fee.xml", FEE_11_MAP));
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainDeleteFlowTest.java

示例13: testFailure_wrongCurrency_v06

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v06() throws Exception {
  setEppInput("domain_renew_fee.xml", FEE_06_MAP);
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistDomain();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainRenewFlowTest.java

示例14: testFailure_wrongCurrency_v12

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v12() throws Exception {
  setEppInput("domain_renew_fee.xml", FEE_12_MAP);
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistDomain();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainRenewFlowTest.java

示例15: testFailure_wrongCurrency_v12

import org.joda.money.Money; //导入依赖的package包/类
@Test
public void testFailure_wrongCurrency_v12() throws Exception {
  setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.12"));
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCurrency(CurrencyUnit.EUR)
          .setCreateBillingCost(Money.of(EUR, 13))
          .setRestoreBillingCost(Money.of(EUR, 11))
          .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(EUR, 7)))
          .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(EUR)))
          .setServerStatusChangeBillingCost(Money.of(EUR, 19))
          .build());
  persistContactsAndHosts();
  EppException thrown = expectThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
开发者ID:google,项目名称:nomulus,代码行数:18,代码来源:DomainCreateFlowTest.java


注:本文中的org.joda.money.Money类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。