mirror of
https://github.com/google/nomulus.git
synced 2025-04-30 12:07:51 +02:00
Change to hasSize() for assertions (#1588)
* Change to hasSize() for assertions
This commit is contained in:
parent
f79e4740f6
commit
9ec303bd71
10 changed files with 19 additions and 17 deletions
|
@ -92,7 +92,7 @@ public class DeleteOldCommitLogsActionTest
|
||||||
contact = auditedOfy().load().type(ContactResource.class).first().now();
|
contact = auditedOfy().load().type(ContactResource.class).first().now();
|
||||||
|
|
||||||
// The following value might change if {@link CommitLogRevisionsTranslatorFactory} changes.
|
// The following value might change if {@link CommitLogRevisionsTranslatorFactory} changes.
|
||||||
assertThat(contact.getRevisions().size()).isEqualTo(6);
|
assertThat(contact.getRevisions()).hasSize(6);
|
||||||
|
|
||||||
// Before deleting the unneeded manifests - we have 11 of them (one for the first
|
// Before deleting the unneeded manifests - we have 11 of them (one for the first
|
||||||
// creation, and 10 more for the mutateContacts)
|
// creation, and 10 more for the mutateContacts)
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.batch;
|
package google.registry.batch;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static google.registry.testing.AppEngineExtension.makeRegistrar1;
|
import static google.registry.testing.AppEngineExtension.makeRegistrar1;
|
||||||
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
import static google.registry.testing.DatabaseHelper.loadByEntity;
|
||||||
import static google.registry.testing.DatabaseHelper.persistResource;
|
import static google.registry.testing.DatabaseHelper.persistResource;
|
||||||
|
@ -430,7 +431,7 @@ class SendExpiringCertificateNotificationEmailActionTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableList<RegistrarInfo> results = action.getRegistrarsWithExpiringCertificates();
|
ImmutableList<RegistrarInfo> results = action.getRegistrarsWithExpiringCertificates();
|
||||||
assertThat(results.size()).isEqualTo(numOfRegistrarsWithExpiringCertificates);
|
assertThat(results).hasSize(numOfRegistrarsWithExpiringCertificates);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOfyAndSql
|
@TestOfyAndSql
|
||||||
|
|
|
@ -282,7 +282,7 @@ class Spec11PipelineTest {
|
||||||
ImmutableList.copyOf(
|
ImmutableList.copyOf(
|
||||||
ResourceUtils.readResourceUtf8(this.getClass(), "test_output.txt").split("\n"));
|
ResourceUtils.readResourceUtf8(this.getClass(), "test_output.txt").split("\n"));
|
||||||
ImmutableList<String> resultFileContents = resultFileContents();
|
ImmutableList<String> resultFileContents = resultFileContents();
|
||||||
assertThat(resultFileContents.size()).isEqualTo(expectedFileContents.size());
|
assertThat(resultFileContents).hasSize(expectedFileContents.size());
|
||||||
assertThat(resultFileContents.get(0)).isEqualTo(expectedFileContents.get(0));
|
assertThat(resultFileContents.get(0)).isEqualTo(expectedFileContents.get(0));
|
||||||
assertThat(resultFileContents.subList(1, resultFileContents.size()))
|
assertThat(resultFileContents.subList(1, resultFileContents.size()))
|
||||||
.comparingElementsUsing(
|
.comparingElementsUsing(
|
||||||
|
|
|
@ -302,13 +302,13 @@ public class ReplicateToDatastoreActionTest {
|
||||||
// records.
|
// records.
|
||||||
action.run();
|
action.run();
|
||||||
Truth8.assertThat(ofyTm().transact(() -> ofyTm().loadByKeyIfPresent(bar.key()))).isPresent();
|
Truth8.assertThat(ofyTm().transact(() -> ofyTm().loadByKeyIfPresent(bar.key()))).isPresent();
|
||||||
assertThat(ofyTm().loadAllOf(ReplayGap.class).size()).isEqualTo(30);
|
assertThat(ofyTm().loadAllOf(ReplayGap.class)).hasSize(30);
|
||||||
|
|
||||||
// Verify that we can clean up this many gap records after expiration.
|
// Verify that we can clean up this many gap records after expiration.
|
||||||
fakeClock.advanceBy(Duration.millis(ReplicateToDatastoreAction.MAX_GAP_RETENTION_MILLIS + 1));
|
fakeClock.advanceBy(Duration.millis(ReplicateToDatastoreAction.MAX_GAP_RETENTION_MILLIS + 1));
|
||||||
resetAction();
|
resetAction();
|
||||||
action.run();
|
action.run();
|
||||||
assertThat(ofyTm().loadAllOf(ReplayGap.class).size()).isEqualTo(0);
|
assertThat(ofyTm().loadAllOf(ReplayGap.class)).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -170,7 +170,7 @@ public class BouncyCastleTest {
|
||||||
try (ByteArrayInputStream input = new ByteArrayInputStream(signatureFileData)) {
|
try (ByteArrayInputStream input = new ByteArrayInputStream(signatureFileData)) {
|
||||||
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
||||||
PGPSignatureList sigList = (PGPSignatureList) pgpFact.nextObject();
|
PGPSignatureList sigList = (PGPSignatureList) pgpFact.nextObject();
|
||||||
assertThat(sigList.size()).isEqualTo(1);
|
assertThat(sigList).hasSize(1);
|
||||||
sig = sigList.get(0);
|
sig = sigList.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,8 +212,8 @@ public class BouncyCastleTest {
|
||||||
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
||||||
PGPOnePassSignatureList onePassList = (PGPOnePassSignatureList) pgpFact.nextObject();
|
PGPOnePassSignatureList onePassList = (PGPOnePassSignatureList) pgpFact.nextObject();
|
||||||
PGPSignatureList sigList = (PGPSignatureList) pgpFact.nextObject();
|
PGPSignatureList sigList = (PGPSignatureList) pgpFact.nextObject();
|
||||||
assertThat(onePassList.size()).isEqualTo(1);
|
assertThat(onePassList).hasSize(1);
|
||||||
assertThat(sigList.size()).isEqualTo(1);
|
assertThat(sigList).hasSize(1);
|
||||||
onePass = onePassList.get(0);
|
onePass = onePassList.get(0);
|
||||||
sig = sigList.get(0);
|
sig = sigList.get(0);
|
||||||
}
|
}
|
||||||
|
@ -258,7 +258,7 @@ public class BouncyCastleTest {
|
||||||
try (ByteArrayInputStream input = new ByteArrayInputStream(encryptedData)) {
|
try (ByteArrayInputStream input = new ByteArrayInputStream(encryptedData)) {
|
||||||
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
||||||
PGPEncryptedDataList encDataList = (PGPEncryptedDataList) pgpFact.nextObject();
|
PGPEncryptedDataList encDataList = (PGPEncryptedDataList) pgpFact.nextObject();
|
||||||
assertThat(encDataList.size()).isEqualTo(1);
|
assertThat(encDataList).hasSize(1);
|
||||||
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) encDataList.get(0);
|
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) encDataList.get(0);
|
||||||
assertThat(encData.getKeyID()).isEqualTo(publicKey.getKeyID());
|
assertThat(encData.getKeyID()).isEqualTo(publicKey.getKeyID());
|
||||||
assertThat(encData.getKeyID()).isEqualTo(privateKey.getKeyID());
|
assertThat(encData.getKeyID()).isEqualTo(privateKey.getKeyID());
|
||||||
|
@ -302,7 +302,7 @@ public class BouncyCastleTest {
|
||||||
try (ByteArrayInputStream input = new ByteArrayInputStream(encryptedData)) {
|
try (ByteArrayInputStream input = new ByteArrayInputStream(encryptedData)) {
|
||||||
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
||||||
PGPEncryptedDataList encDataList = (PGPEncryptedDataList) pgpFact.nextObject();
|
PGPEncryptedDataList encDataList = (PGPEncryptedDataList) pgpFact.nextObject();
|
||||||
assertThat(encDataList.size()).isEqualTo(1);
|
assertThat(encDataList).hasSize(1);
|
||||||
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) encDataList.get(0);
|
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) encDataList.get(0);
|
||||||
// Bob loads the private key to which the message is addressed.
|
// Bob loads the private key to which the message is addressed.
|
||||||
PGPPrivateKey privateKey =
|
PGPPrivateKey privateKey =
|
||||||
|
@ -350,7 +350,7 @@ public class BouncyCastleTest {
|
||||||
try (ByteArrayInputStream input = new ByteArrayInputStream(encryptedData)) {
|
try (ByteArrayInputStream input = new ByteArrayInputStream(encryptedData)) {
|
||||||
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
PGPObjectFactory pgpFact = new BcPGPObjectFactory(input);
|
||||||
PGPEncryptedDataList encDataList = (PGPEncryptedDataList) pgpFact.nextObject();
|
PGPEncryptedDataList encDataList = (PGPEncryptedDataList) pgpFact.nextObject();
|
||||||
assertThat(encDataList.size()).isEqualTo(1);
|
assertThat(encDataList).hasSize(1);
|
||||||
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) encDataList.get(0);
|
PGPPublicKeyEncryptedData encData = (PGPPublicKeyEncryptedData) encDataList.get(0);
|
||||||
// Bob loads the private key to which the message is addressed.
|
// Bob loads the private key to which the message is addressed.
|
||||||
PGPPrivateKey privateKey =
|
PGPPrivateKey privateKey =
|
||||||
|
|
|
@ -53,7 +53,7 @@ class JsonResponseTest {
|
||||||
void testSetHeader() {
|
void testSetHeader() {
|
||||||
jsonResponse.setHeader("header", "value");
|
jsonResponse.setHeader("header", "value");
|
||||||
Map<String, Object> headerMap = fakeResponse.getHeaders();
|
Map<String, Object> headerMap = fakeResponse.getHeaders();
|
||||||
assertThat(headerMap.size()).isEqualTo(1);
|
assertThat(headerMap).hasSize(1);
|
||||||
assertThat(headerMap.get("header")).isEqualTo("value");
|
assertThat(headerMap.get("header")).isEqualTo("value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -158,7 +158,7 @@ public class CloudTasksHelper implements Serializable {
|
||||||
*/
|
*/
|
||||||
public void assertTasksEnqueued(String queueName, Collection<TaskMatcher> taskMatchers) {
|
public void assertTasksEnqueued(String queueName, Collection<TaskMatcher> taskMatchers) {
|
||||||
List<Task> tasks = getTestTasksFor(queueName);
|
List<Task> tasks = getTestTasksFor(queueName);
|
||||||
assertThat(tasks.size()).isEqualTo(taskMatchers.size());
|
assertThat(tasks).hasSize(taskMatchers.size());
|
||||||
for (final TaskMatcher taskMatcher : taskMatchers) {
|
for (final TaskMatcher taskMatcher : taskMatchers) {
|
||||||
try {
|
try {
|
||||||
tasks.remove(tasks.stream().filter(taskMatcher).findFirst().get());
|
tasks.remove(tasks.stream().filter(taskMatcher).findFirst().get());
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
package google.registry.tools;
|
package google.registry.tools;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
import static com.google.common.truth.Truth8.assertThat;
|
||||||
import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS;
|
import static google.registry.batch.AsyncTaskEnqueuer.QUEUE_ASYNC_ACTIONS;
|
||||||
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
|
import static google.registry.testing.DatabaseHelper.assertNoBillingEvents;
|
||||||
import static google.registry.testing.DatabaseHelper.createTlds;
|
import static google.registry.testing.DatabaseHelper.createTlds;
|
||||||
|
@ -546,7 +547,7 @@ public final class DomainLockUtilsTest {
|
||||||
assertThat(loadByEntity(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
assertThat(loadByEntity(domain).getStatusValues()).containsNoneIn(REGISTRY_LOCK_STATUSES);
|
||||||
ImmutableList<DomainHistory> historyEntries =
|
ImmutableList<DomainHistory> historyEntries =
|
||||||
getHistoryEntriesOfType(domain, HistoryEntry.Type.DOMAIN_UPDATE, DomainHistory.class);
|
getHistoryEntriesOfType(domain, HistoryEntry.Type.DOMAIN_UPDATE, DomainHistory.class);
|
||||||
assertThat(historyEntries.size()).isEqualTo(2);
|
assertThat(historyEntries).hasSize(2);
|
||||||
historyEntries.forEach(
|
historyEntries.forEach(
|
||||||
entry -> {
|
entry -> {
|
||||||
assertThat(entry.getRequestedByRegistrar()).isEqualTo(!isAdmin);
|
assertThat(entry.getRequestedByRegistrar()).isEqualTo(!isAdmin);
|
||||||
|
|
|
@ -133,7 +133,7 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
||||||
runCommand("--prefix", "ooo", "--number", "100", "--length", "16");
|
runCommand("--prefix", "ooo", "--number", "100", "--length", "16");
|
||||||
// The deterministic string generator makes it too much hassle to assert about each token, so
|
// The deterministic string generator makes it too much hassle to assert about each token, so
|
||||||
// just assert total number.
|
// just assert total number.
|
||||||
assertThat(loadAllOf(AllocationToken.class).size()).isEqualTo(100);
|
assertThat(loadAllOf(AllocationToken.class)).hasSize(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOfyAndSql
|
@TestOfyAndSql
|
||||||
|
@ -200,7 +200,7 @@ class GenerateAllocationTokensCommandTest extends CommandTestCase<GenerateAlloca
|
||||||
Collection<String> sampleTokens = command.stringGenerator.createStrings(13, 100);
|
Collection<String> sampleTokens = command.stringGenerator.createStrings(13, 100);
|
||||||
runCommand("--tokens", Joiner.on(",").join(sampleTokens));
|
runCommand("--tokens", Joiner.on(",").join(sampleTokens));
|
||||||
assertInStdout(Iterables.toArray(sampleTokens, String.class));
|
assertInStdout(Iterables.toArray(sampleTokens, String.class));
|
||||||
assertThat(loadAllOf(AllocationToken.class).size()).isEqualTo(100);
|
assertThat(loadAllOf(AllocationToken.class)).hasSize(100);
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOfyAndSql
|
@TestOfyAndSql
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class CreateSyntheticHistoryEntriesPipelineTest {
|
||||||
Class<? extends HistoryEntry> historyClazz, T resource) {
|
Class<? extends HistoryEntry> historyClazz, T resource) {
|
||||||
ImmutableList<? extends HistoryEntry> historyEntries =
|
ImmutableList<? extends HistoryEntry> historyEntries =
|
||||||
jpaTm().transact(() -> jpaTm().loadAllOf(historyClazz));
|
jpaTm().transact(() -> jpaTm().loadAllOf(historyClazz));
|
||||||
assertThat(historyEntries.size()).isEqualTo(1);
|
assertThat(historyEntries).hasSize(1);
|
||||||
HistoryEntry historyEntry = historyEntries.get(0);
|
HistoryEntry historyEntry = historyEntries.get(0);
|
||||||
assertThat(historyEntry.getType()).isEqualTo(HistoryEntry.Type.SYNTHETIC);
|
assertThat(historyEntry.getType()).isEqualTo(HistoryEntry.Type.SYNTHETIC);
|
||||||
assertThat(historyEntry.getRegistrarId()).isEqualTo("NewRegistrar");
|
assertThat(historyEntry.getRegistrarId()).isEqualTo("NewRegistrar");
|
||||||
|
|
Loading…
Add table
Reference in a new issue