Change lrpTldStates to Interval

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=135957698
This commit is contained in:
ctingue 2016-10-12 13:51:28 -07:00 committed by Ben McIlwain
parent edbb8985e6
commit 4e0b6d36c4
13 changed files with 232 additions and 131 deletions

View file

@ -39,6 +39,7 @@ import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import org.joda.money.Money;
import org.joda.time.DateTime;
import org.joda.time.Interval;
import org.junit.Before;
import org.junit.Test;
@ -405,6 +406,17 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
.containsExactly("ns2.example.com");
}
@Test
public void testSuccess_removeLrpPeriod() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setLrpPeriod(new Interval(
DateTime.parse("2004-06-09T12:30:00Z"), DateTime.parse("2004-07-10T13:30:00Z")))
.build());
runCommandForced("--lrp_period=null", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLrpPeriod()).isNull();
}
@Test
public void testFailure_invalidAddGracePeriod() throws Exception {
thrown.expect(IllegalArgumentException.class);
@ -815,65 +827,25 @@ public class UpdateTldCommandTest extends CommandTestCase<UpdateTldCommand> {
}
@Test
public void testSuccess_updateLrpTldState() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setTldStateTransitions(
ImmutableSortedMap.of(
START_OF_TIME, TldState.PREDELEGATION,
now.minusMonths(2), TldState.SUNRISE,
now.minusMonths(1), TldState.LANDRUSH,
now, TldState.GENERAL_AVAILABILITY))
.setLrpTldStates(ImmutableSet.of(TldState.SUNRISE))
.build());
runCommandForced("--lrp_tld_states=LANDRUSH", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLrpTldStates()).containsExactly(TldState.LANDRUSH);
public void testSuccess_updateLrpPeriod() throws Exception {
runCommandForced("--lrp_period=2004-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLrpPeriod()).isEqualTo(
new Interval(
DateTime.parse("2004-06-09T12:30:00Z"), DateTime.parse("2004-07-10T13:30:00Z")));
}
@Test
public void testSuccess_updateMultipleLrpTldStates() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setTldStateTransitions(
ImmutableSortedMap.of(
START_OF_TIME, TldState.PREDELEGATION,
now.minusMonths(2), TldState.SUNRISE,
now.minusMonths(1), TldState.LANDRUSH,
now, TldState.GENERAL_AVAILABILITY))
.setLrpTldStates(ImmutableSet.<TldState>of())
.build());
runCommandForced("--lrp_tld_states=SUNRISE,LANDRUSH", "xn--q9jyb4c");
assertThat(Registry.get("xn--q9jyb4c").getLrpTldStates())
.containsExactly(TldState.LANDRUSH, TldState.SUNRISE);
}
@Test
public void testFailure_updateLrpTldStates_notInTransitions() throws Exception {
persistResource(
Registry.get("xn--q9jyb4c").asBuilder()
.setTldStateTransitions(
ImmutableSortedMap.of(
START_OF_TIME, TldState.PREDELEGATION,
now.minusMonths(2), TldState.SUNRISE,
now, TldState.GENERAL_AVAILABILITY))
.setLrpTldStates(ImmutableSet.of(TldState.SUNRISE))
.build());
public void testFailure_updateLrpPeriod_backwardsInterval() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"Cannot specify an LRP TLD state that is not part of the TLD state transitions.");
runCommandForced("--lrp_tld_states=LANDRUSH", "xn--q9jyb4c");
ParameterException.class,
"--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z not an ISO-8601 interval");
runCommandForced("--lrp_period=2005-06-09T12:30:00Z/2004-07-10T13:30:00Z", "xn--q9jyb4c");
}
@Test
public void testFailure_updateLrpTldStates_badTldState() throws Exception {
thrown.expect(
IllegalArgumentException.class,
"No enum constant google.registry.model.registry.Registry.TldState.LOUD_PERIOD");
runCommandForced(
"--lrp_tld_states=LOUD_PERIOD",
"--initial_tld_state=PREDELEGATION",
"--roid_suffix=Q9JYB4C",
"xn--q9jyb4c");
public void testFailure_updateLrpPeriod_badInterval() throws Exception {
thrown.expect(ParameterException.class, "--lrp_period=foobar not an ISO-8601 interval");
runCommandForced("--lrp_period=foobar", "xn--q9jyb4c");
}
private void runSuccessfulReservedListsTest(String reservedLists) throws Exception {