This is an automated email from the ASF dual-hosted git repository. kinow pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-imaging.git
commit 5259f0fadd4341d144db26fc9c5910b166a2d72b Author: Arturo Bernal <[email protected]> AuthorDate: Wed Apr 21 11:26:52 2021 +0200 [IMAGING-288] Java 8 improvements: * Use method reference * Replace statement with lambda * Use Map.computeIfAbsent * Use map.merge --- .../commons/imaging/formats/tiff/TiffTags.java | 13 ++----------- .../imaging/common/bytesource/ByteSourceTest.java | 4 +--- .../imaging/formats/bmp/BmpImageParserTest.java | 4 +--- .../commons/imaging/formats/bmp/BmpReadTest.java | 4 +--- .../commons/imaging/formats/dcx/DcxReadTest.java | 4 +--- .../commons/imaging/formats/gif/GifReadTest.java | 4 +--- .../commons/imaging/formats/icns/IcnsReadTest.java | 4 +--- .../commons/imaging/formats/ico/IcoReadTest.java | 8 ++------ .../formats/jpeg/JpegWithInvalidDhtSegmentTest.java | 4 +--- .../formats/jpeg/decoder/JpegDecoderTest.java | 4 +--- .../formats/jpeg/decoder/JpegInputStreamTest.java | 8 ++------ .../formats/png/PngWithInvalidPngChunkSizeTest.java | 8 ++------ .../imaging/formats/png/chunks/PngChunkIccpTest.java | 8 ++------ .../imaging/formats/png/chunks/PngChunkScalTest.java | 20 +++++--------------- .../commons/imaging/formats/pnm/PgmFileInfoTest.java | 8 ++------ .../imaging/formats/pnm/PnmImageParserTest.java | 12 +++--------- .../commons/imaging/formats/pnm/PpmFileInfoTest.java | 8 ++------ .../commons/imaging/formats/rgbe/RgbeReadTest.java | 4 +--- .../formats/tiff/fieldtypes/FieldTypeAsciiTest.java | 4 +--- .../formats/tiff/fieldtypes/FieldTypeByteTest.java | 4 +--- .../tiff/fieldtypes/FieldTypeRationalTest.java | 4 +--- .../PhotometricInterpreterLogLuvTest.java | 8 ++------ 22 files changed, 36 insertions(+), 113 deletions(-) diff --git a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffTags.java b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffTags.java index 53f4226..4901433 100644 --- a/src/main/java/org/apache/commons/imaging/formats/tiff/TiffTags.java +++ b/src/main/java/org/apache/commons/imaging/formats/tiff/TiffTags.java @@ -84,11 +84,7 @@ final class TiffTags { final Map<Integer, List<TagInfo>> map = new HashMap<>(); for (final TagInfo tag : tags) { - List<TagInfo> tagList = map.get(tag.tag); - if (tagList == null) { - tagList = new ArrayList<>(); - map.put(tag.tag, tagList); - } + List<TagInfo> tagList = map.computeIfAbsent(tag.tag, k -> new ArrayList<>()); tagList.add(tag); } @@ -99,12 +95,7 @@ final class TiffTags { final Map<Integer, Integer> map = new HashMap<>(); for (final TagInfo tag : tags) { - final Integer count = map.get(tag.tag); - if (count == null) { - map.put(tag.tag, 1); - } else { - map.put(tag.tag, count + 1); - } + map.merge(tag.tag, 1, Integer::sum); } return map; diff --git a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java index 84c906a..d88af1d 100644 --- a/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java +++ b/src/test/java/org/apache/commons/imaging/common/bytesource/ByteSourceTest.java @@ -73,9 +73,7 @@ public abstract class ByteSourceTest extends ImagingTest { public void testGetInputStreamThrowsNullPointerException() { final ByteSourceArray byteSourceArray = new ByteSourceArray(null); - Assertions.assertThrows(NullPointerException.class, () -> { - byteSourceArray.getInputStream(0L); - }); + Assertions.assertThrows(NullPointerException.class, () -> byteSourceArray.getInputStream(0L)); } } \ No newline at end of file diff --git a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java index d3dc7e3..4a371bc 100644 --- a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpImageParserTest.java @@ -57,8 +57,6 @@ public class BmpImageParserTest { final String file = "/images/bmp/IMAGING-279/negative_array_size_exception.bmp"; final File bmp = new File(BmpImageParser.class.getResource(file).getFile()); final BmpImageParser parser = new BmpImageParser(); - assertThrows(IOException.class, () -> { - parser.getImageInfo(bmp, Collections.emptyMap()); - }); + assertThrows(IOException.class, () -> parser.getImageInfo(bmp, Collections.emptyMap())); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java index a0fb51f..8968af2 100644 --- a/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/bmp/BmpReadTest.java @@ -55,9 +55,7 @@ public class BmpReadTest extends BmpBaseTest { @ParameterizedTest @MethodSource("data") public void testMetaData(final File imageFile) { - Assertions.assertThrows(UnsupportedOperationException.class, () -> { - Imaging.getMetadata(imageFile); - }); + Assertions.assertThrows(UnsupportedOperationException.class, () -> Imaging.getMetadata(imageFile)); } @ParameterizedTest diff --git a/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java b/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java index 195ac6c..f7d2485 100644 --- a/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/dcx/DcxReadTest.java @@ -40,9 +40,7 @@ public class DcxReadTest extends DcxBaseTest { @ParameterizedTest @MethodSource("data") public void testImageMetadata(final File imageFile) { - Assertions.assertThrows(UnsupportedOperationException.class, () -> { - Imaging.getMetadata(imageFile); - }); + Assertions.assertThrows(UnsupportedOperationException.class, () -> Imaging.getMetadata(imageFile)); } @Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException") diff --git a/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java b/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java index ae46679..9f41a6e 100644 --- a/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/gif/GifReadTest.java @@ -53,9 +53,7 @@ public class GifReadTest extends GifBaseTest { @ParameterizedTest @MethodSource("data") public void testMetadata(final File imageFile) { - Assertions.assertThrows(UnsupportedOperationException.class, () -> { - Imaging.getMetadata(imageFile); - }); + Assertions.assertThrows(UnsupportedOperationException.class, () -> Imaging.getMetadata(imageFile)); } @ParameterizedTest diff --git a/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java b/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java index bc50441..1730cfb 100644 --- a/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/icns/IcnsReadTest.java @@ -64,9 +64,7 @@ public class IcnsReadTest extends IcnsBaseTest { @ParameterizedTest @MethodSource("data") public void testImageMetadata(final File imageFile) { - Assertions.assertThrows(UnsupportedOperationException.class, () -> { - Imaging.getMetadata(imageFile); - }); + Assertions.assertThrows(UnsupportedOperationException.class, () -> Imaging.getMetadata(imageFile)); } @ParameterizedTest diff --git a/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java b/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java index b409432..a4590ec 100644 --- a/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/ico/IcoReadTest.java @@ -40,18 +40,14 @@ public class IcoReadTest extends IcoBaseTest { @ParameterizedTest @MethodSource("data") public void testMetadata(final File imageFile) { - Assertions.assertThrows(UnsupportedOperationException.class, () -> { - Imaging.getMetadata(imageFile); - }); + Assertions.assertThrows(UnsupportedOperationException.class, () -> Imaging.getMetadata(imageFile)); } @Disabled(value = "RoundtripTest has to be fixed before implementation can throw UnsupportedOperationException") @ParameterizedTest @MethodSource("data") public void testImageInfo(final File imageFile) { - Assertions.assertThrows(UnsupportedOperationException.class, () -> { - Imaging.getImageInfo(imageFile, Collections.emptyMap()); - }); + Assertions.assertThrows(UnsupportedOperationException.class, () -> Imaging.getImageInfo(imageFile, Collections.emptyMap())); } @ParameterizedTest diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegWithInvalidDhtSegmentTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegWithInvalidDhtSegmentTest.java index ac255c6..b0cd416 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegWithInvalidDhtSegmentTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/JpegWithInvalidDhtSegmentTest.java @@ -38,8 +38,6 @@ public class JpegWithInvalidDhtSegmentTest { final File imageFile = new File(JpegWithInvalidDhtSegmentTest.class .getResource("/IMAGING-215/ArrayIndexOutOfBoundsException_DhtSegment_79.jpeg") .getFile()); - Assertions.assertThrows(ImageReadException.class, () -> { - Imaging.getMetadata(imageFile, Collections.emptyMap()); - }); + Assertions.assertThrows(ImageReadException.class, () -> Imaging.getMetadata(imageFile, Collections.emptyMap())); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoderTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoderTest.java index 7d6795d..17ce4ff 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoderTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegDecoderTest.java @@ -39,8 +39,6 @@ public class JpegDecoderTest { JpegDecoderTest.class.getResource("/IMAGING-220/timeout-48eb4251935b4ca8b26d1859ea525c1b42ae0c78.jpeg") .getFile()); final ByteSourceFile byteSourceFile = new ByteSourceFile(inputFile); - Assertions.assertThrows(ImageReadException.class, () -> { - new JpegDecoder().decode(byteSourceFile); - }); + Assertions.assertThrows(ImageReadException.class, () -> new JpegDecoder().decode(byteSourceFile)); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java b/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java index 509fcc5..6598b40 100644 --- a/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/jpeg/decoder/JpegInputStreamTest.java @@ -33,9 +33,7 @@ public class JpegInputStreamTest { byteArray[1] = (byte) 74; final JpegInputStream jpegInputStream = new JpegInputStream(byteArray); - Assertions.assertThrows(ImageReadException.class, () -> { - jpegInputStream.nextBit(); - }); + Assertions.assertThrows(ImageReadException.class, jpegInputStream::nextBit); } @@ -44,9 +42,7 @@ public class JpegInputStreamTest { final int[] byteArray = new int[0]; final JpegInputStream jpegInputStream = new JpegInputStream(byteArray); - Assertions.assertThrows(IllegalStateException.class, () -> { - jpegInputStream.nextBit(); - }); + Assertions.assertThrows(IllegalStateException.class, jpegInputStream::nextBit); } diff --git a/src/test/java/org/apache/commons/imaging/formats/png/PngWithInvalidPngChunkSizeTest.java b/src/test/java/org/apache/commons/imaging/formats/png/PngWithInvalidPngChunkSizeTest.java index 0139313..f59c478 100644 --- a/src/test/java/org/apache/commons/imaging/formats/png/PngWithInvalidPngChunkSizeTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/png/PngWithInvalidPngChunkSizeTest.java @@ -44,9 +44,7 @@ public class PngWithInvalidPngChunkSizeTest { JpegWithInvalidDhtSegmentTest.class.getResource("/IMAGING-211/testfile_2.png").getFile()); final Map<String, Object> params = new HashMap<>(); params.put(ImagingConstants.BUFFERED_IMAGE_FACTORY, new ManagedImageBufferedImageFactory()); - Assertions.assertThrows(ImageReadException.class, () -> { - Imaging.getBufferedImage(imageFile, params); - }); + Assertions.assertThrows(ImageReadException.class, () -> Imaging.getBufferedImage(imageFile, params)); } /** @@ -59,8 +57,6 @@ public class PngWithInvalidPngChunkSizeTest { JpegWithInvalidDhtSegmentTest.class.getResource("/IMAGING-210/testfile.png").getFile()); final Map<String, Object> params = new HashMap<>(); params.put(ImagingConstants.BUFFERED_IMAGE_FACTORY, new ManagedImageBufferedImageFactory()); - Assertions.assertThrows(ImageReadException.class, () -> { - Imaging.getBufferedImage(imageFile, params); - }); + Assertions.assertThrows(ImageReadException.class, () -> Imaging.getBufferedImage(imageFile, params)); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java index 09c748b..85a1568 100644 --- a/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkIccpTest.java @@ -42,9 +42,7 @@ public class PngChunkIccpTest { @Test public void testErrorOnNoProfileName() { final byte[] data = ImagingConstants.EMPTY_BYTE_ARRAY; - Assertions.assertThrows(ImageReadException.class, () -> { - new PngChunkIccp(0, chunkType, 0, data); - }); + Assertions.assertThrows(ImageReadException.class, () -> new PngChunkIccp(0, chunkType, 0, data)); } @Test @@ -76,9 +74,7 @@ public class PngChunkIccpTest { data[i] = bytes.get(i).byteValue(); } // gather the compressed data - IntStream.range(0, compressedData.length).forEach(i -> { - data[bytes.size() + i] = compressedData[i]; - }); + IntStream.range(0, compressedData.length).forEach(i -> data[bytes.size() + i] = compressedData[i]); // create the chunk final PngChunkIccp chunk = new PngChunkIccp(data.length, chunkType, 0, data); assertArrayEquals(uncompressedData, chunk.getUncompressedProfile()); diff --git a/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkScalTest.java b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkScalTest.java index f67242d..639477c 100644 --- a/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkScalTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/png/chunks/PngChunkScalTest.java @@ -48,36 +48,26 @@ public class PngChunkScalTest { @Test public void testConstruct_InvalidUnitSpecifier() { - Assertions.assertThrows(ImageReadException.class,() -> { - new PngChunkScal(10, chunkType, 0, new byte[]{3, 48, 46, 48, 49, 0, 48, 46, 48, 50}); - }); + Assertions.assertThrows(ImageReadException.class,() -> new PngChunkScal(10, chunkType, 0, new byte[]{3, 48, 46, 48, 49, 0, 48, 46, 48, 50})); } @Test public void testConstruct_MissingSeparator() { - Assertions.assertThrows(ImageReadException.class,() -> { - new PngChunkScal(9, chunkType, 0, new byte[]{1, 48, 46, 48, 49, 48, 46, 48, 50}); - }); + Assertions.assertThrows(ImageReadException.class,() -> new PngChunkScal(9, chunkType, 0, new byte[]{1, 48, 46, 48, 49, 48, 46, 48, 50})); } @Test public void testConstruct_InvalidDblValue() { - Assertions.assertThrows(ImageReadException.class,() -> { - new PngChunkScal(10, chunkType, 0, new byte[]{2, 65, 46, 48, 49, 0, 48, 46, 48, 50}); - }); + Assertions.assertThrows(ImageReadException.class,() -> new PngChunkScal(10, chunkType, 0, new byte[]{2, 65, 46, 48, 49, 0, 48, 46, 48, 50})); } @Test public void testConstruct_MissingXValue() { - Assertions.assertThrows(ImageReadException.class,() -> { - new PngChunkScal(2, chunkType, 0, new byte[]{2, 0}); - }); + Assertions.assertThrows(ImageReadException.class,() -> new PngChunkScal(2, chunkType, 0, new byte[]{2, 0})); } @Test public void testConstruct_MissingYValue() { - Assertions.assertThrows(ImageReadException.class,() -> { - new PngChunkScal(6, chunkType, 0, new byte[]{2, 48, 46, 48, 49, 0}); - }); + Assertions.assertThrows(ImageReadException.class,() -> new PngChunkScal(6, chunkType, 0, new byte[]{2, 48, 46, 48, 49, 0})); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java b/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java index a624b50..d0d7592 100644 --- a/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/pnm/PgmFileInfoTest.java @@ -26,16 +26,12 @@ public class PgmFileInfoTest { @Test public void testCreateThrowsImageReadExceptionOne() { - Assertions.assertThrows(ImageReadException.class, () -> { - new PgmFileInfo(16711680, 16711680, false, 16711680); - }); + Assertions.assertThrows(ImageReadException.class, () -> new PgmFileInfo(16711680, 16711680, false, 16711680)); } @Test public void testCreateThrowsImageReadExceptionTwo() { - Assertions.assertThrows(ImageReadException.class, () -> { - new PgmFileInfo(0, 0, true, 0); - }); + Assertions.assertThrows(ImageReadException.class, () -> new PgmFileInfo(0, 0, true, 0)); } @Test diff --git a/src/test/java/org/apache/commons/imaging/formats/pnm/PnmImageParserTest.java b/src/test/java/org/apache/commons/imaging/formats/pnm/PnmImageParserTest.java index 7f7af48..6d7d638 100644 --- a/src/test/java/org/apache/commons/imaging/formats/pnm/PnmImageParserTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/pnm/PnmImageParserTest.java @@ -86,9 +86,7 @@ public class PnmImageParserTest { final byte[] bytes = "P1\na 2\n0 0 0 0 0 0 0 0 0 0 0\n1 1 1 1 1 1 1 1 1 1 1\n".getBytes(US_ASCII); final Map<String, Object> params = Collections.emptyMap(); final PnmImageParser underTest = new PnmImageParser(); - Assertions.assertThrows(ImageReadException.class, () -> { - underTest.getImageInfo(bytes, params); - }); + Assertions.assertThrows(ImageReadException.class, () -> underTest.getImageInfo(bytes, params)); } @Test @@ -96,9 +94,7 @@ public class PnmImageParserTest { final byte[] bytes = "P1\n2 a\n0 0\n0 0\n0 0\n0 0\n0 0\n0 1\n1 1\n1 1\n1 1\n1 1\n1 1\n".getBytes(US_ASCII); final Map<String, Object> params = Collections.emptyMap(); final PnmImageParser underTest = new PnmImageParser(); - Assertions.assertThrows(ImageReadException.class, () -> { - underTest.getImageInfo(bytes, params); - }); + Assertions.assertThrows(ImageReadException.class, () -> underTest.getImageInfo(bytes, params)); } @Test @@ -106,8 +102,6 @@ public class PnmImageParserTest { final byte[] bytes = "P7\nWIDTH \n".getBytes(US_ASCII); final Map<String, Object> params = Collections.emptyMap(); final PnmImageParser underTest = new PnmImageParser(); - Assertions.assertThrows(ImageReadException.class, () -> { - underTest.getImageInfo(bytes, params); - }); + Assertions.assertThrows(ImageReadException.class, () -> underTest.getImageInfo(bytes, params)); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/pnm/PpmFileInfoTest.java b/src/test/java/org/apache/commons/imaging/formats/pnm/PpmFileInfoTest.java index 73d0301..efcf199 100644 --- a/src/test/java/org/apache/commons/imaging/formats/pnm/PpmFileInfoTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/pnm/PpmFileInfoTest.java @@ -29,16 +29,12 @@ public class PpmFileInfoTest { @Test public void testCreatesPpmFileInfoOne() { - Assertions.assertThrows(ImageReadException.class, () -> { - new PpmFileInfo(0, 0, false, 16711680); - }); + Assertions.assertThrows(ImageReadException.class, () -> new PpmFileInfo(0, 0, false, 16711680)); } @Test public void testCreatesPpmFileInfoThree() { - Assertions.assertThrows(ImageReadException.class, () -> { - new PpmFileInfo(0, 0, true, 0); - }); + Assertions.assertThrows(ImageReadException.class, () -> new PpmFileInfo(0, 0, true, 0)); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeReadTest.java b/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeReadTest.java index 7495a75..cbe05b7 100644 --- a/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeReadTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/rgbe/RgbeReadTest.java @@ -68,8 +68,6 @@ public class RgbeReadTest extends RgbeBaseTest { .getFile()); final ByteSourceFile byteSourceFile = new ByteSourceFile(inputFile); final Map<String, Object> params = Collections.emptyMap(); - Assertions.assertThrows(ImageReadException.class, () -> { - new RgbeImageParser().getBufferedImage(byteSourceFile, params); - }); + Assertions.assertThrows(ImageReadException.class, () -> new RgbeImageParser().getBufferedImage(byteSourceFile, params)); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java index f45203e..213d40e 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeAsciiTest.java @@ -39,9 +39,7 @@ public class FieldTypeAsciiTest { final ByteOrder byteOrder = ByteOrder.BIG_ENDIAN; final TiffField tiffField = new TiffField(0, 0, fieldTypeAscii, 0L, 0, byteArray, byteOrder, 1); - Assertions.assertThrows(ImageWriteException.class, () -> { - fieldTypeAscii.writeData(tiffField, byteOrder); - }); + Assertions.assertThrows(ImageWriteException.class, () -> fieldTypeAscii.writeData(tiffField, byteOrder)); } @Test diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java index cf220af..968f7ec 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeByteTest.java @@ -29,9 +29,7 @@ public class FieldTypeByteTest{ final FieldTypeByte fieldTypeByte = FieldType.UNDEFINED; final ByteOrder byteOrder = ByteOrder.BIG_ENDIAN; - Assertions.assertThrows(ImageWriteException.class, () -> { - fieldTypeByte.writeData( null, byteOrder); - }); + Assertions.assertThrows(ImageWriteException.class, () -> fieldTypeByte.writeData( null, byteOrder)); } } \ No newline at end of file diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java index d6ad22f..2bb4b17 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/fieldtypes/FieldTypeRationalTest.java @@ -44,9 +44,7 @@ public class FieldTypeRationalTest { public void testWriteDataWithNonNull() { final FieldTypeRational fieldTypeRational = new FieldTypeRational((-922), "z_AX"); final ByteOrder byteOrder = ByteOrder.nativeOrder(); - Assertions.assertThrows(ImageWriteException.class, () -> { - fieldTypeRational.writeData("z_AX", byteOrder); - }); + Assertions.assertThrows(ImageWriteException.class, () -> fieldTypeRational.writeData("z_AX", byteOrder)); } } diff --git a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java index 76f51a7..73ade22 100644 --- a/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java +++ b/src/test/java/org/apache/commons/imaging/formats/tiff/photometricinterpreters/PhotometricInterpreterLogLuvTest.java @@ -90,16 +90,12 @@ public class PhotometricInterpreterLogLuvTest { @Test public void testInterpretPixelNullSamples() { - Assertions.assertThrows(ImageReadException.class, () -> { - p.interpretPixel(null, null, 0, 0); - }); + Assertions.assertThrows(ImageReadException.class, () -> p.interpretPixel(null, null, 0, 0)); } @Test public void testInterpretPixelEmptySamples() { - Assertions.assertThrows(ImageReadException.class, () -> { - p.interpretPixel(null, new int[] {}, 0, 0); - }); + Assertions.assertThrows(ImageReadException.class, () -> p.interpretPixel(null, new int[] {}, 0, 0)); } @Test
