@Test public void getNoApps() { Optional<CoffeeNetNavigationAppInformation> coffeeNetNavigationAppInformation = Optional.of( new CoffeeNetNavigationAppInformation("groupId", "artifactId", "0.1.0", "parent-groupId", "parent-artifactId", "0.2.0")); when(dataExtractorMock.extractAppInformation()).thenReturn(coffeeNetNavigationAppInformation); Optional<CurrentCoffeeNetUser> coffeeNetWebUser = Optional.of(new CurrentCoffeeNetUser("username", "email")); when(dataExtractorMock.extractUser()).thenReturn(coffeeNetWebUser); when(dataExtractorMock.extractApps()).thenReturn(Optional.empty()); when(dataExtractorMock.extractLogoutPath()).thenReturn("/logout"); CoffeeNetNavigationInformation coffeeNetNavigationInformation = sut.get(); assertThat(coffeeNetNavigationInformation.getLogoutPath()).isEqualTo("/logout"); assertThat(coffeeNetNavigationInformation.getCurrentCoffeeNetUser().getUsername()).isSameAs("username"); assertThat(coffeeNetNavigationInformation.getCurrentCoffeeNetUser().getEmail()).isSameAs("email"); Assertions.assertThat(coffeeNetNavigationInformation.getProfileApp()).isNull(); Assertions.assertThat(coffeeNetNavigationInformation.getCoffeeNetApps()).isNull(); assertThat(coffeeNetNavigationInformation.getCoffeeNetNavigationAppInformation()).isSameAs( coffeeNetNavigationAppInformation.get()); }
@Override public CoffeeNetNavigationInformation get() { CurrentCoffeeNetUser currentCoffeeNetUser = dataExtractor.extractUser().orElse(null); CoffeeNetNavigationAppInformation appInformation = dataExtractor.extractAppInformation().orElse(null); Map<String, List<CoffeeNetApp>> apps = dataExtractor.extractApps().orElseGet(Collections::emptyMap); String logoutPath = dataExtractor.extractLogoutPath(); List<CoffeeNetApp> profileApps = apps.get("profile"); CoffeeNetApp profileApp = null; if (profileApps != null && !profileApps.isEmpty()) { profileApp = profileApps.get(0); } List<CoffeeNetApp> coffeeNetApps = apps.get("apps"); return new CoffeeNetNavigationInformation(currentCoffeeNetUser, coffeeNetApps, profileApp, logoutPath, appInformation); }
CoffeeNetNavigationServiceImpl implements CoffeeNetNavigationService { @Override public CoffeeNetNavigationInformation get() { CurrentCoffeeNetUser currentCoffeeNetUser = dataExtractor.extractUser().orElse(null); CoffeeNetNavigationAppInformation appInformation = dataExtractor.extractAppInformation().orElse(null); Map<String, List<CoffeeNetApp>> apps = dataExtractor.extractApps().orElseGet(Collections::emptyMap); String logoutPath = dataExtractor.extractLogoutPath(); List<CoffeeNetApp> profileApps = apps.get("profile"); CoffeeNetApp profileApp = null; if (profileApps != null && !profileApps.isEmpty()) { profileApp = profileApps.get(0); } List<CoffeeNetApp> coffeeNetApps = apps.get("apps"); return new CoffeeNetNavigationInformation(currentCoffeeNetUser, coffeeNetApps, profileApp, logoutPath, appInformation); } }
CoffeeNetNavigationServiceImpl implements CoffeeNetNavigationService { @Override public CoffeeNetNavigationInformation get() { CurrentCoffeeNetUser currentCoffeeNetUser = dataExtractor.extractUser().orElse(null); CoffeeNetNavigationAppInformation appInformation = dataExtractor.extractAppInformation().orElse(null); Map<String, List<CoffeeNetApp>> apps = dataExtractor.extractApps().orElseGet(Collections::emptyMap); String logoutPath = dataExtractor.extractLogoutPath(); List<CoffeeNetApp> profileApps = apps.get("profile"); CoffeeNetApp profileApp = null; if (profileApps != null && !profileApps.isEmpty()) { profileApp = profileApps.get(0); } List<CoffeeNetApp> coffeeNetApps = apps.get("apps"); return new CoffeeNetNavigationInformation(currentCoffeeNetUser, coffeeNetApps, profileApp, logoutPath, appInformation); } CoffeeNetNavigationServiceImpl(CoffeeNetNavigationDataExtractor dataExtractor); }
CoffeeNetNavigationServiceImpl implements CoffeeNetNavigationService { @Override public CoffeeNetNavigationInformation get() { CurrentCoffeeNetUser currentCoffeeNetUser = dataExtractor.extractUser().orElse(null); CoffeeNetNavigationAppInformation appInformation = dataExtractor.extractAppInformation().orElse(null); Map<String, List<CoffeeNetApp>> apps = dataExtractor.extractApps().orElseGet(Collections::emptyMap); String logoutPath = dataExtractor.extractLogoutPath(); List<CoffeeNetApp> profileApps = apps.get("profile"); CoffeeNetApp profileApp = null; if (profileApps != null && !profileApps.isEmpty()) { profileApp = profileApps.get(0); } List<CoffeeNetApp> coffeeNetApps = apps.get("apps"); return new CoffeeNetNavigationInformation(currentCoffeeNetUser, coffeeNetApps, profileApp, logoutPath, appInformation); } CoffeeNetNavigationServiceImpl(CoffeeNetNavigationDataExtractor dataExtractor); @Override CoffeeNetNavigationInformation get(); }
CoffeeNetNavigationServiceImpl implements CoffeeNetNavigationService { @Override public CoffeeNetNavigationInformation get() { CurrentCoffeeNetUser currentCoffeeNetUser = dataExtractor.extractUser().orElse(null); CoffeeNetNavigationAppInformation appInformation = dataExtractor.extractAppInformation().orElse(null); Map<String, List<CoffeeNetApp>> apps = dataExtractor.extractApps().orElseGet(Collections::emptyMap); String logoutPath = dataExtractor.extractLogoutPath(); List<CoffeeNetApp> profileApps = apps.get("profile"); CoffeeNetApp profileApp = null; if (profileApps != null && !profileApps.isEmpty()) { profileApp = profileApps.get(0); } List<CoffeeNetApp> coffeeNetApps = apps.get("apps"); return new CoffeeNetNavigationInformation(currentCoffeeNetUser, coffeeNetApps, profileApp, logoutPath, appInformation); } CoffeeNetNavigationServiceImpl(CoffeeNetNavigationDataExtractor dataExtractor); @Override CoffeeNetNavigationInformation get();  }