mirror of
https://github.com/google/nomulus.git
synced 2025-07-24 11:38:35 +02:00
mv com/google/domain/registry google/registry
This change renames directories in preparation for the great package rename. The repository is now in a broken state because the code itself hasn't been updated. However this should ensure that git correctly preserves history for each file.
This commit is contained in:
parent
a41677aea1
commit
5012893c1d
2396 changed files with 0 additions and 0 deletions
115
javatests/google/registry/model/domain/GracePeriodTest.java
Normal file
115
javatests/google/registry/model/domain/GracePeriodTest.java
Normal file
|
@ -0,0 +1,115 @@
|
|||
// Copyright 2016 The Domain Registry Authors. All Rights Reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package com.google.domain.registry.model.domain;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.domain.registry.model.billing.BillingEvent;
|
||||
import com.google.domain.registry.model.billing.BillingEvent.Reason;
|
||||
import com.google.domain.registry.model.billing.BillingEvent.Recurring;
|
||||
import com.google.domain.registry.model.domain.rgp.GracePeriodStatus;
|
||||
import com.google.domain.registry.model.reporting.HistoryEntry;
|
||||
import com.google.domain.registry.testing.AppEngineRule;
|
||||
import com.google.domain.registry.testing.ExceptionRule;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.Ref;
|
||||
|
||||
import org.joda.money.CurrencyUnit;
|
||||
import org.joda.money.Money;
|
||||
import org.joda.time.DateTime;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.junit.runners.JUnit4;
|
||||
|
||||
/** Unit tests for {@link GracePeriod}. */
|
||||
@RunWith(JUnit4.class)
|
||||
public class GracePeriodTest {
|
||||
|
||||
@Rule
|
||||
public final AppEngineRule appEngine = AppEngineRule.builder()
|
||||
.withDatastore() // Needed to be able to construct Keys.
|
||||
.build();
|
||||
|
||||
@Rule
|
||||
public final ExceptionRule thrown = new ExceptionRule();
|
||||
|
||||
private final DateTime now = DateTime.now(UTC);
|
||||
private BillingEvent.OneTime onetime;
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_forBillingEvent() {
|
||||
GracePeriod gracePeriod = GracePeriod.forBillingEvent(GracePeriodStatus.ADD, onetime);
|
||||
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.ADD);
|
||||
assertThat(gracePeriod.getOneTimeBillingEvent()).isEqualTo(Ref.create(onetime));
|
||||
assertThat(gracePeriod.getRecurringBillingEvent()).isNull();
|
||||
assertThat(gracePeriod.getClientId()).isEqualTo("TheRegistrar");
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now.plusDays(1));
|
||||
assertThat(gracePeriod.isSunrushAddGracePeriod()).isFalse();
|
||||
assertThat(gracePeriod.hasBillingEvent()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_forBillingEvent_sunrushAdd() {
|
||||
GracePeriod gracePeriod = GracePeriod.forBillingEvent(GracePeriodStatus.SUNRUSH_ADD, onetime);
|
||||
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.ADD);
|
||||
assertThat(gracePeriod.isSunrushAddGracePeriod()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuccess_createWithoutBillingEvent() {
|
||||
GracePeriod gracePeriod = GracePeriod.createWithoutBillingEvent(
|
||||
GracePeriodStatus.REDEMPTION, now, "TheRegistrar");
|
||||
assertThat(gracePeriod.getType()).isEqualTo(GracePeriodStatus.REDEMPTION);
|
||||
assertThat(gracePeriod.getOneTimeBillingEvent()).isNull();
|
||||
assertThat(gracePeriod.getRecurringBillingEvent()).isNull();
|
||||
assertThat(gracePeriod.getClientId()).isEqualTo("TheRegistrar");
|
||||
assertThat(gracePeriod.getExpirationTime()).isEqualTo(now);
|
||||
assertThat(gracePeriod.hasBillingEvent()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_forBillingEvent_autoRenew() {
|
||||
thrown.expect(IllegalArgumentException.class, "autorenew");
|
||||
GracePeriod.forBillingEvent(GracePeriodStatus.AUTO_RENEW, onetime);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFailure_createForRecurring_notAutoRenew() {
|
||||
thrown.expect(IllegalArgumentException.class, "autorenew");
|
||||
GracePeriod.createForRecurring(
|
||||
GracePeriodStatus.RENEW,
|
||||
now.plusDays(1),
|
||||
"TheRegistrar",
|
||||
Ref.create(Key.create(Recurring.class, 12345)));
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue