public static void readAllResultLines(List<String> target, String resultPath) throws IOException { readAllResultLines(target, resultPath, new String[]{}); }
public static void compareResultsByLinesInMemoryWithStrictOrder(String expectedResultStr, String resultPath, String[] excludePrefixes) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, true); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedResultStr.split("\n"); Assert.assertEquals("Different number of lines in expected and obtained result.", expected.length, result.length); Assert.assertArrayEquals(expected, result); }
public static void compareKeyValuePairsWithDelta(String expectedLines, String resultPath, String[] excludePrefixes, String delimiter, double maxDelta) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, false); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedLines.isEmpty() ? new String[0] : expectedLines.split("\n"); Assert.assertEquals("Wrong number of result lines.", expected.length, result.length); Arrays.sort(result); Arrays.sort(expected); for (int i = 0; i < expected.length; i++) { String[] expectedFields = expected[i].split(delimiter); String[] resultFields = result[i].split(delimiter); double expectedPayLoad = Double.parseDouble(expectedFields[1]); double resultPayLoad = Double.parseDouble(resultFields[1]); Assert.assertTrue("Values differ by more than the permissible delta", Math.abs(expectedPayLoad - resultPayLoad) < maxDelta); } }
public static void checkLinesAgainstRegexp(String resultPath, String regexp){ Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(""); ArrayList<String> list = new ArrayList<>(); try { readAllResultLines(list, resultPath, new String[]{}, false); } catch (IOException e1) { Assert.fail("Error reading the result"); } for (String line : list){ matcher.reset(line); if (!matcher.find()){ String msg = "Line is not well-formed: " + line; Assert.fail(msg); } } }
public static void compareResultsByLinesInMemory( String expectedResultStr, String resultPath, String[] excludePrefixes) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, false); String[] result = list.toArray(new String[list.size()]); Arrays.sort(result); String[] expected = expectedResultStr.isEmpty() ? new String[0] : expectedResultStr.split("\n"); Arrays.sort(expected); if (expected.length != result.length || !Arrays.deepEquals(expected, result)) { String msg = String.format( "Different elements in arrays: expected %d elements and received %d\n" + "files: %s\n expected: %s\n received: %s", expected.length, result.length, Arrays.toString(getAllInvolvedFiles(resultPath, excludePrefixes)), Arrays.toString(expected), Arrays.toString(result)); fail(msg); } }
public static void readAllResultLines( List<String> target, String resultPath, String[] excludePrefixes, boolean inOrderOfFiles) throws IOException { checkArgument(resultPath != null, "resultPath cannot be be null"); final BufferedReader[] readers = getResultReader(resultPath, excludePrefixes, inOrderOfFiles); try { for (BufferedReader reader : readers) { String s; while ((s = reader.readLine()) != null) { target.add(s); } } } finally { for (BufferedReader reader : readers) { org.apache.flink.util.IOUtils.closeQuietly(reader); } } }
public static void readAllResultLines(List<String> target, String resultPath) throws IOException { readAllResultLines(target, resultPath, new String[]{}); }
public static void readAllResultLines(List<String> target, String resultPath) throws IOException { readAllResultLines(target, resultPath, new String[]{}); }
public static void readAllResultLines(List<String> target, String resultPath) throws IOException { readAllResultLines(target, resultPath, new String[]{}); }
public static void readAllResultLines(List<String> target, String resultPath) throws IOException { readAllResultLines(target, resultPath, new String[]{}); }
public static void compareResultsByLinesInMemoryWithStrictOrder(String expectedResultStr, String resultPath, String[] excludePrefixes) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, true); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedResultStr.split("\n"); Assert.assertEquals("Different number of lines in expected and obtained result.", expected.length, result.length); Assert.assertArrayEquals(expected, result); }
public static void compareResultsByLinesInMemoryWithStrictOrder(String expectedResultStr, String resultPath, String[] excludePrefixes) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, true); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedResultStr.split("\n"); Assert.assertEquals("Different number of lines in expected and obtained result.", expected.length, result.length); Assert.assertArrayEquals(expected, result); }
public static void compareResultsByLinesInMemoryWithStrictOrder(String expectedResultStr, String resultPath, String[] excludePrefixes) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, true); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedResultStr.split("\n"); Assert.assertEquals("Different number of lines in expected and obtained result.", expected.length, result.length); Assert.assertArrayEquals(expected, result); }
public static void compareKeyValuePairsWithDelta(String expectedLines, String resultPath, String[] excludePrefixes, String delimiter, double maxDelta) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, false); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedLines.isEmpty() ? new String[0] : expectedLines.split("\n"); Assert.assertEquals("Wrong number of result lines.", expected.length, result.length); Arrays.sort(result); Arrays.sort(expected); for (int i = 0; i < expected.length; i++) { String[] expectedFields = expected[i].split(delimiter); String[] resultFields = result[i].split(delimiter); double expectedPayLoad = Double.parseDouble(expectedFields[1]); double resultPayLoad = Double.parseDouble(resultFields[1]); Assert.assertTrue("Values differ by more than the permissible delta", Math.abs(expectedPayLoad - resultPayLoad) < maxDelta); } }
public static void compareResultsByLinesInMemoryWithStrictOrder(String expectedResultStr, String resultPath, String[] excludePrefixes) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, true); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedResultStr.split("\n"); Assert.assertEquals("Different number of lines in expected and obtained result.", expected.length, result.length); Assert.assertArrayEquals(expected, result); }
public static void compareKeyValuePairsWithDelta(String expectedLines, String resultPath, String[] excludePrefixes, String delimiter, double maxDelta) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, false); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedLines.isEmpty() ? new String[0] : expectedLines.split("\n"); Assert.assertEquals("Wrong number of result lines.", expected.length, result.length); Arrays.sort(result); Arrays.sort(expected); for (int i = 0; i < expected.length; i++) { String[] expectedFields = expected[i].split(delimiter); String[] resultFields = result[i].split(delimiter); double expectedPayLoad = Double.parseDouble(expectedFields[1]); double resultPayLoad = Double.parseDouble(resultFields[1]); Assert.assertTrue("Values differ by more than the permissible delta", Math.abs(expectedPayLoad - resultPayLoad) < maxDelta); } }
public static void compareKeyValuePairsWithDelta(String expectedLines, String resultPath, String[] excludePrefixes, String delimiter, double maxDelta) throws Exception { ArrayList<String> list = new ArrayList<>(); readAllResultLines(list, resultPath, excludePrefixes, false); String[] result = list.toArray(new String[list.size()]); String[] expected = expectedLines.isEmpty() ? new String[0] : expectedLines.split("\n"); Assert.assertEquals("Wrong number of result lines.", expected.length, result.length); Arrays.sort(result); Arrays.sort(expected); for (int i = 0; i < expected.length; i++) { String[] expectedFields = expected[i].split(delimiter); String[] resultFields = result[i].split(delimiter); double expectedPayLoad = Double.parseDouble(expectedFields[1]); double resultPayLoad = Double.parseDouble(resultFields[1]); Assert.assertTrue("Values differ by more than the permissible delta", Math.abs(expectedPayLoad - resultPayLoad) < maxDelta); } }
public static void checkLinesAgainstRegexp(String resultPath, String regexp){ Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(""); ArrayList<String> list = new ArrayList<>(); try { readAllResultLines(list, resultPath, new String[]{}, false); } catch (IOException e1) { Assert.fail("Error reading the result"); } for (String line : list){ matcher.reset(line); if (!matcher.find()){ String msg = "Line is not well-formed: " + line; Assert.fail(msg); } } }
public static void checkLinesAgainstRegexp(String resultPath, String regexp){ Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(""); ArrayList<String> list = new ArrayList<>(); try { readAllResultLines(list, resultPath, new String[]{}, false); } catch (IOException e1) { Assert.fail("Error reading the result"); } for (String line : list){ matcher.reset(line); if (!matcher.find()){ String msg = "Line is not well-formed: " + line; Assert.fail(msg); } } }
public static void checkLinesAgainstRegexp(String resultPath, String regexp){ Pattern pattern = Pattern.compile(regexp); Matcher matcher = pattern.matcher(""); ArrayList<String> list = new ArrayList<>(); try { readAllResultLines(list, resultPath, new String[]{}, false); } catch (IOException e1) { Assert.fail("Error reading the result"); } for (String line : list){ matcher.reset(line); if (!matcher.find()){ String msg = "Line is not well-formed: " + line; Assert.fail(msg); } } }