mirror of
https://github.com/google/nomulus
synced 2026-06-06 06:52:56 +00:00
Add @VirtualEntity checking to Ofy's deleteWithoutBackup()
This was an oversight I noticed ages ago, so resurrecting some old local changes I had to correct it. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=146812322
This commit is contained in:
@@ -17,10 +17,12 @@ package google.registry.testing;
|
||||
import static google.registry.model.common.EntityGroupRoot.getCrossTldKey;
|
||||
|
||||
import com.googlecode.objectify.Key;
|
||||
import com.googlecode.objectify.ObjectifyService;
|
||||
import com.googlecode.objectify.annotation.Entity;
|
||||
import com.googlecode.objectify.annotation.Id;
|
||||
import com.googlecode.objectify.annotation.Parent;
|
||||
import google.registry.model.ImmutableObject;
|
||||
import google.registry.model.annotations.VirtualEntity;
|
||||
import google.registry.model.common.EntityGroupRoot;
|
||||
|
||||
/**
|
||||
@@ -28,6 +30,10 @@ import google.registry.model.common.EntityGroupRoot;
|
||||
*/
|
||||
@Entity
|
||||
public class TestObject extends ImmutableObject {
|
||||
static {
|
||||
ObjectifyService.register(TestObject.class); // Register this kind on first reference.
|
||||
}
|
||||
|
||||
@Parent
|
||||
Key<EntityGroupRoot> parent;
|
||||
|
||||
@@ -59,4 +65,30 @@ public class TestObject extends ImmutableObject {
|
||||
instance.parent = parent;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/** A test @VirtualEntity model object, which should not be persisted. */
|
||||
@Entity
|
||||
@VirtualEntity
|
||||
public static class TestVirtualObject extends ImmutableObject {
|
||||
static {
|
||||
ObjectifyService.register(TestVirtualObject.class); // Register this kind on first reference.
|
||||
}
|
||||
|
||||
@Id
|
||||
String id;
|
||||
|
||||
/**
|
||||
* Expose a factory method for testing saves of virtual entities; in real life this would never
|
||||
* be needed for an actual @VirtualEntity.
|
||||
*/
|
||||
public static TestVirtualObject create(String id) {
|
||||
TestVirtualObject instance = new TestVirtualObject();
|
||||
instance.id = id;
|
||||
return instance;
|
||||
}
|
||||
|
||||
public static Key<TestVirtualObject> createKey(String id) {
|
||||
return Key.create(TestVirtualObject.class, id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user