Clarify diff display of MutatingCommand

Tools inheriting from MutatingCommand print out the change they are going to
make and then ask the user to confirm that this is indeed what they wanted to
do.

The change is outputted as a list of updated values in the form

key -> [oldValue, newValue]

e.g.

dnsPaused -> [true, false]

This CL will change the output to be clearer:

key: oldValue -> newValue

e.g.

dnsPaused: true -> false

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170853745
This commit is contained in:
guyben 2017-10-03 07:41:02 -07:00 committed by Ben McIlwain
parent fd62f4a74e
commit 01591ff88e
8 changed files with 30 additions and 31 deletions

View file

@ -99,16 +99,16 @@ public class MutatingCommandTest {
String changes = command.prompt();
assertThat(changes).isEqualTo(
"Update HostResource@2-ROID\n"
+ "lastEppUpdateTime -> [null, 2014-09-09T09:09:09.000Z]\n"
+ "lastEppUpdateTime: null -> 2014-09-09T09:09:09.000Z\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Update Registrar@Registrar1\n"
+ "billingIdentifier -> [null, 42]\n"
+ "billingIdentifier: null -> 42\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames -> [false, true]\n");
+ "blockPremiumNames: false -> true\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(ofy().load().entity(host1).now()).isEqualTo(newHost1);
@ -229,13 +229,13 @@ public class MutatingCommandTest {
+ host1 + "\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames -> [false, true]\n");
+ "blockPremiumNames: false -> true\n");
String results = command.execute();
assertThat(results).isEqualTo("Updated 4 entities.\n");
assertThat(ofy().load().entity(host1).now()).isNull();
@ -269,13 +269,13 @@ public class MutatingCommandTest {
+ host1 + "\n"
+ "\n"
+ "Update HostResource@3-ROID\n"
+ "currentSponsorClientId -> [TheRegistrar, Registrar2]\n"
+ "currentSponsorClientId: TheRegistrar -> Registrar2\n"
+ "\n"
+ "Delete Registrar@Registrar1\n"
+ registrar1 + "\n"
+ "\n"
+ "Update Registrar@Registrar2\n"
+ "blockPremiumNames -> [false, true]\n");
+ "blockPremiumNames: false -> true\n");
try {
command.execute();
assertWithMessage("Expected transaction to fail with IllegalStateException").fail();