mirror of
https://github.com/google/nomulus.git
synced 2025-08-04 00:42:12 +02:00
Fix some issues caught by IntelliJ static code analysis
The most common issues were: * Arrays.asList() shouldn't be called with a single parameter. * Broken Javadoc @links. * Unnecessary casts and type declarations. * Unnecessary unused variable initializations. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=230994311
This commit is contained in:
parent
3cf26ff9b6
commit
c6e58d3bff
39 changed files with 132 additions and 165 deletions
|
@ -25,7 +25,6 @@ import static google.registry.backup.ExportCommitLogDiffAction.DIFF_FILE_PREFIX;
|
|||
import static google.registry.model.ofy.CommitLogBucket.getBucketIds;
|
||||
import static google.registry.model.ofy.CommitLogBucket.getBucketKey;
|
||||
import static google.registry.model.ofy.ObjectifyService.ofy;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
||||
import com.google.appengine.api.datastore.DatastoreServiceFactory;
|
||||
|
@ -135,7 +134,7 @@ public class RestoreCommitLogsActionTest {
|
|||
assertExpectedIds("previous to keep", "b", "d", "e", "f");
|
||||
assertInDatastore(file1CommitLogs);
|
||||
assertInDatastore(file2CommitLogs);
|
||||
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
|
||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||
assertCommitLogBuckets(ImmutableMap.of(1, now.minusMinutes(1), 2, now.minusMinutes(2)));
|
||||
}
|
||||
|
||||
|
@ -149,7 +148,7 @@ public class RestoreCommitLogsActionTest {
|
|||
ofy().clearSessionCache();
|
||||
assertExpectedIds("previous to keep");
|
||||
assertInDatastore(commitLogs);
|
||||
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
|
||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||
assertCommitLogBuckets(ImmutableMap.of());
|
||||
}
|
||||
|
||||
|
@ -168,7 +167,7 @@ public class RestoreCommitLogsActionTest {
|
|||
ofy().clearSessionCache();
|
||||
assertExpectedIds("previous to keep", "a", "b");
|
||||
assertInDatastore(commitLogs);
|
||||
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
|
||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
||||
}
|
||||
|
||||
|
@ -188,7 +187,7 @@ public class RestoreCommitLogsActionTest {
|
|||
ofy().clearSessionCache();
|
||||
assertExpectedIds("previous to keep");
|
||||
assertInDatastore(commitLogs);
|
||||
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
|
||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
||||
}
|
||||
|
||||
|
@ -205,7 +204,7 @@ public class RestoreCommitLogsActionTest {
|
|||
ofy().clearSessionCache();
|
||||
assertExpectedIds("previous to keep");
|
||||
assertInDatastore(commitLogs);
|
||||
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
|
||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
||||
}
|
||||
|
||||
|
@ -222,7 +221,7 @@ public class RestoreCommitLogsActionTest {
|
|||
ofy().clearSessionCache();
|
||||
assertThat(ofy().load().entity(TestObject.create("existing")).now().getField()).isEqualTo("b");
|
||||
assertInDatastore(commitLogs);
|
||||
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
|
||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
||||
}
|
||||
|
||||
|
@ -242,7 +241,7 @@ public class RestoreCommitLogsActionTest {
|
|||
assertExpectedIds("previous to keep");
|
||||
assertInDatastore(commitLogs);
|
||||
assertCommitLogBuckets(ImmutableMap.of(1, now));
|
||||
assertInDatastore(asList(CommitLogCheckpointRoot.create(now)));
|
||||
assertInDatastore(CommitLogCheckpointRoot.create(now));
|
||||
}
|
||||
|
||||
private CommitLogCheckpoint createCheckpoint(DateTime now) {
|
||||
|
@ -280,6 +279,10 @@ public class RestoreCommitLogsActionTest {
|
|||
.containsExactly((Object[]) ids);
|
||||
}
|
||||
|
||||
private void assertInDatastore(ImmutableObject entity) {
|
||||
assertThat(ofy().load().entity(entity).now()).isEqualTo(entity);
|
||||
}
|
||||
|
||||
private void assertInDatastore(Iterable<? extends ImmutableObject> entities) {
|
||||
assertThat(ofy().load().entities(entities).values()).containsExactlyElementsIn(entities);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ import google.registry.export.datastore.Operation.Metadata;
|
|||
import google.registry.export.datastore.Operation.Progress;
|
||||
import google.registry.testing.FakeClock;
|
||||
import google.registry.testing.TestDataHelper;
|
||||
import google.registry.util.Clock;
|
||||
import java.io.IOException;
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.Duration;
|
||||
|
@ -91,8 +90,8 @@ public class OperationTest {
|
|||
Operation.OperationList operationList =
|
||||
loadJson("operation_list.json", Operation.OperationList.class);
|
||||
assertThat(operationList.toList()).hasSize(2);
|
||||
Clock clock = new FakeClock(DateTime.parse("2018-10-29T16:01:04.645299Z"));
|
||||
((FakeClock) clock).advanceOneMilli();
|
||||
FakeClock clock = new FakeClock(DateTime.parse("2018-10-29T16:01:04.645299Z"));
|
||||
clock.advanceOneMilli();
|
||||
assertThat(operationList.toList().get(0).getRunningTime(clock)).isEqualTo(Duration.millis(1));
|
||||
assertThat(operationList.toList().get(0).getProgress())
|
||||
.isEqualTo("Progress: [51797/54513 entities]");
|
||||
|
|
|
@ -84,9 +84,7 @@ public class SheetSynchronizerTest {
|
|||
|
||||
// Explicitly constructs a List<Object> to avoid newArrayList typing to ArrayList<String>
|
||||
private List<Object> createRow(Object... elements) {
|
||||
List<Object> row = new ArrayList<>();
|
||||
row.addAll(Arrays.asList(elements));
|
||||
return row;
|
||||
return new ArrayList<>(Arrays.asList(elements));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -59,15 +59,15 @@ public class EppConsoleActionTest extends ShardableTestCase {
|
|||
ArgumentCaptor<TransportCredentials> credentialsCaptor =
|
||||
ArgumentCaptor.forClass(TransportCredentials.class);
|
||||
ArgumentCaptor<SessionMetadata> metadataCaptor = ArgumentCaptor.forClass(SessionMetadata.class);
|
||||
verify(action.eppRequestHandler).executeEpp(
|
||||
metadataCaptor.capture(),
|
||||
credentialsCaptor.capture(),
|
||||
eq(EppRequestSource.CONSOLE),
|
||||
eq(false),
|
||||
eq(false),
|
||||
eq(INPUT_XML_BYTES));
|
||||
assertThat(((GaeUserCredentials) credentialsCaptor.getValue()).toString())
|
||||
.contains("user=TestUserId");
|
||||
verify(action.eppRequestHandler)
|
||||
.executeEpp(
|
||||
metadataCaptor.capture(),
|
||||
credentialsCaptor.capture(),
|
||||
eq(EppRequestSource.CONSOLE),
|
||||
eq(false),
|
||||
eq(false),
|
||||
eq(INPUT_XML_BYTES));
|
||||
assertThat(credentialsCaptor.getValue().toString()).contains("user=TestUserId");
|
||||
assertThat(metadataCaptor.getValue().getClientId()).isEqualTo("ClientIdentifier");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,7 +30,6 @@ import static org.joda.time.DateTimeZone.UTC;
|
|||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Iterables;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.ObjectArrays;
|
||||
import com.google.common.collect.Streams;
|
||||
|
@ -173,29 +172,6 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
assertThat(ofy().load().type(HistoryEntry.class)).isEmpty();
|
||||
}
|
||||
|
||||
public <T> T getOnlyGlobalResource(Class<T> clazz) {
|
||||
return Iterables.getOnlyElement(ofy().load().type(clazz));
|
||||
}
|
||||
|
||||
/** Helper to remove the grace period's billing event key to facilitate comparison. */
|
||||
/** A helper class that sets the billing event parent history entry to facilitate comparison. */
|
||||
public static class BillingEventParentSetter implements Function<BillingEvent, BillingEvent> {
|
||||
private HistoryEntry historyEntry;
|
||||
|
||||
public static BillingEventParentSetter withParent(HistoryEntry historyEntry) {
|
||||
BillingEventParentSetter instance = new BillingEventParentSetter();
|
||||
instance.historyEntry = historyEntry;
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BillingEvent apply(BillingEvent billingEvent) {
|
||||
return billingEvent.asBuilder().setParent(historyEntry).build();
|
||||
}
|
||||
|
||||
private BillingEventParentSetter() {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to facilitate comparison of maps of GracePeriods to BillingEvents. This takes a map of
|
||||
* GracePeriods to BillingEvents and returns a map of the same entries that ignores the keys
|
||||
|
@ -340,7 +316,7 @@ public abstract class FlowTestCase<F extends Flow> extends ShardableTestCase {
|
|||
String.format(
|
||||
"Invalid xml.\nExpected:\n%s\n\nActual:\n%s\n",
|
||||
xml,
|
||||
marshal(output, ValidationMode.LENIENT)),
|
||||
Arrays.toString(marshal(output, ValidationMode.LENIENT))),
|
||||
e);
|
||||
}
|
||||
// Clear the cache so that we don't see stale results in tests.
|
||||
|
|
|
@ -762,12 +762,8 @@ public class DomainDeleteFlowTest extends ResourceFlowTestCase<DomainDeleteFlow,
|
|||
.asBuilder()
|
||||
.setSuperordinateDomain(Key.create(reloadResourceByForeignKey()))
|
||||
.build());
|
||||
domain =
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.addSubordinateHost(subordinateHost.getFullyQualifiedHostName())
|
||||
.build());
|
||||
persistResource(
|
||||
domain.asBuilder().addSubordinateHost(subordinateHost.getFullyQualifiedHostName()).build());
|
||||
EppException thrown = assertThrows(DomainToDeleteHasHostsException.class, this::runFlow);
|
||||
assertAboutEppExceptions().that(thrown).marshalsToXml();
|
||||
}
|
||||
|
|
|
@ -99,25 +99,24 @@ public class DomainRestoreRequestFlowTest
|
|||
.setType(HistoryEntry.Type.DOMAIN_DELETE)
|
||||
.setParent(domain)
|
||||
.build());
|
||||
domain =
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.setRegistrationExpirationTime(clock.nowUtc().plusYears(5).plusDays(45))
|
||||
.setDeletionTime(clock.nowUtc().plusDays(35))
|
||||
.addGracePeriod(
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.REDEMPTION, clock.nowUtc().plusDays(1), "foo", null))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
.setDeletePollMessage(
|
||||
Key.create(
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setClientId("TheRegistrar")
|
||||
.setEventTime(clock.nowUtc().plusDays(5))
|
||||
.setParent(historyEntry)
|
||||
.build())))
|
||||
.build());
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.setRegistrationExpirationTime(clock.nowUtc().plusYears(5).plusDays(45))
|
||||
.setDeletionTime(clock.nowUtc().plusDays(35))
|
||||
.addGracePeriod(
|
||||
GracePeriod.create(
|
||||
GracePeriodStatus.REDEMPTION, clock.nowUtc().plusDays(1), "foo", null))
|
||||
.setStatusValues(ImmutableSet.of(StatusValue.PENDING_DELETE))
|
||||
.setDeletePollMessage(
|
||||
Key.create(
|
||||
persistResource(
|
||||
new PollMessage.OneTime.Builder()
|
||||
.setClientId("TheRegistrar")
|
||||
.setEventTime(clock.nowUtc().plusDays(5))
|
||||
.setParent(historyEntry)
|
||||
.build())))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
}
|
||||
|
||||
|
|
|
@ -325,27 +325,27 @@ public class DomainUpdateFlowTest extends ResourceFlowTestCase<DomainUpdateFlow,
|
|||
setEppInput("domain_update_subordinate_hosts.xml");
|
||||
persistReferencedEntities();
|
||||
DomainBase domain = persistDomain();
|
||||
HostResource existingHost = persistActiveSubordinateHost("ns1.example.tld", domain);
|
||||
persistActiveSubordinateHost("ns1.example.tld", domain);
|
||||
HostResource addedHost = persistActiveSubordinateHost("ns2.example.tld", domain);
|
||||
domain =
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addSubordinateHost("ns2.example.tld")
|
||||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())
|
||||
.get())))
|
||||
.build());
|
||||
persistResource(
|
||||
domain
|
||||
.asBuilder()
|
||||
.addSubordinateHost("ns1.example.tld")
|
||||
.addSubordinateHost("ns2.example.tld")
|
||||
.setNameservers(
|
||||
ImmutableSet.of(
|
||||
Key.create(
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc())
|
||||
.get())))
|
||||
.build());
|
||||
clock.advanceOneMilli();
|
||||
assertTransactionalFlow(true);
|
||||
runFlowAssertResponse(loadFile("generic_success_response.xml"));
|
||||
domain = reloadResourceByForeignKey();
|
||||
assertThat(domain.getNameservers()).containsExactly(Key.create(addedHost));
|
||||
assertThat(domain.getSubordinateHosts()).containsExactly("ns1.example.tld", "ns2.example.tld");
|
||||
existingHost = loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()).get();
|
||||
HostResource existingHost =
|
||||
loadByForeignKey(HostResource.class, "ns1.example.tld", clock.nowUtc()).get();
|
||||
addedHost = loadByForeignKey(HostResource.class, "ns2.example.tld", clock.nowUtc()).get();
|
||||
assertThat(existingHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
assertThat(addedHost.getSuperordinateDomain()).isEqualTo(Key.create(domain));
|
||||
|
|
|
@ -30,6 +30,7 @@ import static google.registry.testing.DatastoreHelper.persistReservedList;
|
|||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.DateTimeUtils.END_OF_TIME;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static java.math.BigDecimal.ROUND_UNNECESSARY;
|
||||
import static org.joda.money.CurrencyUnit.EUR;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
|
||||
|
@ -497,7 +498,7 @@ public class RegistryTest extends EntityTestCase {
|
|||
@Test
|
||||
public void testEapFee_undefined() {
|
||||
assertThat(Registry.get("tld").getEapFeeFor(clock.nowUtc()).getCost())
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2));
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2, ROUND_UNNECESSARY));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -514,7 +515,7 @@ public class RegistryTest extends EntityTestCase {
|
|||
assertThat(registry.getEapFeeFor(clock.nowUtc()).getCost())
|
||||
.isEqualTo(new BigDecimal("100.00"));
|
||||
assertThat(registry.getEapFeeFor(clock.nowUtc().minusDays(2)).getCost())
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2));
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2, ROUND_UNNECESSARY));
|
||||
assertThat(registry.getEapFeeFor(clock.nowUtc().plusDays(2)).getCost())
|
||||
.isEqualTo(new BigDecimal("50.00"));
|
||||
}
|
||||
|
|
|
@ -88,7 +88,8 @@ public class FrontendMetricsTest {
|
|||
.and()
|
||||
.hasNoOtherValues();
|
||||
|
||||
ChannelFuture unusedFuture = channel1.close();
|
||||
@SuppressWarnings("unused")
|
||||
ChannelFuture unusedFuture1 = channel1.close();
|
||||
assertThat(channel1.isActive()).isFalse();
|
||||
assertThat(FrontendMetrics.activeConnectionsGauge)
|
||||
.hasValueForLabels(1, PROTOCOL, CERT_HASH)
|
||||
|
@ -99,7 +100,8 @@ public class FrontendMetricsTest {
|
|||
.and()
|
||||
.hasNoOtherValues();
|
||||
|
||||
unusedFuture = channel2.close();
|
||||
@SuppressWarnings("unused")
|
||||
ChannelFuture unusedFuture2 = channel2.close();
|
||||
assertThat(channel2.isActive()).isFalse();
|
||||
assertThat(FrontendMetrics.activeConnectionsGauge).hasNoOtherValues();
|
||||
assertThat(FrontendMetrics.totalConnectionsCounter)
|
||||
|
|
|
@ -46,6 +46,7 @@ import google.registry.model.domain.secdns.DelegationSignerData;
|
|||
import google.registry.model.eppcommon.StatusValue;
|
||||
import google.registry.model.host.HostResource;
|
||||
import google.registry.model.poll.PollMessage;
|
||||
import google.registry.model.poll.PollMessage.Autorenew;
|
||||
import google.registry.model.reporting.HistoryEntry;
|
||||
import google.registry.model.transfer.TransferData;
|
||||
import google.registry.model.transfer.TransferStatus;
|
||||
|
@ -377,9 +378,9 @@ public class XjcToDomainBaseConverterTest {
|
|||
// First import in a transaction, then verify in another transaction.
|
||||
// Ancestor queries don't work within the same transaction.
|
||||
DomainBase domain = persistResource(convertDomainInTransaction(xjcDomain));
|
||||
PollMessage pollMessage = ofy().load().key(domain.getAutorenewPollMessage()).now();
|
||||
Autorenew pollMessage = ofy().load().key(domain.getAutorenewPollMessage()).now();
|
||||
assertThat(pollMessage).isInstanceOf(PollMessage.Autorenew.class);
|
||||
assertThat(((PollMessage.Autorenew) pollMessage).getTargetId()).isEqualTo(xjcDomain.getRoid());
|
||||
assertThat(pollMessage.getTargetId()).isEqualTo(xjcDomain.getRoid());
|
||||
assertThat(pollMessage.getClientId()).isEqualTo("RegistrarX");
|
||||
assertThat(pollMessage.getEventTime()).isEqualTo(xjcDomain.getExDate());
|
||||
assertThat(pollMessage.getMsg()).isEqualTo("Domain was auto-renewed.");
|
||||
|
|
|
@ -290,11 +290,13 @@ public final class AppEngineRule extends ExternalResource {
|
|||
|
||||
if (withUserService) {
|
||||
// Set top-level properties on LocalServiceTestConfig for user login.
|
||||
helper.setEnvIsLoggedIn(userInfo.isLoggedIn())
|
||||
helper
|
||||
.setEnvIsLoggedIn(userInfo.isLoggedIn())
|
||||
// This envAttributes thing is the only way to set userId.
|
||||
// see https://code.google.com/p/googleappengine/issues/detail?id=3579
|
||||
.setEnvAttributes(ImmutableMap.<String, Object>of(
|
||||
"com.google.appengine.api.users.UserService.user_id_key", userInfo.gaeUserId()))
|
||||
.setEnvAttributes(
|
||||
ImmutableMap.of(
|
||||
"com.google.appengine.api.users.UserService.user_id_key", userInfo.gaeUserId()))
|
||||
.setEnvAuthDomain(userInfo.authDomain())
|
||||
.setEnvEmail(userInfo.email())
|
||||
.setEnvIsAdmin(userInfo.isAdmin());
|
||||
|
|
|
@ -26,7 +26,7 @@ public class FakeLockHandler implements LockHandler {
|
|||
|
||||
private static final long serialVersionUID = 6437880915118738492L;
|
||||
|
||||
boolean lockSucceeds = true;
|
||||
boolean lockSucceeds;
|
||||
|
||||
/**
|
||||
* @param lockSucceeds if true - the lock acquisition will succeed and the callable will be
|
||||
|
|
|
@ -23,6 +23,7 @@ import static google.registry.testing.DatastoreHelper.persistPremiumList;
|
|||
import static google.registry.testing.DatastoreHelper.persistReservedList;
|
||||
import static google.registry.testing.JUnitBackports.assertThrows;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static java.math.BigDecimal.ROUND_UNNECESSARY;
|
||||
import static org.joda.money.CurrencyUnit.JPY;
|
||||
import static org.joda.money.CurrencyUnit.USD;
|
||||
import static org.joda.time.DateTimeZone.UTC;
|
||||
|
@ -135,7 +136,7 @@ public class CreateTldCommandTest extends CommandTestCase<CreateTldCommand> {
|
|||
|
||||
Registry registry = Registry.get("xn--q9jyb4c");
|
||||
assertThat(registry.getEapFeeFor(now.minusHours(1)).getCost())
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2));
|
||||
.isEqualTo(BigDecimal.ZERO.setScale(2, ROUND_UNNECESSARY));
|
||||
assertThat(registry.getEapFeeFor(now.plusHours(1)).getCost())
|
||||
.isEqualTo(new BigDecimal("50.00"));
|
||||
assertThat(registry.getEapFeeFor(now.plusDays(1).plusHours(1)).getCost())
|
||||
|
|
|
@ -36,10 +36,11 @@ import org.mockito.ArgumentCaptor;
|
|||
/**
|
||||
* Class for verifying EPP commands sent to the server via the tool endpoint.
|
||||
*
|
||||
* <p>Provides its own (mock) {@link Connection} that will be monitored for EPP transmission. This
|
||||
* Connection needs to be registered with the tool endpoint - something like this:
|
||||
* <p>Provides its own (mock) {@link AppEngineConnection} that will be monitored for EPP
|
||||
* transmission. This Connection needs to be registered with the tool endpoint - something like
|
||||
* this:
|
||||
*
|
||||
* <pre> {@code
|
||||
* <pre>{@code
|
||||
* SomeToolCommand command = ...;
|
||||
* EppToolVerifier eppToolVerifier = EppToolVerifier.create(command);
|
||||
* // run command...
|
||||
|
|
|
@ -20,7 +20,6 @@ import static google.registry.testing.DatastoreHelper.persistResource;
|
|||
import static google.registry.testing.TaskQueueHelper.assertNoTasksEnqueued;
|
||||
import static google.registry.testing.TaskQueueHelper.assertTasksEnqueued;
|
||||
import static google.registry.testing.TestDataHelper.loadFile;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.mockito.Matchers.anyInt;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
@ -108,7 +107,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
|
|||
.containsExactly(
|
||||
"status", "SUCCESS",
|
||||
"message", "Success",
|
||||
"results", asList(loadRegistrar(CLIENT_ID).toJsonMap()));
|
||||
"results", ImmutableList.of(loadRegistrar(CLIENT_ID).toJsonMap()));
|
||||
assertMetric(CLIENT_ID, "read", "[OWNER]", "SUCCESS");
|
||||
}
|
||||
|
||||
|
@ -164,7 +163,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
|
|||
assertThat(response).containsExactly(
|
||||
"status", "SUCCESS",
|
||||
"message", "Saved TheRegistrar",
|
||||
"results", asList(loadRegistrar(CLIENT_ID).toJsonMap()));
|
||||
"results", ImmutableList.of(loadRegistrar(CLIENT_ID).toJsonMap()));
|
||||
assertMetric(CLIENT_ID, "update", "[OWNER]", "SUCCESS");
|
||||
}
|
||||
|
||||
|
@ -285,7 +284,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
|
|||
// This role is authorized to perform this change, make sure the change succeeded
|
||||
// We got a success result:
|
||||
assertThat(response).containsEntry("status", "SUCCESS");
|
||||
assertThat(response).containsEntry("results", asList(updatedRegistrar.toJsonMap()));
|
||||
assertThat(response).containsEntry("results", ImmutableList.of(updatedRegistrar.toJsonMap()));
|
||||
// The updatedRegistrar had its value changed:
|
||||
// (We check it separately from the next assert to get better error message on failure)
|
||||
assertThat(getter.apply(updatedRegistrar)).isEqualTo(newValue);
|
||||
|
@ -467,7 +466,7 @@ public class RegistrarSettingsActionTest extends RegistrarSettingsActionTestCase
|
|||
.containsExactly(
|
||||
"status", "SUCCESS",
|
||||
"message", "Saved TheRegistrar",
|
||||
"results", asList(loadRegistrar(CLIENT_ID).toJsonMap()));
|
||||
"results", ImmutableList.of(loadRegistrar(CLIENT_ID).toJsonMap()));
|
||||
assertMetric(CLIENT_ID, "update", "[OWNER]", "SUCCESS");
|
||||
}
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ import static google.registry.testing.CertificateSamples.SAMPLE_CERT_HASH;
|
|||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static google.registry.testing.DatastoreHelper.persistResource;
|
||||
import static google.registry.util.DateTimeUtils.START_OF_TIME;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import google.registry.model.registrar.Registrar;
|
||||
import java.util.Map;
|
||||
|
@ -52,7 +52,7 @@ public class SecuritySettingsTest extends RegistrarSettingsActionTestCase {
|
|||
"id", CLIENT_ID,
|
||||
"args", modified.toJsonMap()));
|
||||
assertThat(response).containsEntry("status", "SUCCESS");
|
||||
assertThat(response).containsEntry("results", asList(modified.toJsonMap()));
|
||||
assertThat(response).containsEntry("results", ImmutableList.of(modified.toJsonMap()));
|
||||
assertThat(loadRegistrar(CLIENT_ID)).isEqualTo(modified);
|
||||
assertMetric(CLIENT_ID, "update", "[OWNER]", "SUCCESS");
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ package google.registry.ui.server.registrar;
|
|||
import static com.google.common.base.Strings.repeat;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static google.registry.testing.DatastoreHelper.loadRegistrar;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
@ -59,7 +58,7 @@ public class WhoisSettingsTest extends RegistrarSettingsActionTestCase {
|
|||
action.handleJsonRequest(
|
||||
ImmutableMap.of("op", "update", "id", CLIENT_ID, "args", modified.toJsonMap()));
|
||||
assertThat(response.get("status")).isEqualTo("SUCCESS");
|
||||
assertThat(response.get("results")).isEqualTo(asList(modified.toJsonMap()));
|
||||
assertThat(response.get("results")).isEqualTo(ImmutableList.of(modified.toJsonMap()));
|
||||
assertThat(loadRegistrar(CLIENT_ID)).isEqualTo(modified);
|
||||
assertMetric(CLIENT_ID, "update", "[OWNER]", "SUCCESS");
|
||||
}
|
||||
|
|
|
@ -67,8 +67,6 @@ public class CidrAddressBlockTest extends TestCase {
|
|||
assertEquals(32, b1.getNetmask());
|
||||
b1 = new CidrAddressBlock("2001:db8::1");
|
||||
assertEquals(128, b1.getNetmask());
|
||||
b1 = new CidrAddressBlock("3ffe::/16");
|
||||
|
||||
b1 = new CidrAddressBlock(InetAddresses.forString("5ffe::1"));
|
||||
assertEquals(128, b1.getNetmask());
|
||||
assertEquals("5ffe:0:0:0:0:0:0:1", b1.getIp());
|
||||
|
|
|
@ -19,6 +19,7 @@ import static google.registry.testing.JUnitBackports.assertThrows;
|
|||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
import static java.util.Arrays.asList;
|
||||
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.OutputStream;
|
||||
|
@ -60,7 +61,7 @@ public class TeeOutputStreamTest {
|
|||
|
||||
@Test
|
||||
public void testWriteInteger_failsAfterClose() throws Exception {
|
||||
OutputStream tee = new TeeOutputStream(asList(outputA));
|
||||
OutputStream tee = new TeeOutputStream(ImmutableList.of(outputA));
|
||||
tee.close();
|
||||
IllegalStateException thrown = assertThrows(IllegalStateException.class, () -> tee.write(1));
|
||||
assertThat(thrown).hasMessageThat().contains("outputstream closed");
|
||||
|
@ -68,7 +69,7 @@ public class TeeOutputStreamTest {
|
|||
|
||||
@Test
|
||||
public void testWriteByteArray_failsAfterClose() throws Exception {
|
||||
OutputStream tee = new TeeOutputStream(asList(outputA));
|
||||
OutputStream tee = new TeeOutputStream(ImmutableList.of(outputA));
|
||||
tee.close();
|
||||
IllegalStateException thrown =
|
||||
assertThrows(IllegalStateException.class, () -> tee.write("hello".getBytes(UTF_8)));
|
||||
|
@ -77,7 +78,7 @@ public class TeeOutputStreamTest {
|
|||
|
||||
@Test
|
||||
public void testWriteByteSubarray_failsAfterClose() throws Exception {
|
||||
OutputStream tee = new TeeOutputStream(asList(outputA));
|
||||
OutputStream tee = new TeeOutputStream(ImmutableList.of(outputA));
|
||||
tee.close();
|
||||
IllegalStateException thrown =
|
||||
assertThrows(IllegalStateException.class, () -> tee.write("hello".getBytes(UTF_8), 1, 3));
|
||||
|
|
|
@ -139,8 +139,7 @@ public class XmlTestUtils {
|
|||
}
|
||||
// First, handle all namespace specifications, updating our ns-to-URI map. Use a HashMap
|
||||
// rather than an ImmutableMap.Builder so that we can override existing map entries.
|
||||
HashMap<String, String> newNsMap = new HashMap<>();
|
||||
newNsMap.putAll(nsMap);
|
||||
HashMap<String, String> newNsMap = new HashMap<>(nsMap);
|
||||
for (String key : namespacesBuilder.build()) {
|
||||
// Parse the attribute name, of the form xmlns:nsid, and extract the namespace identifier.
|
||||
// If there's no colon, we are setting the default namespace.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue