@Test public void originsHaveStatuses() throws JsonProcessingException { MemoryBackedRegistry<BackendService> registry = new MemoryBackedRegistry<>(); DashboardDataSupplier supplier = new DashboardDataSupplier(registry, environment, styxConfig); Origin foo1 = origin("foo1"); Origin foo2 = origin("foo2"); registry.add(backend("foo", foo1, foo2)); registry.add(backend("bar", origin("bar1"))); environment.eventBus().post(new OriginsSnapshot(id("foo"), pools(foo1), pools(foo2), pools())); DashboardData.Downstream downstream = supplier.get().downstream(); DashboardData.Backend fooBackend = downstream.backend("STYXPRES-foo"); assertThat(downstream.backendIds(), containsInAnyOrder("STYXPRES-foo", "STYXPRES-bar")); assertThat(fooBackend.statusesByOriginId(), is(equalTo(ImmutableMap.of("foo1", "active", "foo2", "inactive")))); assertThat(fooBackend.origin("foo1").status(), is("active")); environment.eventBus().post(new OriginsSnapshot(id("foo"), pools(), pools(foo1), pools(foo2))); fooBackend = supplier.get().downstream().backend("STYXPRES-foo"); assertThat(fooBackend.statusesByOriginId(), is(equalTo(ImmutableMap.of("foo1", "inactive", "foo2", "disabled")))); assertThat(fooBackend.origin("foo1").status(), is("inactive")); }
@Override public DashboardData get() { return data; }
DashboardDataSupplier implements Supplier<DashboardData>, Registry.ChangeListener<BackendService> { @Override public DashboardData get() { return data; } }
DashboardDataSupplier implements Supplier<DashboardData>, Registry.ChangeListener<BackendService> { @Override public DashboardData get() { return data; } DashboardDataSupplier(Registry<BackendService> backendServicesRegistry, Environment environment, StyxConfig styxConfig); }
DashboardDataSupplier implements Supplier<DashboardData>, Registry.ChangeListener<BackendService> { @Override public DashboardData get() { return data; } DashboardDataSupplier(Registry<BackendService> backendServicesRegistry, Environment environment, StyxConfig styxConfig); @Override void onChange(Registry.Changes<BackendService> changes); @Override DashboardData get(); }
DashboardDataSupplier implements Supplier<DashboardData>, Registry.ChangeListener<BackendService> { @Override public DashboardData get() { return data; } DashboardDataSupplier(Registry<BackendService> backendServicesRegistry, Environment environment, StyxConfig styxConfig); @Override void onChange(Registry.Changes<BackendService> changes); @Override DashboardData get();  }