1
0
mirror of https://github.com/google/nomulus synced 2026-02-07 21:41:03 +00:00

Remove references to Objectify (#1846)

This is not a complete removal of ofy as we still a dependency on it
(GaeUserIdConverter). But this PR removed it from a lot of places where
it's no longer needed.
This commit is contained in:
Lai Jiang
2022-11-09 11:31:00 -05:00
committed by GitHub
parent 9546408a3a
commit d2b9ebafc8
53 changed files with 82 additions and 921 deletions

View File

@@ -21,7 +21,7 @@ import google.registry.testing.FakeClock;
import org.joda.time.DateTime;
import org.junit.jupiter.api.extension.RegisterExtension;
/** Base class of all unit tests for entities which are persisted to Datastore via Objectify. */
/** Base class of all unit tests for entities which are persisted to SQL. */
public abstract class EntityTestCase {
protected enum JpaEntityCoverageCheck {

View File

@@ -17,7 +17,6 @@ package google.registry.model;
import static com.google.common.truth.Truth.assertThat;
import com.google.common.collect.ImmutableMap;
import com.googlecode.objectify.annotation.Id;
import google.registry.testing.AppEngineExtension;
import java.lang.reflect.Field;
import java.util.Map;
@@ -34,14 +33,13 @@ public class ModelUtilsTest {
/** Test class for reflection methods. */
public static class TestClass extends ImmutableObject implements Buildable {
@Id
String id;
String a;
String b;
/** Note that there is no getter for {@link #b}.*/
/** Note that there is no getter for {@link #b}. */
public String getId() {
return id;
}
@@ -50,7 +48,7 @@ public class ModelUtilsTest {
return a;
}
/** Builder for {@link TestClass}. Note that there is no setter for {@link #a}.*/
/** Builder for {@link TestClass}. Note that there is no setter for {@link #a}. */
public static class Builder extends Buildable.Builder<TestClass> {
protected Builder() {}
@@ -83,10 +81,11 @@ public class ModelUtilsTest {
@Test
void testGetAllFields() throws Exception {
Map<String, Field> expected = ImmutableMap.of(
"id", TestClass.class.getDeclaredField("id"),
"a", TestClass.class.getDeclaredField("a"),
"b", TestClass.class.getDeclaredField("b"));
Map<String, Field> expected =
ImmutableMap.of(
"id", TestClass.class.getDeclaredField("id"),
"a", TestClass.class.getDeclaredField("a"),
"b", TestClass.class.getDeclaredField("b"));
// More complicated version of isEqualTo() so that we check for ordering.
assertThat(ModelUtils.getAllFields(TestClass.class).entrySet())
.containsExactlyElementsIn(expected.entrySet())
@@ -127,7 +126,7 @@ public class ModelUtilsTest {
original.id = "foo";
TestClass cloned = original.asBuilder().setId("bar").build();
assertThat(cloned.hashCode()).isNotEqualTo(original.hashCode());
cloned.id = "foo"; // Violates immutability contract.
cloned.id = "foo"; // Violates immutability contract.
// The hashCode is now cached and is stale (but that's the expected behavior).
assertThat(cloned.hashCode()).isNotEqualTo(original.hashCode());
}

View File

@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package google.registry.model.translators;
package google.registry.model.adapters;
import static com.google.common.truth.Truth.assertThat;
import static google.registry.util.DateTimeUtils.START_OF_TIME;

View File

@@ -888,9 +888,7 @@ public class DomainTest {
@Test
void testHistoryIdRestoration() {
// Verify that history ids for billing events are restored during load from datastore. History
// ids are not used by business code or persisted in datastore, but only to reconstruct
// objectify keys when loading from SQL.
// Verify that history ids for billing events are restored during load.
DateTime now = fakeClock.nowUtc();
domain =
persistResource(

View File

@@ -20,15 +20,14 @@ import static google.registry.persistence.transaction.QueryComposer.Comparator;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static org.junit.Assert.assertThrows;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
import google.registry.model.ImmutableObject;
import google.registry.testing.AppEngineExtension;
import google.registry.persistence.transaction.JpaTestExtensions.JpaUnitTestExtension;
import google.registry.testing.DatabaseHelper;
import google.registry.testing.FakeClock;
import java.util.Optional;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NoResultException;
import javax.persistence.NonUniqueResultException;
import org.junit.jupiter.api.BeforeEach;
@@ -44,13 +43,11 @@ public class QueryComposerTest {
TestEntity charlie = new TestEntity("charlie", 1);
@RegisterExtension
public final AppEngineExtension appEngine =
AppEngineExtension.builder()
public final JpaUnitTestExtension jpa =
new JpaTestExtensions.Builder()
.withClock(fakeClock)
.withCloudSql()
.withOfyTestEntities(TestEntity.class)
.withJpaUnitTestEntities(TestEntity.class)
.build();
.withEntityClass(TestEntity.class)
.buildUnitTestExtension();
public QueryComposerTest() {}
@@ -319,12 +316,10 @@ public class QueryComposerTest {
.isEmpty();
}
@javax.persistence.Entity
@Entity(name = "QueryComposerTestEntity")
@Entity
private static class TestEntity extends ImmutableObject {
@javax.persistence.Id @Id private String name;
@Id private String name;
@Index
// Renaming this implicitly verifies that property names work for hibernate queries.
@Column(name = "some_value")
private int val;

View File

@@ -1125,7 +1125,7 @@ public final class DatabaseHelper {
.build());
}
/** Persists a single Objectify resource, without adjusting foreign resources or keys. */
/** Persists a single resource, without adjusting foreign resources or keys. */
public static <R> R persistSimpleResource(final R resource) {
return persistSimpleResources(ImmutableList.of(resource)).get(0);
}