From a81d45fe5d7c8bdbc75bcaae334fd468c9d5662d Mon Sep 17 00:00:00 2001 From: mcilwain Date: Thu, 3 Jan 2019 16:21:39 -0800 Subject: [PATCH] Fix stdout of DeleteAllocationTokensCommand It was saying it was deleting tokens it wasn't, because it was outputting the raw input list of tokens rather than the list that filtered out redeemed or domain-specific tokens. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=227769266 --- .../registry/tools/DeleteAllocationTokensCommand.java | 6 +++++- .../registry/tools/DeleteAllocationTokensCommandTest.java | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/java/google/registry/tools/DeleteAllocationTokensCommand.java b/java/google/registry/tools/DeleteAllocationTokensCommand.java index aaf02f7f1..f252616f6 100644 --- a/java/google/registry/tools/DeleteAllocationTokensCommand.java +++ b/java/google/registry/tools/DeleteAllocationTokensCommand.java @@ -101,7 +101,11 @@ final class DeleteAllocationTokensCommand extends ConfirmingCommand System.out.printf( "%s tokens: %s\n", dryRun ? "Would delete" : "Deleted", - JOINER.join(batch.stream().map(Key::getName).collect(toImmutableSet()))); + JOINER.join( + tokensToDelete.stream() + .map(AllocationToken::getToken) + .sorted() + .collect(toImmutableSet()))); return tokensToDelete.size(); } } diff --git a/javatests/google/registry/tools/DeleteAllocationTokensCommandTest.java b/javatests/google/registry/tools/DeleteAllocationTokensCommandTest.java index 0ce485f23..ed2a71a14 100644 --- a/javatests/google/registry/tools/DeleteAllocationTokensCommandTest.java +++ b/javatests/google/registry/tools/DeleteAllocationTokensCommandTest.java @@ -54,6 +54,7 @@ public class DeleteAllocationTokensCommandTest runCommandForced("--prefix", ""); assertThat(reloadTokens(preNot1, preNot2, othrNot)).isEmpty(); assertThat(reloadTokens(preRed1, preRed2, othrRed)).containsExactly(preRed1, preRed2, othrRed); + assertInStdout("Deleted tokens: asdgfho7HASDS, prefix2978204, prefix8ZZZhs8"); } @Test @@ -84,6 +85,7 @@ public class DeleteAllocationTokensCommandTest runCommandForced("--prefix", "", "--dry_run"); assertThat(reloadTokens(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot)) .containsExactly(preRed1, preRed2, preNot1, preNot2, othrRed, othrNot); + assertInStdout("Would delete tokens: asdgfho7HASDS, prefix2978204, prefix8ZZZhs8"); } @Test