org.joda.money.Money Java Examples

The following examples show how to use org.joda.money.Money. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DomainDeleteFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@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));
}
 
Example #2
Source File: UpdateTldCommandTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_renewBillingCostTransitions() throws Exception {
  DateTime later = now.plusMonths(1);
  runCommandForced(
      String.format(
          "--renew_billing_cost_transitions=\"%s=USD 1,%s=USD 2.00,%s=USD 100\"",
          START_OF_TIME,
          now,
          later),
      "xn--q9jyb4c");

  Registry registry = Registry.get("xn--q9jyb4c");
  assertThat(registry.getStandardRenewCost(START_OF_TIME)).isEqualTo(Money.of(USD, 1));
  assertThat(registry.getStandardRenewCost(now.minusMillis(1))).isEqualTo(Money.of(USD, 1));
  assertThat(registry.getStandardRenewCost(now)).isEqualTo(Money.of(USD, 2));
  assertThat(registry.getStandardRenewCost(now.plusMillis(1))).isEqualTo(Money.of(USD, 2));
  assertThat(registry.getStandardRenewCost(later.minusMillis(1))).isEqualTo(Money.of(USD, 2));
  assertThat(registry.getStandardRenewCost(later)).isEqualTo(Money.of(USD, 100));
  assertThat(registry.getStandardRenewCost(later.plusMillis(1))).isEqualTo(Money.of(USD, 100));
  assertThat(registry.getStandardRenewCost(END_OF_TIME)).isEqualTo(Money.of(USD, 100));
}
 
Example #3
Source File: DomainRenewFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@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 = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
Example #4
Source File: JodaMoneySerializerTest.java    From batchers with Apache License 2.0 6 votes vote down vote up
@Test
public void testMoneySerialization() throws IOException {
    JodaMoneySerializer jodaMoneySerializer = new JodaMoneySerializer();
    Money value = Money.of(CurrencyUnit.EUR, 234.56);
    jodaMoneySerializer.serialize(value, jsonGenerator, null);

    verify(jsonGenerator).writeString("234.56 €");
}
 
Example #5
Source File: DatastoreHelper.java    From nomulus with Apache License 2.0 6 votes vote down vote up
private static Registry setupRegistry(
    Registry.Builder registryBuilder,
    String tld,
    String roidSuffix,
    ImmutableSortedMap<DateTime, TldState> tldStates) {
  return registryBuilder
      .setTldStr(tld)
      .setRoidSuffix(roidSuffix)
      .setTldStateTransitions(tldStates)
      // Set billing costs to distinct small primes to avoid masking bugs in tests.
      .setRenewBillingCostTransitions(ImmutableSortedMap.of(START_OF_TIME, Money.of(USD, 11)))
      .setEapFeeSchedule(ImmutableSortedMap.of(START_OF_TIME, Money.zero(USD)))
      .setCreateBillingCost(Money.of(USD, 13))
      .setRestoreBillingCost(Money.of(USD, 17))
      .setServerStatusChangeBillingCost(Money.of(USD, 19))
      // Always set a default premium list. Tests that don't want it can delete it.
      .setPremiumList(persistPremiumList(tld, DEFAULT_PREMIUM_LIST_CONTENTS.get()))
      .setPremiumPricingEngine(StaticPremiumListPricingEngine.NAME)
      .setDnsWriters(ImmutableSet.of(VoidDnsWriter.NAME))
      .build();
}
 
Example #6
Source File: DomainCheckFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
private void runEapFeeCheckTest(String inputFile, String outputFile) throws Exception {
  clock.setTo(DateTime.parse("2010-01-01T10:00:00Z"));
  persistActiveDomain("example1.tld");
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setEapFeeSchedule(
              new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
                  .put(START_OF_TIME, Money.of(USD, 0))
                  .put(clock.nowUtc().minusDays(1), Money.of(USD, 100))
                  .put(clock.nowUtc().plusDays(1), Money.of(USD, 50))
                  .put(clock.nowUtc().plusDays(2), Money.of(USD, 0))
                  .build())
          .build());
  setEppInput(inputFile, ImmutableMap.of("CURRENCY", "USD"));
  runFlowAssertResponse(loadFile(outputFile));
}
 
Example #7
Source File: DomainTransferUtils.java    From nomulus with Apache License 2.0 6 votes vote down vote up
private static BillingEvent.OneTime createTransferBillingEvent(
    DateTime automaticTransferTime,
    HistoryEntry historyEntry,
    String targetId,
    String gainingClientId,
    Registry registry,
    Money transferCost) {
  return new BillingEvent.OneTime.Builder()
      .setReason(Reason.TRANSFER)
      .setTargetId(targetId)
      .setClientId(gainingClientId)
      .setCost(transferCost)
      .setPeriodYears(1)
      .setEventTime(automaticTransferTime)
      .setBillingTime(automaticTransferTime.plus(registry.getTransferGracePeriodLength()))
      .setParent(historyEntry)
      .build();
}
 
Example #8
Source File: Registry.java    From nomulus with Apache License 2.0 6 votes vote down vote up
/** Returns the EAP fee for the registry at the given time. */
public Fee getEapFeeFor(DateTime now) {
  ImmutableSortedMap<DateTime, Money> valueMap = getEapFeeScheduleAsMap();
  DateTime periodStart = valueMap.floorKey(now);
  DateTime periodEnd = valueMap.ceilingKey(now);
  // NOTE: assuming END_OF_TIME would never be reached...
  Range<DateTime> validPeriod =
      Range.closedOpen(
          periodStart != null ? periodStart : START_OF_TIME,
          periodEnd != null ? periodEnd : END_OF_TIME);
  return Fee.create(
      eapFeeSchedule.getValueAtTime(now).getAmount(),
      FeeType.EAP,
      // An EAP fee does not count as premium -- it's a separate one-time fee, independent of
      // which the domain is separately considered standard vs premium depending on renewal price.
      false,
      validPeriod,
      validPeriod.upperEndpoint());
}
 
Example #9
Source File: DomainUpdateFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
public void doServerStatusBillingTest(String xmlFilename, boolean isBillable) throws Exception {
  setEppInput(xmlFilename);
  clock.advanceOneMilli();
  runFlowAssertResponse(
      CommitMode.LIVE, UserPrivileges.SUPERUSER, loadFile("generic_success_response.xml"));

  if (isBillable) {
    assertBillingEvents(
        new BillingEvent.OneTime.Builder()
            .setReason(Reason.SERVER_STATUS)
            .setTargetId("example.tld")
            .setClientId("TheRegistrar")
            .setCost(Money.of(USD, 19))
            .setEventTime(clock.nowUtc())
            .setBillingTime(clock.nowUtc())
            .setParent(
                getOnlyHistoryEntryOfType(
                    reloadResourceByForeignKey(), HistoryEntry.Type.DOMAIN_UPDATE))
            .build());
  } else {
    assertNoBillingEvents();
  }
}
 
Example #10
Source File: DomainCreateFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@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", ImmutableMap.of("DOMAIN", "example.tld"));
}
 
Example #11
Source File: DomainRenewFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@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 = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
Example #12
Source File: DomainCreateFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_allocationTokenPromotion() throws Exception {
  // A discount of 0.5 means that the first-year cost (13) is cut in half, so a discount of 6.5
  // Note: we're asking to register it for two years so the total cost should be 13 + (13/2)
  persistContactsAndHosts();
  persistResource(
      new AllocationToken.Builder()
          .setToken("abc123")
          .setTokenType(TokenType.UNLIMITED_USE)
          .setDiscountFraction(0.5)
          .setTokenStatusTransitions(
              ImmutableSortedMap.<DateTime, TokenStatus>naturalOrder()
                  .put(START_OF_TIME, TokenStatus.NOT_STARTED)
                  .put(clock.nowUtc().plusMillis(1), TokenStatus.VALID)
                  .put(clock.nowUtc().plusSeconds(1), TokenStatus.ENDED)
                  .build())
          .build());
  clock.advanceOneMilli();
  setEppInput("domain_create_allocationtoken.xml", ImmutableMap.of("DOMAIN", "example.tld"));
  runFlowAssertResponse(
      loadFile("domain_create_response.xml", ImmutableMap.of("DOMAIN", "example.tld")));
  BillingEvent.OneTime billingEvent =
      Iterables.getOnlyElement(ofy().load().type(BillingEvent.OneTime.class));
  assertThat(billingEvent.getTargetId()).isEqualTo("example.tld");
  assertThat(billingEvent.getCost()).isEqualTo(Money.of(USD, BigDecimal.valueOf(19.5)));
}
 
Example #13
Source File: DomainRenewFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testFailure_wrongCurrency_v11() throws Exception {
  setEppInput("domain_renew_fee.xml", FEE_11_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 = assertThrows(CurrencyUnitMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
Example #14
Source File: PremiumListDaoTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void getPremiumPrice_worksSuccessfully() {
  persistResource(
      newRegistry("foobar", "FOOBAR")
          .asBuilder()
          .setPremiumListKey(
              Key.create(
                  getCrossTldKey(),
                  google.registry.model.registry.label.PremiumList.class,
                  "premlist"))
          .build());
  PremiumListDao.saveNew(PremiumList.create("premlist", USD, TEST_PRICES));
  assertThat(PremiumListDao.getPremiumPrice("silver", Registry.get("foobar")))
      .hasValue(Money.of(USD, 10.23));
  assertThat(PremiumListDao.getPremiumPrice("gold", Registry.get("foobar")))
      .hasValue(Money.of(USD, 1305.47));
  assertThat(PremiumListDao.getPremiumPrice("zirconium", Registry.get("foobar"))).isEmpty();
}
 
Example #15
Source File: DomainCreateFlowTest.java    From nomulus with Apache License 2.0 6 votes vote down vote up
@Test
public void testSuccess_premiumAndEap() throws Exception {
  createTld("example");
  setEppInput("domain_create_premium_eap.xml");
  persistContactsAndHosts("net");
  persistResource(
      Registry.get("example")
          .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(
      "example",
      "domain_create_response_premium_eap.xml",
      ImmutableMap.of("DOMAIN", "rich.example"));
}
 
Example #16
Source File: EmployeeTo.java    From batchers with Apache License 2.0 5 votes vote down vote up
public EmployeeTo(String firstName, String lastName, String email, Integer income, Money taxTotal, Long id, Long errorCount) {
  this.firstName = firstName;
  this.lastName = lastName;
  this.email = email;
  this.income = income;
  this.taxTotal = taxTotal;
  this.id = id;
  this.errorCount = errorCount;
}
 
Example #17
Source File: DomainBaseTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void testMultipleAutoRenews() {
  // Change the registry so that renewal costs change every year to make sure we are using the
  // autorenew time as the lookup time for the cost.
  DateTime oldExpirationTime = domain.getRegistrationExpirationTime();
  persistResource(
      Registry.get("com")
          .asBuilder()
          .setRenewBillingCostTransitions(
              new ImmutableSortedMap.Builder<DateTime, Money>(Ordering.natural())
                  .put(START_OF_TIME, Money.of(USD, 1))
                  .put(oldExpirationTime.plusMillis(1), Money.of(USD, 2))
                  .put(oldExpirationTime.plusYears(1).plusMillis(1), Money.of(USD, 3))
                  // Surround the third autorenew with price changes right before and after just
                  // to be 100% sure that we lookup the cost at the expiration time.
                  .put(oldExpirationTime.plusYears(2).minusMillis(1), Money.of(USD, 4))
                  .put(oldExpirationTime.plusYears(2).plusMillis(1), Money.of(USD, 5))
                  .build())
          .build());
  DomainBase renewedThreeTimes = domain.cloneProjectedAtTime(oldExpirationTime.plusYears(2));
  assertThat(renewedThreeTimes.getRegistrationExpirationTime())
      .isEqualTo(oldExpirationTime.plusYears(3));
  assertThat(renewedThreeTimes.getLastEppUpdateTime()).isEqualTo(oldExpirationTime.plusYears(2));
  assertThat(renewedThreeTimes.getGracePeriods())
      .containsExactly(
          GracePeriod.createForRecurring(
              GracePeriodStatus.AUTO_RENEW,
              oldExpirationTime
                  .plusYears(2)
                  .plus(Registry.get("com").getAutoRenewGracePeriodLength()),
              renewedThreeTimes.getCurrentSponsorClientId(),
              renewedThreeTimes.autorenewBillingEvent));
}
 
Example #18
Source File: DomainCreateFlowTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFailure_wrongFeeAmount_v06() {
  setEppInput("domain_create_fee.xml", ImmutableMap.of("FEE_VERSION", "0.6", "CURRENCY", "USD"));
  persistResource(
      Registry.get("tld").asBuilder().setCreateBillingCost(Money.of(USD, 20)).build());
  persistContactsAndHosts();
  EppException thrown = assertThrows(FeesMismatchException.class, this::runFlow);
  assertAboutEppExceptions().that(thrown).marshalsToXml();
}
 
Example #19
Source File: PremiumPricingEngine.java    From nomulus with Apache License 2.0 5 votes vote down vote up
static DomainPrices create(boolean isPremium, Money createCost, Money renewCost) {
  DomainPrices instance = new DomainPrices();
  instance.isPremium = isPremium;
  instance.createCost = createCost;
  instance.renewCost = renewCost;
  return instance;
}
 
Example #20
Source File: GracePeriodTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Before
public void before() {
  onetime = new BillingEvent.OneTime.Builder()
    .setEventTime(now)
    .setBillingTime(now.plusDays(1))
    .setClientId("TheRegistrar")
    .setCost(Money.of(CurrencyUnit.USD, 42))
    .setParent(Key.create(HistoryEntry.class, 12345))
    .setReason(Reason.CREATE)
    .setPeriodYears(1)
    .setTargetId("foo.google")
    .build();
}
 
Example #21
Source File: RegistryTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void testSettingRestoreBillingCost() {
  Registry registry =
      Registry.get("tld").asBuilder().setRestoreBillingCost(Money.of(USD, 42)).build();
  // The default value of 13 is set in createTld().
  assertThat(registry.getStandardCreateCost()).isEqualTo(Money.of(USD, 13));
  assertThat(registry.getStandardRestoreCost()).isEqualTo(Money.of(USD, 42));
}
 
Example #22
Source File: DomainRenewFlow.java    From nomulus with Apache License 2.0 5 votes vote down vote up
private OneTime createRenewBillingEvent(
    String tld, Money renewCost, int years, HistoryEntry historyEntry, DateTime now) {
  return new BillingEvent.OneTime.Builder()
      .setReason(Reason.RENEW)
      .setTargetId(targetId)
      .setClientId(clientId)
      .setPeriodYears(years)
      .setCost(renewCost)
      .setEventTime(now)
      .setBillingTime(now.plus(Registry.get(tld).getRenewGracePeriodLength()))
      .setParent(historyEntry)
      .build();
}
 
Example #23
Source File: DomainRenewFlowTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void testSuccess_recurringClientIdIsSame_whenSuperuserOverridesRenewal() throws Exception {
  persistDomain();
  setClientIdForFlow("NewRegistrar");
  doSuccessfulTest(
      "domain_renew_response.xml",
      5,
      "NewRegistrar",
      UserPrivileges.SUPERUSER,
      ImmutableMap.of("DOMAIN", "example.tld", "EXDATE", "2005-04-03T22:00:00.0Z"),
      Money.of(USD, 55));
}
 
Example #24
Source File: LongColumnMoneyMajorMapper.java    From jadira with Apache License 2.0 5 votes vote down vote up
@Override
public Long toNonNullValue(Money value) {
	if (!currencyUnit.equals(value.getCurrencyUnit())) {
		throw new IllegalStateException("Expected currency " + currencyUnit.getCurrencyCode() + " but was " + value.getCurrencyUnit());
	}
    return value.getAmountMajorLong();
}
 
Example #25
Source File: PremiumListTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
void testValidation_labelMustBePunyCoded() {
  Exception e =
      assertThrows(
          IllegalArgumentException.class,
          () ->
              new PremiumListEntry.Builder()
                  .setPrice(Money.parse("USD 399"))
                  .setLabel("lower.みんな")
                  .build());
  assertThat(e).hasMessageThat().contains("must be in puny-coded, lower-case form");
}
 
Example #26
Source File: TaxPaymentWebServiceTest.java    From batchers with Apache License 2.0 5 votes vote down vote up
@Test(expected = TaxWebServiceFatalException.class)
public void testProcess_ClientExceptionOccurs_TaxWebserviceFatalExceptionIsRethrown() throws Exception {
    whenCallingTheWebservice().thenThrow(aMethodNotAllowedException());

    Employee employee = new EmployeeTestBuilder().build();

    taxPaymentWebService.doWebserviceCallToTaxService(employee, Money.of(CurrencyUnit.EUR, 2000.0));
}
 
Example #27
Source File: PricingEngineProxyTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void test_getDomainCreateCost_multipleYears() {
  assertThat(getDomainCreateCost("espresso.moka", clock.nowUtc(), 1))
      .isEqualTo(Money.parse("USD 13"));
  assertThat(getDomainCreateCost("espresso.moka", clock.nowUtc(), 5))
      .isEqualTo(Money.parse("USD 65"));
  assertThat(getDomainCreateCost("fraction.moka", clock.nowUtc(), 1))
      .isEqualTo(Money.parse("USD 20.50"));
  assertThat(getDomainCreateCost("fraction.moka", clock.nowUtc(), 3))
      .isEqualTo(Money.parse("USD 61.50"));
}
 
Example #28
Source File: OteAccountBuilderTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateOteEntities_multipleContacts_success() {
  OteAccountBuilder.forClientId("myclientid")
      .addContact("[email protected]")
      .addContact("[email protected]")
      .addContact("[email protected]")
      .buildAndPersist();

  assertTldExists("myclientid-sunrise", START_DATE_SUNRISE, Money.zero(USD));
  assertTldExists("myclientid-ga", GENERAL_AVAILABILITY, Money.zero(USD));
  assertTldExists("myclientid-eap", GENERAL_AVAILABILITY, Money.of(USD, 100));
  assertRegistrarExists("myclientid-1", "myclientid-sunrise");
  assertRegistrarExists("myclientid-3", "myclientid-ga");
  assertRegistrarExists("myclientid-4", "myclientid-ga");
  assertRegistrarExists("myclientid-5", "myclientid-eap");
  assertContactExists("myclientid-1", "[email protected]");
  assertContactExists("myclientid-3", "[email protected]");
  assertContactExists("myclientid-4", "[email protected]");
  assertContactExists("myclientid-5", "[email protected]");
  assertContactExists("myclientid-1", "[email protected]");
  assertContactExists("myclientid-3", "[email protected]");
  assertContactExists("myclientid-4", "[email protected]");
  assertContactExists("myclientid-5", "[email protected]");
  assertContactExists("myclientid-1", "[email protected]");
  assertContactExists("myclientid-3", "[email protected]");
  assertContactExists("myclientid-4", "[email protected]");
  assertContactExists("myclientid-5", "[email protected]");
}
 
Example #29
Source File: DomainCheckFlowTest.java    From nomulus with Apache License 2.0 5 votes vote down vote up
@Test
public void testFeeExtension_fractionalCost() throws Exception {
  // Note that the response xml expects to see "11.10" with two digits after the decimal point.
  // This works because Money.getAmount(), used in the flow, returns a BigDecimal that is set to
  // display the number of digits that is conventional for the given currency.
  persistResource(
      Registry.get("tld")
          .asBuilder()
          .setCreateBillingCost(Money.of(CurrencyUnit.USD, 11.1))
          .build());
  setEppInput("domain_check_fee_fractional.xml");
  runFlowAssertResponse(loadFile("domain_check_fee_fractional_response.xml"));
}
 
Example #30
Source File: DomainDeleteFlow.java    From nomulus with Apache License 2.0 5 votes vote down vote up
private Money getGracePeriodCost(GracePeriod gracePeriod, DateTime now) {
  if (gracePeriod.getType() == GracePeriodStatus.AUTO_RENEW) {
    DateTime autoRenewTime =
        ofy().load().key(checkNotNull(gracePeriod.getRecurringBillingEvent())).now()
            .getRecurrenceTimeOfYear()
                .getLastInstanceBeforeOrAt(now);
    return getDomainRenewCost(targetId, autoRenewTime, 1);
  }
  return ofy().load().key(checkNotNull(gracePeriod.getOneTimeBillingEvent())).now().getCost();
}