Fix some low-hanging code quality issue fruits (#1047)

* Fix some low-hanging code quality issue fruits

These include problems such as: use of raw types, unnecessary throw clauses,
unused variables, and more.
This commit is contained in:
Ben McIlwain
2021-04-01 18:04:21 -04:00
committed by GitHub
parent dc51019fd2
commit 0164bceb95
79 changed files with 163 additions and 196 deletions
@@ -135,7 +135,7 @@ public class AsyncTaskEnqueuerTest {
@MockitoSettings(strictness = Strictness.LENIENT)
@Test
void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() throws Exception {
void test_enqueueAsyncResave_ignoresTasksTooFarIntoFuture() {
ContactResource contact = persistActiveContact("jd23456");
asyncTaskEnqueuer.enqueueAsyncResave(contact, clock.nowUtc(), clock.nowUtc().plusDays(31));
assertNoTasksEnqueued(QUEUE_ASYNC_ACTIONS);
@@ -476,7 +476,7 @@ public class DeleteContactsAndHostsActionTest
}
@Test
void testSuccess_targetResourcesDontExist_areDelayedForADay() throws Exception {
void testSuccess_targetResourcesDontExist_areDelayedForADay() {
ContactResource contactNotSaved = newContactResource("somecontact");
HostResource hostNotSaved = newHostResource("a11.blah.foo");
DateTime timeBeforeRun = clock.nowUtc();
@@ -515,7 +515,7 @@ public class DeleteContactsAndHostsActionTest
}
@Test
void testSuccess_unparseableTasks_areDelayedForADay() throws Exception {
void testSuccess_unparseableTasks_areDelayedForADay() {
TaskOptions task =
TaskOptions.Builder.withMethod(Method.PULL).param("gobbledygook", "kljhadfgsd9f7gsdfh");
getQueue(QUEUE_ASYNC_DELETE).add(task);
@@ -531,7 +531,7 @@ public class DeleteContactsAndHostsActionTest
}
@Test
void testSuccess_resourcesNotInPendingDelete_areSkipped() throws Exception {
void testSuccess_resourcesNotInPendingDelete_areSkipped() {
ContactResource contact = persistActiveContact("blah2222");
HostResource host = persistActiveHost("rustles.your.jimmies");
DateTime timeEnqueued = clock.nowUtc();
@@ -563,7 +563,7 @@ public class DeleteContactsAndHostsActionTest
}
@Test
void testSuccess_alreadyDeletedResources_areSkipped() throws Exception {
void testSuccess_alreadyDeletedResources_areSkipped() {
ContactResource contactDeleted = persistDeletedContact("blah1236", clock.nowUtc().minusDays(2));
HostResource hostDeleted = persistDeletedHost("a.lim.lop", clock.nowUtc().minusDays(3));
enqueuer.enqueueAsyncDelete(
@@ -191,7 +191,7 @@ public class RefreshDnsOnHostRenameActionTest
}
@Test
void testRun_hostDoesntExist_delaysTask() throws Exception {
void testRun_hostDoesntExist_delaysTask() {
HostResource host = newHostResource("ns1.example.tld");
enqueuer.enqueueAsyncDnsRefresh(host, clock.nowUtc());
enqueueMapreduceOnly();
@@ -222,7 +222,7 @@ public class RefreshDnsOnHostRenameActionTest
}
@Test
void test_noTasksToLease_releasesLockImmediately() throws Exception {
void test_noTasksToLease_releasesLockImmediately() {
enqueueMapreduceOnly();
assertNoDnsTasksEnqueued();
assertNoTasksEnqueued(QUEUE_ASYNC_HOST_RENAME);
@@ -141,8 +141,7 @@ public final class BackupTestStore implements AutoCloseable {
* to simulate an inconsistent export
* @return directory where data is exported
*/
File export(
String exportRootPath, Iterable<Class<?>> pojoTypes, Set<Key<? extends Object>> excludes)
File export(String exportRootPath, Iterable<Class<?>> pojoTypes, Set<Key<?>> excludes)
throws IOException {
File exportDirectory = getExportDirectory(exportRootPath);
for (Class<?> pojoType : pojoTypes) {
@@ -44,8 +44,6 @@ import java.io.File;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Set;
import java.util.stream.Stream;
import org.apache.beam.sdk.values.KV;
import org.joda.time.DateTime;
@@ -113,7 +111,7 @@ public class BackupTestStoreTest {
assertWithMessage("Directory %s should not exist.", exportFolder.getAbsoluteFile())
.that(exportFolder.exists())
.isFalse();
File actualExportFolder = export(exportRootPath, Collections.EMPTY_SET);
File actualExportFolder = export(exportRootPath, ImmutableSet.of());
assertThat(actualExportFolder).isEquivalentAccordingToCompareTo(exportFolder);
try (Stream<String> files =
Files.walk(exportFolder.toPath())
@@ -136,14 +134,14 @@ public class BackupTestStoreTest {
assertWithMessage("Directory %s should not exist.", exportFolder.getAbsoluteFile())
.that(exportFolder.exists())
.isFalse();
assertThat(export(exportRootPath, Collections.EMPTY_SET))
assertThat(export(exportRootPath, ImmutableSet.of()))
.isEquivalentAccordingToCompareTo(exportFolder);
}
@Test
void export_dataReadBack() throws IOException {
String exportRootPath = tempDir.getAbsolutePath();
File exportFolder = export(exportRootPath, Collections.EMPTY_SET);
File exportFolder = export(exportRootPath, ImmutableSet.of());
ImmutableList<Object> loadedRegistries =
loadExportedEntities(new File(exportFolder, "/all_namespaces/kind_Registry/output-0"));
assertThat(loadedRegistries).containsExactly(registry);
@@ -228,7 +226,7 @@ public class BackupTestStoreTest {
assertThat(CommitLogImports.loadEntities(commitLogFile)).isEmpty();
}
private File export(String exportRootPath, Set<Key<?>> excludes) throws IOException {
private File export(String exportRootPath, ImmutableSet<Key<?>> excludes) throws IOException {
return store.export(
exportRootPath,
ImmutableList.of(ContactResource.class, DomainBase.class, Registry.class),
@@ -220,7 +220,7 @@ public class EppTestCase {
return actualOutput;
}
private FakeResponse executeXmlCommand(String inputXml) throws Exception {
private FakeResponse executeXmlCommand(String inputXml) {
EppRequestHandler handler = new EppRequestHandler();
FakeResponse response = new FakeResponse();
handler.response = response;
@@ -200,7 +200,7 @@ class CertificateCheckerTest {
}
@Test
void test_checkCertificate_validCertificateString() throws Exception {
void test_checkCertificate_validCertificateString() {
fakeClock.setTo(DateTime.parse("2020-11-01T00:00:00Z"));
assertThat(certificateChecker.checkCertificate(SAMPLE_CERT3)).isEmpty();
assertThat(certificateChecker.checkCertificate(SAMPLE_CERT))
@@ -208,7 +208,7 @@ class CertificateCheckerTest {
}
@Test
void test_checkCertificate_invalidCertificateString() throws Exception {
void test_checkCertificate_invalidCertificateString() {
fakeClock.setTo(DateTime.parse("2020-11-01T00:00:00Z"));
IllegalArgumentException thrown =
assertThrows(
@@ -55,7 +55,7 @@ public abstract class EntityTestCase {
*/
ENABLED,
/** The test is not relevant for JPA coverage checks. */
DISABLED;
DISABLED
}
protected FakeClock fakeClock = new FakeClock(DateTime.now(UTC));
@@ -20,6 +20,7 @@ import static google.registry.model.ImmutableObjectSubject.immutableObjectCorres
import static google.registry.model.registry.Registry.TldState.GENERAL_AVAILABILITY;
import static google.registry.persistence.transaction.TransactionManagerFactory.jpaTm;
import static google.registry.persistence.transaction.TransactionManagerFactory.tm;
import static google.registry.testing.AppEngineExtension.makeRegistrar2;
import static google.registry.testing.DatabaseHelper.createTld;
import static google.registry.testing.DatabaseHelper.newContactResourceWithRoid;
import static google.registry.testing.DatabaseHelper.newDomainBase;
@@ -42,7 +43,6 @@ import google.registry.model.domain.rgp.GracePeriodStatus;
import google.registry.model.domain.secdns.DelegationSignerData;
import google.registry.model.eppcommon.Trid;
import google.registry.model.host.HostResource;
import google.registry.model.registrar.Registrar;
import google.registry.model.registry.Registries;
import google.registry.model.registry.Registry;
import google.registry.model.reporting.DomainTransactionRecord;
@@ -144,13 +144,9 @@ public class DomainHistoryTest extends EntityTestCase {
.transact(
() -> {
jpaTm().insert(registry);
Registrar registrar =
appEngine
.makeRegistrar2()
.asBuilder()
.setAllowedTlds(ImmutableSet.of("tld"))
.build();
jpaTm().insert(registrar);
jpaTm()
.insert(
makeRegistrar2().asBuilder().setAllowedTlds(ImmutableSet.of("tld")).build());
});
HostResource host = newHostResourceWithRoid("ns1.example.com", "host1");
@@ -54,7 +54,7 @@ import org.junit.jupiter.api.BeforeEach;
/** Unit tests for {@link Registry}. */
@DualDatabaseTest
public class RegistryTest extends EntityTestCase {
public final class RegistryTest extends EntityTestCase {
RegistryTest() {
super(JpaEntityCoverageCheck.ENABLED);
@@ -66,7 +66,7 @@ public class RegistryTest extends EntityTestCase {
}
@TestOfyAndSql
public void testPersistence_updateReservedAndPremiumListSuccessfully() {
void testPersistence_updateReservedAndPremiumListSuccessfully() {
ReservedList rl15 = persistReservedList("tld-reserved15", "potato,FULLY_BLOCKED");
PremiumList pl = persistPremiumList("tld2", "lol,USD 50", "cat,USD 700");
Registry registry =
@@ -38,7 +38,7 @@ import org.joda.time.DateTime;
import org.junit.jupiter.api.BeforeEach;
@DualDatabaseTest
public class HistoryEntryDaoTest extends EntityTestCase {
class HistoryEntryDaoTest extends EntityTestCase {
private DomainBase domain;
private HistoryEntry historyEntry;
@@ -35,7 +35,7 @@ import org.junit.jupiter.api.BeforeEach;
/** Unit tests for {@link Spec11ThreatMatchDao}. */
@DualDatabaseTest
public class Spec11ThreatMatchDaoTest extends EntityTestCase {
class Spec11ThreatMatchDaoTest extends EntityTestCase {
private static final LocalDate TODAY = new LocalDate(2020, 8, 4);
private static final LocalDate YESTERDAY = new LocalDate(2020, 8, 3);
@@ -40,7 +40,7 @@ import org.junit.jupiter.api.Disabled;
/** Unit tests for {@link Spec11ThreatMatch}. */
@DualDatabaseTest
public class Spec11ThreatMatchTest extends EntityTestCase {
public final class Spec11ThreatMatchTest extends EntityTestCase {
private static final String REGISTRAR_ID = "registrar";
private static final LocalDate DATE = LocalDate.parse("2020-06-10", ISODateTimeFormat.date());
@@ -82,7 +82,7 @@ class EntityCallbacksListenerTest {
@Test
void verifyAllManagedEntities_haveNoMethodWithEmbedded() {
ImmutableSet<Class> violations =
ImmutableSet<Class<?>> violations =
PersistenceXmlUtility.getManagedClasses().stream()
.filter(clazz -> clazz.isAnnotationPresent(Entity.class))
.filter(EntityCallbacksListenerTest::hasMethodAnnotatedWithEmbedded)
@@ -30,19 +30,19 @@ class PersistenceXmlTest {
@Test
void verifyClassTags_containOnlyRequiredClasses() {
ImmutableList<Class> managedClassed = PersistenceXmlUtility.getManagedClasses();
ImmutableList<Class<?>> managedClasses = PersistenceXmlUtility.getManagedClasses();
ImmutableList<Class> unnecessaryClasses =
managedClassed.stream()
ImmutableList<Class<?>> unnecessaryClasses =
managedClasses.stream()
.filter(
clazz ->
!clazz.isAnnotationPresent(Entity.class)
&& !AttributeConverter.class.isAssignableFrom(clazz))
.collect(toImmutableList());
ImmutableSet<Class> duplicateClasses =
managedClassed.stream()
.filter(clazz -> Collections.frequency(managedClassed, clazz) > 1)
ImmutableSet<Class<?>> duplicateClasses =
managedClasses.stream()
.filter(clazz -> Collections.frequency(managedClasses, clazz) > 1)
.collect(toImmutableSet());
assertWithMessage("Found duplicate <class> tags defined in persistence.xml.")
@@ -55,11 +55,9 @@ public class LocalDateConverterTest {
private LocalDateConverterTestEntity persistAndLoadTestEntity(LocalDate date) {
LocalDateConverterTestEntity entity = new LocalDateConverterTestEntity(date);
jpaTm().transact(() -> jpaTm().insert(entity));
LocalDateConverterTestEntity retrievedEntity =
jpaTm()
.transact(
() -> jpaTm().loadByKey(VKey.createSql(LocalDateConverterTestEntity.class, "id")));
return retrievedEntity;
return jpaTm()
.transact(
() -> jpaTm().loadByKey(VKey.createSql(LocalDateConverterTestEntity.class, "id")));
}
/** Override entity name to avoid the nested class reference. */
@@ -50,13 +50,13 @@ public class JpaEntityCoverageExtension implements BeforeEachCallback, AfterEach
// TransactionEntity is trivial, its persistence is tested in TransactionTest.
"TransactionEntity");
private static final ImmutableSet<Class> ALL_JPA_ENTITIES =
private static final ImmutableSet<Class<?>> ALL_JPA_ENTITIES =
PersistenceXmlUtility.getManagedClasses().stream()
.filter(e -> !IGNORE_ENTITIES.contains(e.getSimpleName()))
.filter(e -> e.isAnnotationPresent(Entity.class))
.filter(e -> !e.isAnnotationPresent(DiscriminatorValue.class))
.collect(ImmutableSet.toImmutableSet());
private static final Set<Class> allCoveredJpaEntities = Sets.newHashSet();
private static final Set<Class<?>> allCoveredJpaEntities = Sets.newHashSet();
// Map of test class name to boolean flag indicating if it tests any JPA entities.
private static final Map<String, Boolean> testsJpaEntities = Maps.newHashMap();
@@ -81,7 +81,7 @@ public class JpaEntityCoverageExtension implements BeforeEachCallback, AfterEach
testsJpaEntities.clear();
}
public static Set<Class> getUncoveredEntities() {
public static Set<Class<?>> getUncoveredEntities() {
return Sets.difference(ALL_JPA_ENTITIES, allCoveredJpaEntities);
}
@@ -99,9 +99,9 @@ public class JpaEntityCoverageExtension implements BeforeEachCallback, AfterEach
*
* @return true if an instance of {@code entityType} is found in the database and can be read
*/
private static boolean isPersisted(Class entityType) {
private static boolean isPersisted(Class<?> entityType) {
try {
List result =
List<?> result =
jpaTm()
.transact(
() ->
@@ -49,7 +49,7 @@ public class JpaTestRules {
public static class JpaIntegrationTestExtension extends JpaTransactionManagerExtension {
private JpaIntegrationTestExtension(
Clock clock,
ImmutableList<Class> extraEntityClasses,
ImmutableList<Class<?>> extraEntityClasses,
ImmutableMap<String, String> userProperties) {
super(clock, Optional.of(GOLDEN_SCHEMA_SQL_PATH), extraEntityClasses, userProperties);
}
@@ -63,7 +63,7 @@ public class JpaTestRules {
private JpaUnitTestExtension(
Clock clock,
Optional<String> initScriptPath,
ImmutableList<Class> extraEntityClasses,
ImmutableList<Class<?>> extraEntityClasses,
ImmutableMap<String, String> userProperties) {
super(clock, initScriptPath, false, extraEntityClasses, userProperties);
}
@@ -105,8 +105,8 @@ public class JpaTestRules {
private String initScript;
private Clock clock;
private List<Class> extraEntityClasses = new ArrayList<Class>();
private Map<String, String> userProperties = new HashMap<String, String>();
private List<Class<?>> extraEntityClasses = new ArrayList<>();
private Map<String, String> userProperties = new HashMap<>();
/**
* Sets the SQL script to be used to initialize the database. If not set,
@@ -125,7 +125,7 @@ public class JpaTestRules {
}
/** Adds annotated class(es) to the known entities for the database. */
public Builder withEntityClass(Class... classes) {
public Builder withEntityClass(Class<?>... classes) {
this.extraEntityClasses.addAll(ImmutableSet.copyOf(classes));
return this;
}
@@ -87,8 +87,8 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
private final Clock clock;
private final Optional<String> initScriptPath;
private final ImmutableList<Class> extraEntityClasses;
private final ImmutableMap userProperties;
private final ImmutableList<Class<?>> extraEntityClasses;
private final ImmutableMap<String, String> userProperties;
private static final JdbcDatabaseContainer database = create();
private static final HibernateSchemaExporter exporter =
@@ -102,7 +102,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
private JpaTransactionManager cachedTm;
// Hash of the ORM entity names requested by this rule instance.
private int entityHash;
private final int entityHash;
// Whether to create nomulus tables in the test db. Right now, only the JpaTestRules set this to
// false.
@@ -112,7 +112,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
Clock clock,
Optional<String> initScriptPath,
boolean includeNomulusSchema,
ImmutableList<Class> extraEntityClasses,
ImmutableList<Class<?>> extraEntityClasses,
ImmutableMap<String, String> userProperties) {
this.clock = clock;
this.initScriptPath = initScriptPath;
@@ -125,7 +125,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
JpaTransactionManagerExtension(
Clock clock,
Optional<String> initScriptPath,
ImmutableList<Class> extraEntityClasses,
ImmutableList<Class<?>> extraEntityClasses,
ImmutableMap<String, String> userProperties) {
this.clock = clock;
this.initScriptPath = initScriptPath;
@@ -143,7 +143,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
}
private static int getOrmEntityHash(
Optional<String> initScriptPath, ImmutableList<Class> extraEntityClasses) {
Optional<String> initScriptPath, ImmutableList<Class<?>> extraEntityClasses) {
return Streams.concat(
Stream.of(initScriptPath.orElse("")),
extraEntityClasses.stream().map(Class::getCanonicalName))
@@ -172,7 +172,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
executeSql(new String(Files.readAllBytes(tempSqlFile.toPath()), StandardCharsets.UTF_8));
}
ImmutableMap properties = PersistenceModule.provideDefaultDatabaseConfigs();
ImmutableMap<String, String> properties = PersistenceModule.provideDefaultDatabaseConfigs();
if (!userProperties.isEmpty()) {
// If there are user properties, create a new properties object with these added.
Map<String, String> mergedProperties = Maps.newHashMap();
@@ -338,7 +338,7 @@ abstract class JpaTransactionManagerExtension implements BeforeEachCallback, Aft
return Bootstrap.getEntityManagerFactoryBuilder(descriptor, properties).build();
}
private ImmutableList<Class> getTestEntities() {
private ImmutableList<Class<?>> getTestEntities() {
// We have to add the TransactionEntity to extra entities, as this is required by the
// transaction replication mechanism.
return Stream.concat(extraEntityClasses.stream(), Stream.of(TransactionEntity.class))
@@ -180,7 +180,7 @@ class JpaTransactionManagerImplTest {
@Test
void transact_retriesNestedOptimisticLockExceptions() {
JpaTransactionManager spyJpaTm = spy(jpaTm());
doThrow(new RuntimeException().initCause(new OptimisticLockException()))
doThrow(new RuntimeException(new OptimisticLockException()))
.when(spyJpaTm)
.delete(any(VKey.class));
spyJpaTm.transact(() -> spyJpaTm.insert(theEntity));
@@ -220,8 +220,8 @@ class JpaTransactionManagerImplTest {
void transactNewReadOnly_retriesNestedJdbcConnectionExceptions() {
JpaTransactionManager spyJpaTm = spy(jpaTm());
doThrow(
new RuntimeException()
.initCause(new JDBCConnectionException("connection exception", new SQLException())))
new RuntimeException(
new JDBCConnectionException("connection exception", new SQLException())))
.when(spyJpaTm)
.loadByKey(any(VKey.class));
spyJpaTm.transact(() -> spyJpaTm.insert(theEntity));
@@ -52,7 +52,7 @@ public class JpaTransactionManagerRuleTest {
jpaTm()
.transact(
() -> {
List results =
List<?> results =
jpaTm()
.getEntityManager()
.createNativeQuery("SELECT * FROM \"TestEntity\"")
@@ -78,7 +78,7 @@ public class SecretManagerClientTest {
}
@AfterEach
void afterEach() throws IOException {
void afterEach() {
if (isUnitTest) {
return;
}
@@ -130,7 +130,7 @@ class IcannHttpReporterTest {
}
@Test
void testFail_transportException() throws Exception {
void testFail_transportException() {
IcannHttpReporter reporter = createReporter();
reporter.httpTransport =
createMockTransport(HttpStatusCodes.STATUS_CODE_FORBIDDEN, ByteSource.empty());
@@ -154,8 +154,7 @@ public class LockDaoTest {
assertAboutLogs()
.that(logHandler)
.hasLogAtLevelWithMessage(
Level.WARNING,
String.format("Cloud SQL lock for testResource with tld GLOBAL should be null"));
Level.WARNING, "Cloud SQL lock for testResource with tld GLOBAL should be null");
}
@Test
@@ -171,22 +170,19 @@ public class LockDaoTest {
.that(logHandler)
.hasLogAtLevelWithMessage(
Level.WARNING,
String.format(
"Datastore lock requestLogId of wrong does not equal Cloud SQL lock requestLogId"
+ " of testLogId"));
"Datastore lock requestLogId of wrong does not equal Cloud SQL lock requestLogId"
+ " of testLogId");
assertAboutLogs()
.that(logHandler)
.hasLogAtLevelWithMessage(
Level.WARNING,
String.format(
"Datastore lock acquiredTime of 1969-12-31T00:00:00.000Z does not equal Cloud SQL"
+ " lock acquiredTime of 1970-01-01T00:00:00.000Z"));
"Datastore lock acquiredTime of 1969-12-31T00:00:00.000Z does not equal Cloud SQL"
+ " lock acquiredTime of 1970-01-01T00:00:00.000Z");
assertAboutLogs()
.that(logHandler)
.hasLogAtLevelWithMessage(
Level.WARNING,
String.format(
"Datastore lock expirationTime of 1969-12-31T00:00:00.003Z does not equal Cloud"
+ " SQL lock expirationTime of 1970-01-01T00:00:00.002Z"));
"Datastore lock expirationTime of 1969-12-31T00:00:00.003Z does not equal Cloud"
+ " SQL lock expirationTime of 1970-01-01T00:00:00.002Z");
}
}
@@ -381,9 +381,7 @@ public final class AppEngineExtension implements BeforeEachCallback, AfterEachCa
jpaIntegrationWithCoverageExtension.beforeEach(context);
} else if (withJpaUnitTest) {
jpaUnitTestRule =
builder
.withEntityClass(jpaTestEntities.toArray(new Class[jpaTestEntities.size()]))
.buildUnitTestRule();
builder.withEntityClass(jpaTestEntities.toArray(new Class[0])).buildUnitTestRule();
jpaUnitTestRule.beforeEach(context);
} else {
jpaIntegrationTestRule = builder.buildIntegrationTestRule();
@@ -31,7 +31,7 @@ public class ContextCapturingMetaExtension implements BeforeEachCallback {
private ExtensionContext context;
@Override
public void beforeEach(ExtensionContext context) throws Exception {
public void beforeEach(ExtensionContext context) {
this.context = context;
}
@@ -76,7 +76,7 @@ class CreateCdnsTldTest extends CommandTestCase<CreateCdnsTld> {
@Test
@MockitoSettings(strictness = Strictness.LENIENT)
void testSandboxTldRestrictions() throws Exception {
void testSandboxTldRestrictions() {
IllegalArgumentException thrown =
assertThrows(
IllegalArgumentException.class,
@@ -365,7 +365,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
}
@Test
void testFail_clientCertFileFlagWithViolation() throws Exception {
void testFail_clientCertFileFlagWithViolation() {
fakeClock.setTo(DateTime.parse("2020-10-01T00:00:00Z"));
InsecureCertificateException thrown =
assertThrows(
@@ -395,7 +395,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
}
@Test
void testFail_clientCertFileFlagWithMultipleViolations() throws Exception {
void testFail_clientCertFileFlagWithMultipleViolations() {
fakeClock.setTo(DateTime.parse("2055-10-01T00:00:00Z"));
InsecureCertificateException thrown =
assertThrows(
@@ -452,7 +452,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
}
@Test
void testFail_failoverClientCertFileFlagWithViolations() throws Exception {
void testFail_failoverClientCertFileFlagWithViolations() {
fakeClock.setTo(DateTime.parse("2020-11-01T00:00:00Z"));
InsecureCertificateException thrown =
assertThrows(
@@ -482,7 +482,7 @@ class CreateRegistrarCommandTest extends CommandTestCase<CreateRegistrarCommand>
}
@Test
void testFail_failoverClientCertFileFlagWithMultipleViolations() throws Exception {
void testFail_failoverClientCertFileFlagWithMultipleViolations() {
fakeClock.setTo(DateTime.parse("2055-11-01T00:00:00Z"));
InsecureCertificateException thrown =
assertThrows(
@@ -101,7 +101,7 @@ class CurlCommandTest extends CommandTestCase<CurlCommand> {
@Test
@MockitoSettings(strictness = Strictness.LENIENT)
void testPostInvocation_badContentType() throws Exception {
void testPostInvocation_badContentType() {
assertThrows(
IllegalArgumentException.class,
() ->
@@ -80,7 +80,7 @@ class DedupeOneTimeBillingEventIdsCommandTest
}
@Test
void resaveBillingEvent_failsWhenReferredByDomain() throws Exception {
void resaveBillingEvent_failsWhenReferredByDomain() {
persistResource(
domain
.asBuilder()
@@ -115,7 +115,7 @@ class GenerateDnsReportCommandTest extends CommandTestCase<GenerateDnsReportComm
"2607:f8b0:400d:c00:0:0:0:c1"));
@BeforeEach
void beforeEach() throws Exception {
void beforeEach() {
output = tmpDir.resolve("out.dat");
command.clock = clock;
clock.setTo(now);
@@ -58,7 +58,7 @@ class GenerateSqlErDiagramCommandTest extends CommandTestCase<GenerateSqlErDiagr
}
@Test
void validateErDiagramIsUpToDate() throws Exception {
void validateErDiagramIsUpToDate() {
String goldenFullDiagram =
ResourceUtils.readResourceUtf8(
Resources.getResource(
@@ -34,7 +34,7 @@ class SetSqlReplayCheckpointCommandTest extends CommandTestCase<SetSqlReplayChec
}
@Test
void testFailure_multipleParams() throws Exception {
void testFailure_multipleParams() {
DateTime one = DateTime.parse("2000-06-06T22:00:00.0Z");
DateTime two = DateTime.parse("2001-06-06T22:00:00.0Z");
assertThrows(IllegalArgumentException.class, () -> runCommand(one.toString(), two.toString()));
@@ -266,8 +266,7 @@ class ShellCommandTest {
@Test
void testEncapsulatedOutputStream_emptyStream() {
ByteArrayOutputStream backing = new ByteArrayOutputStream();
try (PrintStream out =
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: "))) {}
new PrintStream(new ShellCommand.EncapsulatingOutputStream(backing, "out: ")).close();
assertThat(backing.toString()).isEqualTo("");
}
@@ -54,7 +54,7 @@ class PathParameterTest {
}
@Test
void testConvert_relativePath_returnsOriginalFile() throws Exception {
void testConvert_relativePath_returnsOriginalFile() {
Path currentDirectory = Paths.get("").toAbsolutePath();
Path file = Paths.get(tmpDir.resolve("tmp.file").toString());
Path relative = file.relativize(currentDirectory);
@@ -65,7 +65,7 @@ class PathParameterTest {
}
@Test
void testConvert_extraSlash_returnsWithoutSlash() throws Exception {
void testConvert_extraSlash_returnsWithoutSlash() {
Path file = Paths.get(tmpDir.resolve("file.new").toString());
assertThat((Object) vanilla.convert(file + "/")).isEqualTo(file);
}
@@ -115,7 +115,7 @@ class PathParameterTest {
private final PathParameter outputFile = new PathParameter.OutputFile();
@Test
void testOutputFileValidate_normalFile_works() throws Exception {
void testOutputFileValidate_normalFile_works() {
outputFile.validate("input", tmpDir.resolve("testfile").toString());
}
@@ -146,7 +146,7 @@ class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
}
@Test
void testEmptyOrNullCertificate_doesNotClearOutCurrentOne() throws Exception {
void testEmptyOrNullCertificate_doesNotClearOutCurrentOne() {
Registrar initialRegistrar =
persistResource(
loadRegistrar(CLIENT_ID)