mirror of
https://github.com/google/nomulus.git
synced 2025-05-21 11:49:37 +02:00
Use an enum instead of boolean in EntityTestCase constructor (#669)
* Use an enum instead of boolean in EntityTestCase constructor It's more clear to use an enum rather than just a simple boolean * Add Javadoc and make the enum name more verbose
This commit is contained in:
parent
fac5987c13
commit
d17ec1fcb1
8 changed files with 20 additions and 10 deletions
|
@ -49,6 +49,16 @@ import org.junit.jupiter.api.extension.RegisterExtension;
|
|||
/** Base class of all unit tests for entities which are persisted to Datastore via Objectify. */
|
||||
public abstract class EntityTestCase {
|
||||
|
||||
protected enum JpaEntityCoverageCheck {
|
||||
/**
|
||||
* The test will contribute to the coverage checks in {@link
|
||||
* google.registry.schema.integration.SqlIntegrationTestSuite}.
|
||||
*/
|
||||
ENABLED,
|
||||
/** The test is not relevant for JPA coverage checks. */
|
||||
DISABLED;
|
||||
}
|
||||
|
||||
protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
|
||||
|
||||
@Rule @RegisterExtension public final AppEngineRule appEngine;
|
||||
|
@ -56,14 +66,14 @@ public abstract class EntityTestCase {
|
|||
@Rule @RegisterExtension public InjectRule inject = new InjectRule();
|
||||
|
||||
protected EntityTestCase() {
|
||||
this(false);
|
||||
this(JpaEntityCoverageCheck.DISABLED);
|
||||
}
|
||||
|
||||
protected EntityTestCase(boolean enableJpaEntityCheck) {
|
||||
protected EntityTestCase(JpaEntityCoverageCheck jpaEntityCoverageCheck) {
|
||||
appEngine =
|
||||
AppEngineRule.builder()
|
||||
.withDatastoreAndCloudSql()
|
||||
.enableJpaEntityCoverageCheck(enableJpaEntityCheck)
|
||||
.enableJpaEntityCoverageCheck(jpaEntityCoverageCheck == JpaEntityCoverageCheck.ENABLED)
|
||||
.withClock(fakeClock)
|
||||
.build();
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ public class BillingEventTest extends EntityTestCase {
|
|||
private final DateTime now = DateTime.now(UTC);
|
||||
|
||||
public BillingEventTest() {
|
||||
super(true);
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
HistoryEntry historyEntry;
|
||||
|
|
|
@ -49,7 +49,7 @@ public class ContactResourceTest extends EntityTestCase {
|
|||
ContactResource contactResource;
|
||||
|
||||
public ContactResourceTest() {
|
||||
super(true);
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
|
|||
public class ContactHistoryTest extends EntityTestCase {
|
||||
|
||||
public ContactHistoryTest() {
|
||||
super(true);
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
|
|||
public class HostHistoryTest extends EntityTestCase {
|
||||
|
||||
public HostHistoryTest() {
|
||||
super(true);
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -39,7 +39,7 @@ public class PollMessageTest extends EntityTestCase {
|
|||
PollMessage.Autorenew autoRenew;
|
||||
|
||||
public PollMessageTest() {
|
||||
super(true);
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
|
|
@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test;
|
|||
public final class RegistryLockDaoTest extends EntityTestCase {
|
||||
|
||||
public RegistryLockDaoTest() {
|
||||
super(true);
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -47,7 +47,7 @@ public class Spec11ThreatMatchTest extends EntityTestCase {
|
|||
private ContactResource registrantContact;
|
||||
|
||||
public Spec11ThreatMatchTest() {
|
||||
super(true);
|
||||
super(JpaEntityCoverageCheck.ENABLED);
|
||||
}
|
||||
|
||||
@BeforeEach
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue