### Question:
LogHandler { public static long getTime(List<String> logs) throws NoSuchFieldException { long totalTime = 0; for (String log : logs) { int index = log.indexOf("Process finished successfully after "); if (index < 0) throw new NoSuchFieldException( "Processing time not found in log:\n\n" + log); String timeLine = log.substring(index, log.lastIndexOf(" ")); String time = timeLine.split(" ")[4]; long timeNumber = 0; try { timeNumber = Long.valueOf(time); } catch (NumberFormatException e) { throw new NoSuchFieldException("Invalid time (" + time + ") in log:\n\n" + log); } totalTime += timeNumber; } return totalTime; }  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 testGetTime() throws NoSuchFieldException { String log1 = "bla\nProcess finished successfully after 1111 milliseconds.."; String log2 = "bla\nProcess finished successfully after 2222 milliseconds.."; List<String> logs = Arrays.asList(new String[] { log1, log2 }); long totalTime = LogHandler.getTime(logs); assertTrue(3333 == totalTime); }
@Test(expected = NoSuchFieldException.class) public void testGetTimeWrongLog() throws NoSuchFieldException { String log1 = "bla\nProcess finished successfully after 1111 milliseconds.."; String log2 = "bla\nsome stuff.."; List<String> logs = Arrays.asList(new String[] { log1, log2 }); LogHandler.getTime(logs); }
@Test(expected = NoSuchFieldException.class) public void testGetTimeNaN() throws NoSuchFieldException { String log1 = "bla\nProcess finished successfully after 1111 milliseconds.."; String log2 = "bla\nProcess finished successfully after abc milliseconds.."; List<String> logs = Arrays.asList(new String[] { log1, log2 }); LogHandler.getTime(logs); }