summaryrefslogtreecommitdiff
path: root/core/src/test/java
diff options
context:
space:
mode:
authorSean Owen <srowen@gmail.com>2019-05-14 02:44:57 +0300
committerSean Owen <srowen@gmail.com>2019-05-14 02:44:57 +0300
commitf1683e1f4f670a83c37f6858a7b3db70080e04ae (patch)
tree15388e103075ca3ad384d6845c1606e445e16044 /core/src/test/java
parent39d50c10535192cce7059bfbea3d1f4fffc622b5 (diff)
downloadzxing-f1683e1f4f670a83c37f6858a7b3db70080e04ae.tar.xz
Bump to 3.4.0. Require Java 8. Various code simplifications and plugin / dep updates
Diffstat (limited to 'core/src/test/java')
-rw-r--r--core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java14
-rw-r--r--core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java2
-rw-r--r--core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java16
-rw-r--r--core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java57
4 files changed, 16 insertions, 73 deletions
diff --git a/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java b/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java
index 3e23e44b4..d95dcb856 100644
--- a/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java
+++ b/core/src/test/java/com/google/zxing/multi/qrcode/MultiQRCodeTestCase.java
@@ -19,11 +19,10 @@ package com.google.zxing.multi.qrcode;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.nio.file.Path;
-import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
-import java.util.Map;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.BinaryBitmap;
@@ -62,8 +61,7 @@ public final class MultiQRCodeTestCase extends Assert {
for (Result result : results) {
barcodeContents.add(result.getText());
assertEquals(BarcodeFormat.QR_CODE, result.getBarcodeFormat());
- Map<ResultMetadataType,Object> metadata = result.getResultMetadata();
- assertNotNull(metadata);
+ assertNotNull(result.getResultMetadata());
}
Collection<String> expectedContents = new HashSet<>();
expectedContents.add("You earned the class a 5 MINUTE DANCE PARTY!! Awesome! Way to go! Let's boogie!");
@@ -78,7 +76,7 @@ public final class MultiQRCodeTestCase extends Assert {
Result sa1 = new Result("SA1", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
Result sa2 = new Result("SA2", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
Result sa3 = new Result("SA3", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
- sa1.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (0 << 4) + 2);
+ sa1.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, 2);
sa1.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
sa2.putMetadata(ResultMetadataType.STRUCTURED_APPEND_SEQUENCE, (1 << 4) + 2);
sa2.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
@@ -88,11 +86,7 @@ public final class MultiQRCodeTestCase extends Assert {
Result nsa = new Result("NotSA", new byte[]{}, new ResultPoint[]{}, BarcodeFormat.QR_CODE);
nsa.putMetadata(ResultMetadataType.ERROR_CORRECTION_LEVEL, "L");
- List<Result> inputs = new ArrayList<>();
- inputs.add(sa3);
- inputs.add(sa1);
- inputs.add(nsa);
- inputs.add(sa2);
+ List<Result> inputs = Arrays.asList(sa3, sa1, nsa, sa2);
List<Result> results = QRCodeMultiReader.processStructuredAppend(inputs);
assertNotNull(results);
diff --git a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java
index db95cae15..b0f9b211c 100644
--- a/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java
+++ b/core/src/test/java/com/google/zxing/oned/rss/expanded/RSSExpandedImage2resultTestCase.java
@@ -69,7 +69,7 @@ public final class RSSExpandedImage2resultTestCase extends Assert {
null, null, null, null, null, null,
"001750",
ExpandedProductParsedResult.KILOGRAM,
- "3", null, null, null, new HashMap<String,String>());
+ "3", null, null, null, new HashMap<>());
assertCorrectImage2result("2.png", expected);
}
diff --git a/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java b/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
index d27a22e46..f61b643be 100644
--- a/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
+++ b/core/src/test/java/com/google/zxing/pdf417/PDF417BlackBox4TestCase.java
@@ -40,7 +40,6 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.Comparator;
import java.util.EnumMap;
import java.util.HashMap;
@@ -113,14 +112,7 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
// ignore
}
}
- Collections.sort(results, new Comparator<Result>() {
- @Override
- public int compare(Result arg0, Result arg1) {
- PDF417ResultMetadata resultMetadata = getMeta(arg0);
- PDF417ResultMetadata otherResultMetadata = getMeta(arg1);
- return resultMetadata.getSegmentIndex() - otherResultMetadata.getSegmentIndex();
- }
- });
+ results.sort(Comparator.comparingInt((Result r) -> getMeta(r).getSegmentIndex()));
StringBuilder resultText = new StringBuilder();
String fileId = null;
for (Result result : results) {
@@ -194,11 +186,7 @@ public final class PDF417BlackBox4TestCase extends AbstractBlackBoxTestCase {
for (Path file : getImageFiles()) {
String testImageFileName = file.getFileName().toString();
String fileBaseName = testImageFileName.substring(0, testImageFileName.indexOf('-'));
- List<Path> files = result.get(fileBaseName);
- if (files == null) {
- files = new ArrayList<>();
- result.put(fileBaseName, files);
- }
+ List<Path> files = result.computeIfAbsent(fileBaseName, k -> new ArrayList<>());
files.add(file);
}
return result;
diff --git a/core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java b/core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java
index d6ff4798b..913c7d309 100644
--- a/core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java
+++ b/core/src/test/java/com/google/zxing/qrcode/decoder/DataMaskTestCase.java
@@ -27,82 +27,42 @@ public final class DataMaskTestCase extends Assert {
@Test
public void testMask0() {
- testMaskAcrossDimensions(0, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return (i + j) % 2 == 0;
- }
- });
+ testMaskAcrossDimensions(0, (i, j) -> (i + j) % 2 == 0);
}
@Test
public void testMask1() {
- testMaskAcrossDimensions(1, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return i % 2 == 0;
- }
- });
+ testMaskAcrossDimensions(1, (i, j) -> i % 2 == 0);
}
@Test
public void testMask2() {
- testMaskAcrossDimensions(2, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return j % 3 == 0;
- }
- });
+ testMaskAcrossDimensions(2, (i, j) -> j % 3 == 0);
}
@Test
public void testMask3() {
- testMaskAcrossDimensions(3, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return (i + j) % 3 == 0;
- }
- });
+ testMaskAcrossDimensions(3, (i, j) -> (i + j) % 3 == 0);
}
@Test
public void testMask4() {
- testMaskAcrossDimensions(4, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return (i / 2 + j / 3) % 2 == 0;
- }
- });
+ testMaskAcrossDimensions(4, (i, j) -> (i / 2 + j / 3) % 2 == 0);
}
@Test
public void testMask5() {
- testMaskAcrossDimensions(5, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return (i * j) % 2 + (i * j) % 3 == 0;
- }
- });
+ testMaskAcrossDimensions(5, (i, j) -> (i * j) % 2 + (i * j) % 3 == 0);
}
@Test
public void testMask6() {
- testMaskAcrossDimensions(6, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return ((i * j) % 2 + (i * j) % 3) % 2 == 0;
- }
- });
+ testMaskAcrossDimensions(6, (i, j) -> ((i * j) % 2 + (i * j) % 3) % 2 == 0);
}
@Test
public void testMask7() {
- testMaskAcrossDimensions(7, new MaskCondition() {
- @Override
- public boolean isMasked(int i, int j) {
- return ((i + j) % 2 + (i * j) % 3) % 2 == 0;
- }
- });
+ testMaskAcrossDimensions(7, (i, j) -> ((i + j) % 2 + (i * j) % 3) % 2 == 0);
}
private static void testMaskAcrossDimensions(int reference, MaskCondition condition) {
@@ -126,6 +86,7 @@ public final class DataMaskTestCase extends Assert {
}
}
+ @FunctionalInterface
private interface MaskCondition {
boolean isMasked(int i, int j);
}