### Question:
YamlApplicationsProvider { public static YamlApplicationsProvider loadFromPath(String path) { return new YamlApplicationsProvider(newResource(path)); } private  YamlApplicationsProvider(String yamlText);  YamlApplicationsProvider(Resource resource); static YamlApplicationsProvider loadFromPath(String path); static YamlApplicationsProvider loadFromText(String yamlText); static BackendServices loadApplicationsFrom(String path); BackendServices get();  }### Answer:
@Test public void stickySessionIsDisabledByDefault() { YamlApplicationsProvider config = loadFromPath("classpath:conf/origins/origins-for-configtest.yml"); BackendService app = applicationFor(config, "shopping"); assertThat(app.stickySessionConfig().stickySessionEnabled(), CoreMatchers.is(false)); }
@Test public void stickySessionEnabledWhenYamlStickySessionEnabledIsTrue() { YamlApplicationsProvider config = loadFromPath("classpath:conf/origins/origins-for-configtest.yml"); BackendService app = applicationFor(config, "webapp"); assertThat(app.stickySessionConfig().stickySessionEnabled(), CoreMatchers.is(true)); }
@Test public void cannotLoadWithNoApplications() throws IOException { Exception e = assertThrows(Exception.class, () -> loadFromPath("classpath:/conf/origins/empty-origins-for-configtest.yml")); assertThat(e.getMessage(), matchesPattern("Invalid YAML from classpath:conf/origins/empty-origins-for-configtest.yml: No content to map due to end-of-input\n at \\[Source: .*\\]")); }
@Test public void doesNotLoadIfFileDoesNotExist() { Exception e = assertThrows(RuntimeException.class, () -> loadFromPath("/sadiusadasd")); assertThat(e.getMessage(), matchesPattern("Unable to load YAML from.*")); }
@Test public void cannotLoadWithSyntaxErrors() throws IOException { Exception e = assertThrows(RuntimeException.class, () -> loadFromPath("classpath:/conf/origins/origins-with-syntax-error-for-configtest.yml")); assertThat(e.getMessage(), matchesPattern("Invalid YAML from classpath:conf/origins/origins-with-syntax-error-for-configtest.yml: Cannot deserialize instance of `java.util.ArrayList<com.hotels.styx.api.extension.service.BackendService>` out of VALUE_STRING token\n at \\[Source: .*\\]")); }