From a78b9077651416555d6d0ca42810df8a3d4569b3 Mon Sep 17 00:00:00 2001 From: svc-excavator-bot Date: Wed, 12 Feb 2020 05:18:02 +0000 Subject: [PATCH] Excavator: Prefer AssertJ --- .../com/palantir/crypto2/cipher/NoNegativeSeeksTest.java | 4 ++-- .../test/java/com/palantir/crypto2/io/DecryptionTests.java | 4 ++-- .../crypto2/keys/serialization/KeyMaterialsTest.java | 2 +- .../crypto2/hadoop/StandaloneEncryptedFileSystemTest.java | 5 ++--- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/crypto-core/src/test/java/com/palantir/crypto2/cipher/NoNegativeSeeksTest.java b/crypto-core/src/test/java/com/palantir/crypto2/cipher/NoNegativeSeeksTest.java index a54c945ab..ab4ebd4bb 100644 --- a/crypto-core/src/test/java/com/palantir/crypto2/cipher/NoNegativeSeeksTest.java +++ b/crypto-core/src/test/java/com/palantir/crypto2/cipher/NoNegativeSeeksTest.java @@ -16,7 +16,7 @@ package com.palantir.crypto2.cipher; -import static org.junit.Assert.fail; +import static org.assertj.core.api.Assertions.fail; import com.palantir.crypto2.io.DecryptingSeekableInput; import com.palantir.crypto2.keys.KeyMaterial; @@ -50,7 +50,7 @@ public void close() throws IOException {} @Override public void seek(long offset) throws IOException { if (offset < pos) { - fail(); + fail("fail"); } pos = offset; } diff --git a/crypto-core/src/test/java/com/palantir/crypto2/io/DecryptionTests.java b/crypto-core/src/test/java/com/palantir/crypto2/io/DecryptionTests.java index d934e1439..f17b41d2b 100644 --- a/crypto-core/src/test/java/com/palantir/crypto2/io/DecryptionTests.java +++ b/crypto-core/src/test/java/com/palantir/crypto2/io/DecryptionTests.java @@ -90,7 +90,7 @@ public DecryptionTests(TestCase testCase) { @Test public void testDecrypt() throws IOException { - assertThat(cis.getPos()).isEqualTo(0); + assertThat(cis.getPos()).isZero(); byte[] decrypted = new byte[NUM_BYTES]; readFully(cis, decrypted); @@ -143,7 +143,7 @@ private void testSeek(int seekPos) throws IOException { byte[] expected = Arrays.copyOfRange(data, seekPos, NUM_BYTES); - assertThat(decrypted.length).isEqualTo(expected.length); + assertThat(decrypted).hasSize(expected.length); assertThat(decrypted).isEqualTo(expected); } diff --git a/crypto-keys/src/test/java/com/palantir/crypto2/keys/serialization/KeyMaterialsTest.java b/crypto-keys/src/test/java/com/palantir/crypto2/keys/serialization/KeyMaterialsTest.java index 02f907504..e656d27f8 100644 --- a/crypto-keys/src/test/java/com/palantir/crypto2/keys/serialization/KeyMaterialsTest.java +++ b/crypto-keys/src/test/java/com/palantir/crypto2/keys/serialization/KeyMaterialsTest.java @@ -55,7 +55,7 @@ public void testGenerateKey() { @Test public void testGenerateIv() { byte[] iv = KeyMaterials.generateIv(IV_SIZE); - assertThat(iv.length).isEqualTo(IV_SIZE); + assertThat(iv).hasSize(IV_SIZE); } @Test diff --git a/hadoop-crypto/src/test/java/com/palantir/crypto2/hadoop/StandaloneEncryptedFileSystemTest.java b/hadoop-crypto/src/test/java/com/palantir/crypto2/hadoop/StandaloneEncryptedFileSystemTest.java index 54668fae0..538454207 100644 --- a/hadoop-crypto/src/test/java/com/palantir/crypto2/hadoop/StandaloneEncryptedFileSystemTest.java +++ b/hadoop-crypto/src/test/java/com/palantir/crypto2/hadoop/StandaloneEncryptedFileSystemTest.java @@ -18,7 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatExceptionOfType; -import static org.junit.Assert.assertTrue; import com.google.common.io.ByteStreams; import java.io.File; @@ -234,7 +233,7 @@ public void testOnlyPublicKey() throws IOException { assertThat(readData).isNotEqualTo(dataBytes); // KeyMaterial file exists - assertTrue(rawFs.exists(keyMaterialPath(path))); + assertThat(rawFs.exists(keyMaterialPath(path))).isTrue(); // Unable to open files without Private Key assertThatExceptionOfType(IllegalArgumentException.class) @@ -288,7 +287,7 @@ public void testListStatus_keyMaterialFilesFiltered() throws IOException { FileStatus[] fileStatuses = efs.listStatus(path.getParent()); FileStatus expectedStatus = fileStatus[0]; - assertThat(fileStatus.length).isEqualTo(1); + assertThat(fileStatus).hasSize(1); assertThat(fileStatuses).containsExactly(expectedStatus); }