mirror of
https://github.com/google/nomulus.git
synced 2025-07-21 10:16:07 +02:00
Remove VKeyTranslatorFactory.createVKey(String) (#1312)
* Remove VKeyTranslatorFactory.createVKey(String) This method serves the same function as VKey.fromWebsafeKey(), and isn't used anywhere. Move the test for it into VKeyTest and use it to instead test fromWebsafeKey() (which didn't previously have a test).
This commit is contained in:
parent
476e85c338
commit
0909a1d6d4
3 changed files with 16 additions and 17 deletions
|
@ -92,11 +92,6 @@ public class VKeyTranslatorFactory extends AbstractSimpleTranslatorFactory<VKey,
|
|||
}
|
||||
}
|
||||
|
||||
/** Create a VKey from a URL-safe string representation. */
|
||||
public static VKey<?> createVKey(String urlSafe) {
|
||||
return createVKey(com.googlecode.objectify.Key.create(urlSafe));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public static void addTestEntityClass(Class<?> clazz) {
|
||||
CLASS_REGISTRY.put(com.googlecode.objectify.Key.getKind(clazz), clazz);
|
||||
|
|
|
@ -88,18 +88,6 @@ public class VKeyTranslatorFactoryTest {
|
|||
assertThat(vkey.getSqlKey()).isEqualTo(200L);
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUrlSafeKey() {
|
||||
// Creating an objectify key instead of a datastore key as this should get a correctly formatted
|
||||
// key path.
|
||||
DomainBase domain = newDomainBase("example.com", "ROID-1", persistActiveContact("contact-1"));
|
||||
Key<DomainBase> key = Key.create(domain);
|
||||
VKey<DomainBase> vkey = (VKey<DomainBase>) VKeyTranslatorFactory.createVKey(key.getString());
|
||||
assertThat(vkey.getKind()).isEqualTo(DomainBase.class);
|
||||
assertThat(vkey.getOfyKey()).isEqualTo(key);
|
||||
assertThat(vkey.getSqlKey()).isEqualTo("ROID-1");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testExtraEntityClass() {
|
||||
TestObject testObject = TestObject.create("id", "field");
|
||||
|
|
|
@ -15,11 +15,14 @@ package google.registry.persistence;
|
|||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.common.truth.Truth8.assertThat;
|
||||
import static google.registry.testing.DatabaseHelper.newDomainBase;
|
||||
import static google.registry.testing.DatabaseHelper.persistActiveContact;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import google.registry.model.billing.BillingEvent.OneTime;
|
||||
import google.registry.model.domain.DomainBase;
|
||||
import google.registry.model.registrar.RegistrarContact;
|
||||
import google.registry.testing.AppEngineExtension;
|
||||
import google.registry.testing.TestObject;
|
||||
|
@ -114,6 +117,19 @@ class VKeyTest {
|
|||
.contains("Missing value for last key of type class google.registry.testing.TestObject");
|
||||
}
|
||||
|
||||
@Test
|
||||
void testFromWebsafeKey() {
|
||||
// Creating an objectify key instead of a datastore key as this should get a correctly formatted
|
||||
// key path. We have to one of our actual model object classes for this, TestObject can not be
|
||||
// reconstructed by the VKeyTranslatorFactory.
|
||||
DomainBase domain = newDomainBase("example.com", "ROID-1", persistActiveContact("contact-1"));
|
||||
Key<DomainBase> key = Key.create(domain);
|
||||
VKey<DomainBase> vkey = VKey.fromWebsafeKey(key.getString());
|
||||
assertThat(vkey.getKind()).isEqualTo(DomainBase.class);
|
||||
assertThat(vkey.getOfyKey()).isEqualTo(key);
|
||||
assertThat(vkey.getSqlKey()).isEqualTo("ROID-1");
|
||||
}
|
||||
|
||||
@Entity
|
||||
static class OtherObject {}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue