### Question:
LogHandler { public static List<URL> getUrls(ToolResults logs) throws NoSuchFieldException, MalformedURLException { List<URL> urls = new ArrayList<URL>(); for (String log : logs.getFields()) { int offset = 20; int indexFrom = log.indexOf("URL of input image: "); if (indexFrom < 0) { offset = 19; indexFrom = log.indexOf("URL of input file: "); } if (indexFrom < 0) throw new NoSuchFieldException( "No input image URL found in log:\n\n" + log); int indexTo = log.indexOf(".\n", indexFrom); if (indexTo < indexFrom) throw new NoSuchFieldException( "Image URL must be bounded by .\\n:\n\n" + log); String origUrl = log.substring(indexFrom + offset, indexTo); try { urls.add(new URL(origUrl)); } catch (MalformedURLException e) { throw new MalformedURLException("URL: " + origUrl); } } return urls; }  static List<URL> getUrls(ToolResults logs); static long getTime(List<String> logs); static boolean hasInputUrl(String log); static boolean isLog(String s); static UrlParts splitUrl(String url); static String serviceName(String log); static String evaluationId(String log);  }### Answer:
@Test public void testGetUrls() throws MalformedURLException, NoSuchFieldException { String log1 = "bla\nURL of input image: http: String log2 = "bla\nURL of input image: http: ToolResults logs = wrap(log1, log2); List<URL> urls = LogHandler.getUrls(logs); assertTrue(urls.size() == 2); assertEquals("http: }
@Test(expected = NoSuchFieldException.class) public void testGetUrlsWrongLog() throws MalformedURLException, NoSuchFieldException { String log1 = "bla\nURL of input image: http: String log2 = "bla\ninput image: http: ToolResults logs = wrap(log1, log2); LogHandler.getUrls(logs); }
@Test(expected = NoSuchFieldException.class) public void testGetUrlsWrongLog2() throws MalformedURLException, NoSuchFieldException { String log1 = "bla\nURL of input image: http: String log2 = "bla\nURL of input image: http: ToolResults logs = wrap(log1, log2); LogHandler.getUrls(logs); }
@Test(expected = MalformedURLException.class) public void testGetUrlsBadUrl() throws MalformedURLException, NoSuchFieldException { String log1 = "bla\nURL of input image: http: String log2 = "bla\nURL of input image: /test.com/test2.txt.\n"; ToolResults logs = wrap(log1, log2); LogHandler.getUrls(logs); }