mirror of
https://github.com/google/nomulus.git
synced 2025-04-29 19:47:51 +02:00
Remove duplicate info from create/update reserved list command output (#2020)
It was repeating the domain label twice for every reserved list entry. It used to look like this: baddies=baddies,FULLY_BLOCKED
This commit is contained in:
parent
cbffc454b5
commit
d638c18ffd
5 changed files with 21 additions and 20 deletions
|
@ -20,6 +20,7 @@ import google.registry.model.tld.label.ReservedList;
|
|||
import google.registry.model.tld.label.ReservedListDao;
|
||||
import google.registry.tools.params.PathParameter;
|
||||
import java.nio.file.Path;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
/**
|
||||
|
@ -69,4 +70,12 @@ public abstract class CreateOrUpdateReservedListCommand extends ConfirmingComman
|
|||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
String outputReservedListEntries(ReservedList rl) {
|
||||
return "["
|
||||
+ rl.getReservedListEntries().values().stream()
|
||||
.map(rle -> String.format("(%s)", rle.toString()))
|
||||
.collect(Collectors.joining(", "))
|
||||
+ "]";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@ import com.google.common.base.Strings;
|
|||
import google.registry.model.tld.label.ReservedList;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import org.joda.time.DateTime;
|
||||
|
||||
/** Command to create a {@link ReservedList}. */
|
||||
|
@ -64,11 +63,8 @@ final class CreateReservedListCommand extends CreateOrUpdateReservedListCommand
|
|||
.setCreationTimestamp(now)
|
||||
.build();
|
||||
|
||||
String entries =
|
||||
reservedList.getReservedListEntries().entrySet().stream()
|
||||
.map(entry -> String.format("%s=%s", entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.joining(", "));
|
||||
return String.format("%s\nreservedListMap={%s}\n", reservedList, entries);
|
||||
return String.format(
|
||||
"%s\nreservedListMap=%s\n", reservedList, outputReservedListEntries(reservedList));
|
||||
}
|
||||
|
||||
private static void validateListName(String name) {
|
||||
|
|
|
@ -22,7 +22,6 @@ import com.google.common.base.Strings;
|
|||
import google.registry.model.tld.label.ReservedList;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/** Command to safely update {@link ReservedList}. */
|
||||
@Parameters(separators = " =", commandDescription = "Update a ReservedList.")
|
||||
|
@ -52,17 +51,11 @@ final class UpdateReservedListCommand extends CreateOrUpdateReservedListCommand
|
|||
if (!existingReservedList
|
||||
.getReservedListEntries()
|
||||
.equals(reservedList.getReservedListEntries())) {
|
||||
String oldEntries =
|
||||
existingReservedList.getReservedListEntries().entrySet().stream()
|
||||
.map(entry -> String.format("%s=%s", entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.joining(", "));
|
||||
String newEntries =
|
||||
reservedList.getReservedListEntries().entrySet().stream()
|
||||
.map(entry -> String.format("%s=%s", entry.getKey(), entry.getValue()))
|
||||
.collect(Collectors.joining(", "));
|
||||
return String.format(
|
||||
"Update reserved list for %s?\nOld List: %s\n New List: %s",
|
||||
name, oldEntries, newEntries);
|
||||
"Update reserved list for %s?\nOld list: %s\n New list: %s",
|
||||
name,
|
||||
outputReservedListEntries(existingReservedList),
|
||||
outputReservedListEntries(reservedList));
|
||||
}
|
||||
return "No entity changes to apply.";
|
||||
}
|
||||
|
|
|
@ -190,8 +190,8 @@ class CreateReservedListCommandTest
|
|||
command.init();
|
||||
assertThat(command.prompt())
|
||||
.contains(
|
||||
"reservedListMap={baddies=baddies,FULLY_BLOCKED, "
|
||||
+ "ford=ford,FULLY_BLOCKED # random comment}");
|
||||
"reservedListMap=[(baddies,FULLY_BLOCKED), "
|
||||
+ "(ford,FULLY_BLOCKED # random comment)]");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -201,6 +201,6 @@ class CreateReservedListCommandTest
|
|||
CreateReservedListCommand command = new CreateReservedListCommand();
|
||||
command.input = tmpPath;
|
||||
command.init();
|
||||
assertThat(command.prompt()).contains("reservedListMap={}");
|
||||
assertThat(command.prompt()).contains("reservedListMap=[]");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -130,5 +130,8 @@ class UpdateReservedListCommandTest
|
|||
command.init();
|
||||
|
||||
assertThat(command.prompt()).contains("Update reserved list for xn--q9jyb4c_common-reserved?");
|
||||
assertThat(command.prompt()).contains("Old list: [(helicopter,FULLY_BLOCKED)]");
|
||||
assertThat(command.prompt())
|
||||
.contains("New list: [(baddies,FULLY_BLOCKED), (ford,FULLY_BLOCKED # random comment)]");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue