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. */
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();
}

View file

@ -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;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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