### Question:
MultiLangDaemon { String propertiesFile(final MultiLangDaemonArguments arguments) { String propertiesFile = ""; if (CollectionUtils.isNotEmpty(arguments.parameters)) { if (arguments.parameters.size() == 1) { propertiesFile = arguments.parameters.get(0); } else { throw new RuntimeException( "Expected a single argument, but found multiple arguments. Arguments: " + String.join(", ", arguments.parameters)); } } if (StringUtils.isNotEmpty(arguments.propertiesFile)) { if (StringUtils.isNotEmpty(propertiesFile)) { log.warn("Overriding the properties file with the --properties-file option"); } propertiesFile = arguments.propertiesFile; } if (StringUtils.isEmpty(propertiesFile)) { throw new RuntimeException("Properties file missing, please provide a properties file"); } return propertiesFile; }  static void main(final String[] args);  }### Answer:
@Test public void testNoPropertiesFileArgumentOrOption() { expectedException.expect(RuntimeException.class); expectedException.expectMessage(equalTo("Properties file missing, please provide a properties file")); MultiLangDaemon.MultiLangDaemonArguments arguments = new MultiLangDaemon.MultiLangDaemonArguments(); daemon.propertiesFile(arguments); }
@Test public void testSuccessfulPropertiesArgument() { String expectedPropertiesFile = "/test/properties/file"; MultiLangDaemon.MultiLangDaemonArguments arguments = new MultiLangDaemon.MultiLangDaemonArguments(); arguments.parameters = Collections.singletonList(expectedPropertiesFile); String propertiesFile = daemon.propertiesFile(arguments); assertThat(propertiesFile, equalTo(expectedPropertiesFile)); }
@Test public void testPropertiesOptionsOverrideArgument() { String propertiesArgument = "/test/properties/argument"; String propertiesOptions = "/test/properties/options"; MultiLangDaemon.MultiLangDaemonArguments arguments = new MultiLangDaemon.MultiLangDaemonArguments(); arguments.parameters = Collections.singletonList(propertiesArgument); arguments.propertiesFile = propertiesOptions; String propertiesFile = daemon.propertiesFile(arguments); assertThat(propertiesFile, equalTo(propertiesOptions)); }
@Test public void testExtraArgumentsFailure() { expectedException.expect(RuntimeException.class); expectedException.expectMessage(containsString("Expected a single argument, but found multiple arguments.")); MultiLangDaemon.MultiLangDaemonArguments arguments = new MultiLangDaemon.MultiLangDaemonArguments(); arguments.parameters = Arrays.asList("parameter1", "parameter2"); daemon.propertiesFile(arguments); }