@Test public void getAppsFilteredByNames() { String frontPageName = "Frontpage"; EurekaServiceInstance frontPage = getServiceInstance(frontPageName, null); EurekaServiceInstance frontPageWithUser = getServiceInstance(frontPageName, "ROLE_USER"); EurekaServiceInstance frontPageWithAdminAndUser = getServiceInstance(frontPageName, "ROLE_USER, ROLE_ADMIN"); when(discoveryClientMock.getInstances(frontPageName)).thenReturn(asList(frontPageWithUser, frontPageWithAdminAndUser, frontPage)); String backPageName = "Backpage"; EurekaServiceInstance backPage = getServiceInstance(backPageName, "ROLE_USER, ROLE_ADMIN"); when(discoveryClientMock.getInstances(backPageName)).thenReturn(singletonList(backPage)); when(discoveryClientMock.getServices()).thenReturn(asList(frontPageName, backPageName)); AppQuery query = AppQuery.builder().withAppName("Frontpage").build(); Map<String, List<CoffeeNetApp>> coffeeNetApps = coffeeNetAppService.getApps(query); assertThat(coffeeNetApps.entrySet(), hasSize(1)); assertThat(coffeeNetApps.get(frontPageName), hasSize(3)); assertThat(coffeeNetApps.get(frontPageName).get(0).getName(), is(frontPageName)); assertThat(coffeeNetApps.get(frontPageName).get(0).getAuthorities(), hasItem("ROLE_USER")); assertThat(coffeeNetApps.get(frontPageName).get(1).getName(), is(frontPageName)); assertThat(coffeeNetApps.get(frontPageName).get(1).getAuthorities(), hasItem("ROLE_USER")); assertThat(coffeeNetApps.get(frontPageName).get(2).getName(), is(frontPageName)); assertThat(coffeeNetApps.get(frontPageName).get(2).getAuthorities(), is(empty())); }
@Override public Map<String, List<CoffeeNetApp>> getApps() { return getApps(AppQuery.builder().build()); }
IntegrationCoffeeNetAppService implements CoffeeNetAppService { @Override public Map<String, List<CoffeeNetApp>> getApps() { return getApps(AppQuery.builder().build()); } }
IntegrationCoffeeNetAppService implements CoffeeNetAppService { @Override public Map<String, List<CoffeeNetApp>> getApps() { return getApps(AppQuery.builder().build()); } IntegrationCoffeeNetAppService(DiscoveryClient discoveryClient); }
IntegrationCoffeeNetAppService implements CoffeeNetAppService { @Override public Map<String, List<CoffeeNetApp>> getApps() { return getApps(AppQuery.builder().build()); } IntegrationCoffeeNetAppService(DiscoveryClient discoveryClient); @Override Map<String, List<CoffeeNetApp>> getApps(); @Override Map<String, List<CoffeeNetApp>> getApps(AppQuery query); }
IntegrationCoffeeNetAppService implements CoffeeNetAppService { @Override public Map<String, List<CoffeeNetApp>> getApps() { return getApps(AppQuery.builder().build()); } IntegrationCoffeeNetAppService(DiscoveryClient discoveryClient); @Override Map<String, List<CoffeeNetApp>> getApps(); @Override Map<String, List<CoffeeNetApp>> getApps(AppQuery query);  }