### Question:
LogHandler { public static String serviceName(String log) throws NoSuchFieldException { String oneLinelog = log.replaceAll("\\s+", " "); String regex = ".*Using service: ([^\\.\\s]+)\\..*"; if (!oneLinelog.matches(regex)) throw new NoSuchFieldException( "The log does not contain the service name or the format is wrong:\n" + log); Matcher matcher = Pattern.compile(regex).matcher(oneLinelog); matcher.find(); return matcher.group(1); }  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 testServiceName() throws NoSuchFieldException { String service = LogHandler .serviceName("...\nUsing service: MyService.\n bla\n blub"); assertEquals("MyService", service); }
@Test(expected = NoSuchFieldException.class) public void testServiceNameNoName() throws NoSuchFieldException { LogHandler.serviceName("...\nUsing service: .\n bla\n blub"); }
@Test(expected = NoSuchFieldException.class) public void testServiceWrongFormat() throws NoSuchFieldException { LogHandler.serviceName("...\nUsing service = MyService.\n bla\n blub"); }
@Test(expected = NoSuchFieldException.class) public void testServiceWrongFormat2() throws NoSuchFieldException { LogHandler.serviceName("...\nUsing service: MyService \n bla.\n blub"); }