HostValidatorService implements ApplicationListener<ContextRefreshedEvent> { @Override public void onApplicationEvent(final ContextRefreshedEvent event) { initializeAllowedHosts(); }  boolean isRequestFromAdmin(final ServletRequest request); @Override void onApplicationEvent(final ContextRefreshedEvent event);  }
@Test public void testOnApplicationEventShouldInitializeAllowedHosts() { List<String> adminHosts = new ArrayList<>(); adminHosts.add("a"); adminHosts.add("b"); given(wilmaAdminHostsDTO.getWilmaAdminHosts()).willReturn(adminHosts); given(ipAddressResolver.resolveToHostName("a")).willReturn("a"); given(ipAddressResolver.resolveToHostName("b")).willReturn("b"); underTest.onApplicationEvent(null); assertEquals(adminHosts, Whitebox.getInternalState(underTest, "allowedHosts")); }