HostName { String execHostName() { String hostname; try { Process process = new ProcessBuilder(HOSTNAME).start(); try (InputStream stream = process.getInputStream(); Scanner s = new Scanner(stream).useDelimiter(START_OF_STRING);) { hostname = s.hasNext() ? s.next().trim() : UNKNOWN; } } catch (IOException hostnameBinaryNotFound) { hostname = UNKNOWN; } return hostname; }  String determineHostName();  }
@Test public void execHostNameShouldNeverReturnNull() throws IOException { String result = new HostName().execHostName(); assertThat(result).isNotNull(); }