Skip to content

Commit cc20f7d

Browse files
authored
Add a simple toString for TimedTransitionProperty (#2604)
this means that we can actually see the transitions when running GetAllocationTokenCommand, for instance
1 parent 5603b91 commit cc20f7d

File tree

2 files changed

+49
-1
lines changed

2 files changed

+49
-1
lines changed

core/src/main/java/google/registry/model/common/TimedTransitionProperty.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,4 +185,9 @@ public boolean equals(@CheckForNull Object object) {
185185
public int hashCode() {
186186
return this.backingMap.hashCode();
187187
}
188+
189+
@Override
190+
public String toString() {
191+
return this.backingMap.toString();
192+
}
188193
}

core/src/test/java/google/registry/tools/GetAllocationTokenCommandTest.java

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,12 @@
2525

2626
import com.beust.jcommander.ParameterException;
2727
import com.google.common.collect.ImmutableList;
28+
import com.google.common.collect.ImmutableSet;
29+
import com.google.common.collect.ImmutableSortedMap;
2830
import google.registry.model.domain.Domain;
31+
import google.registry.model.domain.fee.FeeQueryCommandExtensionItem;
2932
import google.registry.model.domain.token.AllocationToken;
33+
import google.registry.util.DateTimeUtils;
3034
import org.joda.time.DateTime;
3135
import org.junit.jupiter.api.Test;
3236

@@ -41,10 +45,49 @@ void testSuccess_oneToken() throws Exception {
4145
new AllocationToken.Builder()
4246
.setToken("foo")
4347
.setTokenType(SINGLE_USE)
48+
.setAllowedEppActions(
49+
ImmutableSet.of(FeeQueryCommandExtensionItem.CommandName.CREATE))
50+
.setAllowedRegistrarIds(ImmutableSet.of("TheRegistrar"))
51+
.setAllowedTlds(ImmutableSet.of("bar"))
52+
.setDiscountFraction(0.5)
53+
.setDiscountYears(2)
54+
.setTokenStatusTransitions(
55+
ImmutableSortedMap.of(
56+
DateTimeUtils.START_OF_TIME,
57+
AllocationToken.TokenStatus.NOT_STARTED,
58+
fakeClock.nowUtc(),
59+
AllocationToken.TokenStatus.VALID))
4460
.setDomainName("foo.bar")
4561
.build());
4662
runCommand("foo");
47-
assertInStdout(token.toString(), "Token foo was not redeemed.");
63+
assertStdoutIs(
64+
"""
65+
AllocationToken: {
66+
allowedClientIds=[TheRegistrar]
67+
allowedEppActions=[CREATE]
68+
allowedTlds=[bar]
69+
creationTime=CreateAutoTimestamp: {
70+
creationTime=2022-09-01T00:00:00.000Z
71+
}
72+
discountFraction=0.5
73+
discountPremiums=false
74+
discountPrice=null
75+
discountYears=2
76+
domainName=foo.bar
77+
redemptionHistoryId=null
78+
registrationBehavior=DEFAULT
79+
renewalPrice=null
80+
renewalPriceBehavior=DEFAULT
81+
token=foo
82+
tokenStatusTransitions={1970-01-01T00:00:00.000Z=NOT_STARTED, 2022-09-01T00:00:00.000Z=VALID}
83+
tokenType=SINGLE_USE
84+
updateTimestamp=UpdateAutoTimestamp: {
85+
lastUpdateTime=2022-09-01T00:00:00.000Z
86+
}
87+
}
88+
Token foo was not redeemed.
89+
90+
""");
4891
}
4992

5093
@Test

0 commit comments

Comments
 (0)