### Question:
CapabilitiesConfigurationPropertyRetriever { Capabilities getCapabilitiesProperty(String capabilities, ConfigurationProperties globalConfiguration) { String property = readCapabilitiesFromUrl(capabilities); return Optional.ofNullable(createCapabilitiesFromFactory(property, globalConfiguration)) .orElseGet(() -> convertJsonObjectToCapabilities(property)); }    }### Answer:
@Test public void capabilities() { DesiredCapabilities capabilitiesJSEnabled = new DesiredCapabilities(); capabilitiesJSEnabled.setJavascriptEnabled(true); Capabilities capabilities = retriever.getCapabilitiesProperty("{\"javascriptEnabled\": true}", null); assertThat(capabilities).isEqualTo(capabilitiesJSEnabled); }
@Test public void shouldFailExceptionWhenJSONStringCannotBeConverted() { assertThatExceptionOfType(ConfigurationException.class) .isThrownBy(() -> retriever.getCapabilitiesProperty("{\"javascriptEnabled\": true", null)) .withMessage("Can't convert JSON Capabilities to Object."); }
@Test public void desiredCapabilities() { DesiredCapabilities capabilitiesFirefox = DesiredCapabilities.firefox(); Capabilities capabilities = retriever.getCapabilitiesProperty("firefox", null); assertThat(capabilities).isEqualTo(capabilitiesFirefox); }
@Test public void capabilitiesClassName() { Capabilities capabilities = retriever.getCapabilitiesProperty(TestCapabilities.class.getName(), null); assertThat(capabilities).isExactlyInstanceOf(TestCapabilities.class); }
@Test public void capabilitiesFactory() { Capabilities capabilities = retriever.getCapabilitiesProperty("test-capabilities-factory", null); assertThat(capabilities).isExactlyInstanceOf(TestCapabilities.class); }
@Test public void capabilitiesURL() { URL capabilitiesURLJSEnabled = getClass().getResource("/org/fluentlenium/configuration/capabilities.json"); DesiredCapabilities capabilitiesJSEnabled = new DesiredCapabilities(); capabilitiesJSEnabled.setJavascriptEnabled(true); Capabilities capabilities = retriever.getCapabilitiesProperty(capabilitiesURLJSEnabled.toString(), null); assertThat(capabilities).isEqualTo(capabilitiesJSEnabled); }
@Test public void shouldFailWithExceptionWhenURLCannotBeRead() { assertThatExceptionOfType(ConfigurationException.class) .isThrownBy(() -> retriever.getCapabilitiesProperty("https: .withMessage("Can't read Capabilities defined at https: }