mirror of
https://github.com/google/nomulus
synced 2026-02-09 14:30:33 +00:00
Add method to show readable key info (#1431)
* Resolve conflict * Apply new printing method to existing command
This commit is contained in:
@@ -418,6 +418,32 @@ class VKeyTest {
|
||||
assertThat(VKey.create(vkeyStringFromQueue)).isEqualTo(vkey);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString_sqlOnlyVKey() {
|
||||
assertThat(VKey.createSql(TestObject.class, "testId").toString())
|
||||
.isEqualTo("VKey<TestObject>(sql:testId)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString_ofyOnlyVKey_withName() {
|
||||
assertThat(
|
||||
VKey.createOfy(TestObject.class, Key.create(TestObject.class, "testName")).toString())
|
||||
.isEqualTo("VKey<TestObject>(ofy:testName)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString_ofyOnlyVKey_withId() {
|
||||
assertThat(VKey.createOfy(TestObject.class, Key.create(TestObject.class, 12345)).toString())
|
||||
.isEqualTo("VKey<TestObject>(ofy:12345)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testToString_sqlAndOfyVKey() {
|
||||
assertThat(
|
||||
VKey.create(TestObject.class, "foo", Key.create(TestObject.create("ofy"))).toString())
|
||||
.isEqualTo("VKey<TestObject>(sql:foo,ofy:ofy)");
|
||||
}
|
||||
|
||||
@Entity
|
||||
static class OtherObject {}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKeyComman
|
||||
"agR0ZXN0chULEgpEb21haW5CYXNlIgU0LVRMRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(DomainBase(\"4-TLD\"))");
|
||||
.contains("Could not load resource for key: VKey<DomainBase>(sql:4-TLD,ofy:4-TLD)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +128,7 @@ class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKeyComman
|
||||
"agR0ZXN0chsLEg9Db250YWN0UmVzb3VyY2UiBjMtUk9JRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(ContactResource(\"3-ROID\"))");
|
||||
.contains("Could not load resource for key: VKey<ContactResource>(sql:3-ROID,ofy:3-ROID)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -177,7 +177,7 @@ class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKeyComman
|
||||
"agR0ZXN0chgLEgxIb3N0UmVzb3VyY2UiBjMtUk9JRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(HostResource(\"3-ROID\"))");
|
||||
.contains("Could not load resource for key: VKey<HostResource>(sql:3-ROID,ofy:3-ROID)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -210,7 +210,7 @@ class GetResourceByKeyCommandTest extends CommandTestCase<GetResourceByKeyComman
|
||||
() -> runCommand("agR0ZXN0chULEgpEb21haW5CYXNlIgUyLVRMRAw"));
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("Could not load resource for key: Key<?>(DomainBase(\"2-TLD\"))");
|
||||
.contains("Could not load resource for key: VKey<DomainBase>(sql:2-TLD,ofy:2-TLD)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -331,7 +331,9 @@ class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||
"--registrar=blobio",
|
||||
"--email=contact@email.com",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("Registry(\"blobio-sunrise\")");
|
||||
assertThat(thrown)
|
||||
.hasMessageThat()
|
||||
.contains("VKey<Registry>(sql:blobio-sunrise,ofy:blobio-sunrise)");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -367,7 +369,7 @@ class SetupOteCommandTest extends CommandTestCase<SetupOteCommand> {
|
||||
"--registrar=blobio",
|
||||
"--email=contact@email.com",
|
||||
"--certfile=" + getCertFilename()));
|
||||
assertThat(thrown).hasMessageThat().contains("Registrar(\"blobio-1\")");
|
||||
assertThat(thrown).hasMessageThat().contains("VKey<Registrar>(sql:blobio-1,ofy:blobio-1)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user