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:
gbrodman 2020-07-09 12:54:32 -04:00 committed by GitHub
parent fac5987c13
commit d17ec1fcb1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 20 additions and 10 deletions

View file

@ -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. */ /** Base class of all unit tests for entities which are persisted to Datastore via Objectify. */
public abstract class EntityTestCase { 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)); protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
@Rule @RegisterExtension public final AppEngineRule appEngine; @Rule @RegisterExtension public final AppEngineRule appEngine;
@ -56,14 +66,14 @@ public abstract class EntityTestCase {
@Rule @RegisterExtension public InjectRule inject = new InjectRule(); @Rule @RegisterExtension public InjectRule inject = new InjectRule();
protected EntityTestCase() { protected EntityTestCase() {
this(false); this(JpaEntityCoverageCheck.DISABLED);
} }
protected EntityTestCase(boolean enableJpaEntityCheck) { protected EntityTestCase(JpaEntityCoverageCheck jpaEntityCoverageCheck) {
appEngine = appEngine =
AppEngineRule.builder() AppEngineRule.builder()
.withDatastoreAndCloudSql() .withDatastoreAndCloudSql()
.enableJpaEntityCoverageCheck(enableJpaEntityCheck) .enableJpaEntityCoverageCheck(jpaEntityCoverageCheck == JpaEntityCoverageCheck.ENABLED)
.withClock(fakeClock) .withClock(fakeClock)
.build(); .build();
} }

View file

@ -51,7 +51,7 @@ public class BillingEventTest extends EntityTestCase {
private final DateTime now = DateTime.now(UTC); private final DateTime now = DateTime.now(UTC);
public BillingEventTest() { public BillingEventTest() {
super(true); super(JpaEntityCoverageCheck.ENABLED);
} }
HistoryEntry historyEntry; HistoryEntry historyEntry;

View file

@ -49,7 +49,7 @@ public class ContactResourceTest extends EntityTestCase {
ContactResource contactResource; ContactResource contactResource;
public ContactResourceTest() { public ContactResourceTest() {
super(true); super(JpaEntityCoverageCheck.ENABLED);
} }
@BeforeEach @BeforeEach

View file

@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
public class ContactHistoryTest extends EntityTestCase { public class ContactHistoryTest extends EntityTestCase {
public ContactHistoryTest() { public ContactHistoryTest() {
super(true); super(JpaEntityCoverageCheck.ENABLED);
} }
@Test @Test

View file

@ -32,7 +32,7 @@ import org.junit.jupiter.api.Test;
public class HostHistoryTest extends EntityTestCase { public class HostHistoryTest extends EntityTestCase {
public HostHistoryTest() { public HostHistoryTest() {
super(true); super(JpaEntityCoverageCheck.ENABLED);
} }
@Test @Test

View file

@ -39,7 +39,7 @@ public class PollMessageTest extends EntityTestCase {
PollMessage.Autorenew autoRenew; PollMessage.Autorenew autoRenew;
public PollMessageTest() { public PollMessageTest() {
super(true); super(JpaEntityCoverageCheck.ENABLED);
} }
@BeforeEach @BeforeEach

View file

@ -36,7 +36,7 @@ import org.junit.jupiter.api.Test;
public final class RegistryLockDaoTest extends EntityTestCase { public final class RegistryLockDaoTest extends EntityTestCase {
public RegistryLockDaoTest() { public RegistryLockDaoTest() {
super(true); super(JpaEntityCoverageCheck.ENABLED);
} }
@Test @Test

View file

@ -47,7 +47,7 @@ public class Spec11ThreatMatchTest extends EntityTestCase {
private ContactResource registrantContact; private ContactResource registrantContact;
public Spec11ThreatMatchTest() { public Spec11ThreatMatchTest() {
super(true); super(JpaEntityCoverageCheck.ENABLED);
} }
@BeforeEach @BeforeEach