@Test public void getApps() { String profileName = "Profile"; EurekaServiceInstance profile = getServiceInstance(profileName, "ROLE_ADMIN, ROLE_USER"); EurekaServiceInstance profile2 = getServiceInstance(profileName, "ROLE_USER"); when(discoveryClientMock.getInstances(profileName)).thenReturn(asList(profile, profile2)); String backPageName = "Backpage"; EurekaServiceInstance backPage = getServiceInstance(backPageName, null); when(discoveryClientMock.getInstances(backPageName)).thenReturn(singletonList(backPage)); String authName = "Auth"; EurekaServiceInstance auth = getServiceInstance(authName, "ROLE_USER"); when(discoveryClientMock.getInstances(authName)).thenReturn(singletonList(auth)); when(discoveryClientMock.getServices()).thenReturn(asList(profileName, backPageName, authName)); Map<String, List<CoffeeNetApp>> coffeeNetApps = coffeeNetAppService.getApps(); assertThat(coffeeNetApps.entrySet(), hasSize(3)); assertThat(coffeeNetApps.get(profileName), hasSize(2)); assertThat(coffeeNetApps.get(profileName).get(0).getName(), is(profileName)); assertThat(coffeeNetApps.get(profileName).get(0).getAuthorities(), hasSize(2)); assertThat(coffeeNetApps.get(profileName).get(0).getAuthorities(), hasItem("ROLE_USER")); assertThat(coffeeNetApps.get(profileName).get(0).getAuthorities(), hasItem("ROLE_ADMIN")); assertThat(coffeeNetApps.get(profileName).get(1).getName(), is(profileName)); assertThat(coffeeNetApps.get(profileName).get(1).getAuthorities(), hasItem("ROLE_USER")); assertThat(coffeeNetApps.get(backPageName), hasSize(1)); assertThat(coffeeNetApps.get(backPageName).get(0).getName(), is(backPageName)); assertThat(coffeeNetApps.get(backPageName).get(0).getAuthorities(), is(empty())); assertThat(coffeeNetApps.get(authName), hasSize(1)); assertThat(coffeeNetApps.get(authName).get(0).getName(), is(authName)); assertThat(coffeeNetApps.get(authName).get(0).getAuthorities(), hasSize(1)); assertThat(coffeeNetApps.get(authName).get(0).getAuthorities(), hasItem("ROLE_USER")); }
@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);  }