@Test(description = "Test printing search results table for different terminal widths", dataProvider = "searchResultsWithTerminalWidth") public void testPrintModules(ArrayValue modules, String terminalWidth, String outputFile) throws IOException { printModules(modules, terminalWidth); Path outputFilePath = Paths.get("src", "test", "resources", "test-resources", "search", outputFile); String expectedOutput = new String(Files.readAllBytes(outputFilePath), StandardCharsets.UTF_8); if (!(outContent.toString().contains(expectedOutput))) { errStream.println("expected output not contains in output stream"); errStream.println("expected output:\n" + expectedOutput); errStream.println("print stream:" + outContent.toString()); Assert.fail(); } }
public static void printModules(ArrayValue modules, String terminalWidth) { int rightMargin = 3; int width = Integer.parseInt(terminalWidth) - rightMargin; int dateColWidth = 15; int versionColWidth = 8; int authorsColWidth = 15; double nameColFactor = 9.0; double descColFactor = 16.0; int additionalSpace = 7; double remainingWidth = (double) width - (dateColWidth + versionColWidth + additionalSpace); int nameColWidth = (int) Math.round(remainingWidth * (nameColFactor / (nameColFactor + descColFactor))); int descColWidth = (int) Math.round(remainingWidth * (descColFactor / (nameColFactor + descColFactor))); int minDescColWidth = 60; printTitle(); printTableHeader(dateColWidth, versionColWidth, nameColWidth, descColWidth, minDescColWidth, authorsColWidth); int i = 0; while (i < modules.size()) { printModule((MapValue) modules.get(i), dateColWidth, versionColWidth, authorsColWidth, nameColWidth, descColWidth, minDescColWidth); i = i + 1; outStream.println(); } outStream.println(); outStream.println(modules.size() + " modules found"); }
Search { public static void printModules(ArrayValue modules, String terminalWidth) { int rightMargin = 3; int width = Integer.parseInt(terminalWidth) - rightMargin; int dateColWidth = 15; int versionColWidth = 8; int authorsColWidth = 15; double nameColFactor = 9.0; double descColFactor = 16.0; int additionalSpace = 7; double remainingWidth = (double) width - (dateColWidth + versionColWidth + additionalSpace); int nameColWidth = (int) Math.round(remainingWidth * (nameColFactor / (nameColFactor + descColFactor))); int descColWidth = (int) Math.round(remainingWidth * (descColFactor / (nameColFactor + descColFactor))); int minDescColWidth = 60; printTitle(); printTableHeader(dateColWidth, versionColWidth, nameColWidth, descColWidth, minDescColWidth, authorsColWidth); int i = 0; while (i < modules.size()) { printModule((MapValue) modules.get(i), dateColWidth, versionColWidth, authorsColWidth, nameColWidth, descColWidth, minDescColWidth); i = i + 1; outStream.println(); } outStream.println(); outStream.println(modules.size() + " modules found"); } }
Search { public static void printModules(ArrayValue modules, String terminalWidth) { int rightMargin = 3; int width = Integer.parseInt(terminalWidth) - rightMargin; int dateColWidth = 15; int versionColWidth = 8; int authorsColWidth = 15; double nameColFactor = 9.0; double descColFactor = 16.0; int additionalSpace = 7; double remainingWidth = (double) width - (dateColWidth + versionColWidth + additionalSpace); int nameColWidth = (int) Math.round(remainingWidth * (nameColFactor / (nameColFactor + descColFactor))); int descColWidth = (int) Math.round(remainingWidth * (descColFactor / (nameColFactor + descColFactor))); int minDescColWidth = 60; printTitle(); printTableHeader(dateColWidth, versionColWidth, nameColWidth, descColWidth, minDescColWidth, authorsColWidth); int i = 0; while (i < modules.size()) { printModule((MapValue) modules.get(i), dateColWidth, versionColWidth, authorsColWidth, nameColWidth, descColWidth, minDescColWidth); i = i + 1; outStream.println(); } outStream.println(); outStream.println(modules.size() + " modules found"); } private  Search(); }
Search { public static void printModules(ArrayValue modules, String terminalWidth) { int rightMargin = 3; int width = Integer.parseInt(terminalWidth) - rightMargin; int dateColWidth = 15; int versionColWidth = 8; int authorsColWidth = 15; double nameColFactor = 9.0; double descColFactor = 16.0; int additionalSpace = 7; double remainingWidth = (double) width - (dateColWidth + versionColWidth + additionalSpace); int nameColWidth = (int) Math.round(remainingWidth * (nameColFactor / (nameColFactor + descColFactor))); int descColWidth = (int) Math.round(remainingWidth * (descColFactor / (nameColFactor + descColFactor))); int minDescColWidth = 60; printTitle(); printTableHeader(dateColWidth, versionColWidth, nameColWidth, descColWidth, minDescColWidth, authorsColWidth); int i = 0; while (i < modules.size()) { printModule((MapValue) modules.get(i), dateColWidth, versionColWidth, authorsColWidth, nameColWidth, descColWidth, minDescColWidth); i = i + 1; outStream.println(); } outStream.println(); outStream.println(modules.size() + " modules found"); } private  Search(); static void execute(String url, String proxyHost, int proxyPort, String proxyUsername, String proxyPassword,
            String terminalWidth); static void printModules(ArrayValue modules, String terminalWidth); }
Search { public static void printModules(ArrayValue modules, String terminalWidth) { int rightMargin = 3; int width = Integer.parseInt(terminalWidth) - rightMargin; int dateColWidth = 15; int versionColWidth = 8; int authorsColWidth = 15; double nameColFactor = 9.0; double descColFactor = 16.0; int additionalSpace = 7; double remainingWidth = (double) width - (dateColWidth + versionColWidth + additionalSpace); int nameColWidth = (int) Math.round(remainingWidth * (nameColFactor / (nameColFactor + descColFactor))); int descColWidth = (int) Math.round(remainingWidth * (descColFactor / (nameColFactor + descColFactor))); int minDescColWidth = 60; printTitle(); printTableHeader(dateColWidth, versionColWidth, nameColWidth, descColWidth, minDescColWidth, authorsColWidth); int i = 0; while (i < modules.size()) { printModule((MapValue) modules.get(i), dateColWidth, versionColWidth, authorsColWidth, nameColWidth, descColWidth, minDescColWidth); i = i + 1; outStream.println(); } outStream.println(); outStream.println(modules.size() + " modules found"); } private  Search(); static void execute(String url, String proxyHost, int proxyPort, String proxyUsername, String proxyPassword,
            String terminalWidth); static void printModules(ArrayValue modules, String terminalWidth);  }