use of rocks.coffeenet.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetNavigationDataExtractorTest method extractAppsNoProfile.
@Test
public void extractAppsNoProfile() {
Map<String, List<CoffeeNetApp>> apps = new HashMap<>();
CoffeeNetApp coffeeNetApp = new CoffeeNetApp("Coffee App", "coffeeapp.coffeenet", emptySet());
apps.put("apps", singletonList(coffeeNetApp));
sut.registerService(CoffeeNetNavigationDataExtractor.CoffeeNetServices.APP_SERVICE, coffeeNetAppServiceMock);
when(coffeeNetAppServiceMock.getApps(any())).thenReturn(apps);
// user
sut.registerService(CoffeeNetNavigationDataExtractor.CoffeeNetServices.USER_SERVICE, coffeeNetCurrentUserServiceMock);
List<GrantedAuthority> authorities = singletonList(new SimpleGrantedAuthority("ROLE_COFFEENET-ADMIN"));
Optional<CoffeeNetUserDetails> user = of(new HumanCoffeeNetUser("username", "email", authorities));
when(coffeeNetCurrentUserServiceMock.get()).thenReturn(user);
Optional<Map<String, List<CoffeeNetApp>>> extractedApps = sut.extractApps();
Map<String, List<CoffeeNetApp>> coffeeNetApps = extractedApps.get();
assertThat(coffeeNetApps).hasSize(1);
assertThat(coffeeNetApps.get("apps")).hasSize(1);
assertThat(coffeeNetApps.get("apps").get(0)).isSameAs(coffeeNetApp);
assertThat(coffeeNetApps.get("profile")).isNull();
}
use of rocks.coffeenet.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetNavigationDataExtractorTest method orderingIsCaseInsensitive.
@Test
public void orderingIsCaseInsensitive() {
Map<String, List<CoffeeNetApp>> apps = new HashMap<>();
CoffeeNetApp coffeeNetApp = new CoffeeNetApp("x App a", "", emptySet());
apps.put("cna1", singletonList(coffeeNetApp));
CoffeeNetApp coffeeNetApp2 = new CoffeeNetApp("X App b", "", emptySet());
apps.put("cna2", singletonList(coffeeNetApp2));
CoffeeNetApp coffeeNetApp3 = new CoffeeNetApp("app a", "", emptySet());
apps.put("cna3", singletonList(coffeeNetApp3));
CoffeeNetApp coffeeNetApp4 = new CoffeeNetApp("App b", "", emptySet());
apps.put("cna4", singletonList(coffeeNetApp4));
sut.registerService(CoffeeNetNavigationDataExtractor.CoffeeNetServices.APP_SERVICE, coffeeNetAppServiceMock);
when(coffeeNetAppServiceMock.getApps(any())).thenReturn(apps);
// user
sut.registerService(CoffeeNetNavigationDataExtractor.CoffeeNetServices.USER_SERVICE, coffeeNetCurrentUserServiceMock);
when(coffeeNetCurrentUserServiceMock.get()).thenReturn(Optional.empty());
Optional<Map<String, List<CoffeeNetApp>>> extractedApps = sut.extractApps();
Map<String, List<CoffeeNetApp>> coffeeNetApps = extractedApps.get();
assertThat(coffeeNetApps).hasSize(1);
assertThat(coffeeNetApps.get("apps")).hasSize(4);
assertThat(coffeeNetApps.get("apps").get(0)).isSameAs(coffeeNetApp3);
assertThat(coffeeNetApps.get("apps").get(1)).isSameAs(coffeeNetApp4);
assertThat(coffeeNetApps.get("apps").get(2)).isSameAs(coffeeNetApp);
assertThat(coffeeNetApps.get("apps").get(3)).isSameAs(coffeeNetApp2);
}
use of rocks.coffeenet.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetNavigationDataExtractorTest method extractApps.
@Test
public void extractApps() {
Map<String, List<CoffeeNetApp>> apps = new HashMap<>();
CoffeeNetApp coffeeNetApp = new CoffeeNetApp("Coffee App", "coffeeapp.coffeenet", emptySet());
apps.put("cna1", singletonList(coffeeNetApp));
CoffeeNetApp profileApp = new CoffeeNetApp("Profile", "profile.coffeenet", emptySet());
apps.put("profile", singletonList(profileApp));
sut.registerService(CoffeeNetNavigationDataExtractor.CoffeeNetServices.APP_SERVICE, coffeeNetAppServiceMock);
when(coffeeNetAppServiceMock.getApps(any())).thenReturn(apps);
// user
sut.registerService(CoffeeNetNavigationDataExtractor.CoffeeNetServices.USER_SERVICE, coffeeNetCurrentUserServiceMock);
List<GrantedAuthority> authorities = singletonList(new SimpleGrantedAuthority("ROLE_COFFEENET-ADMIN"));
Optional<CoffeeNetUserDetails> user = of(new HumanCoffeeNetUser("username", "email", authorities));
when(coffeeNetCurrentUserServiceMock.get()).thenReturn(user);
Optional<Map<String, List<CoffeeNetApp>>> extractedApps = sut.extractApps();
Map<String, List<CoffeeNetApp>> coffeeNetApps = extractedApps.get();
assertThat(coffeeNetApps).hasSize(2);
assertThat(coffeeNetApps.get("apps")).hasSize(1);
assertThat(coffeeNetApps.get("apps").get(0)).isSameAs(coffeeNetApp);
assertThat(coffeeNetApps.get("profile")).hasSize(1);
assertThat(coffeeNetApps.get("profile").get(0)).isSameAs(profileApp);
}
use of rocks.coffeenet.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetNavigationServiceImplTest method getNoVersion.
@Test
public void getNoVersion() {
Optional<CurrentCoffeeNetUser> coffeeNetWebUser = Optional.of(new CurrentCoffeeNetUser("username", "email"));
when(dataExtractorMock.extractUser()).thenReturn(coffeeNetWebUser);
Optional<CoffeeNetNavigationAppInformation> coffeeNetNavigationAppInformation = Optional.empty();
when(dataExtractorMock.extractAppInformation()).thenReturn(coffeeNetNavigationAppInformation);
Map<String, List<CoffeeNetApp>> apps = new HashMap<>();
CoffeeNetApp coffeeNetApp = new CoffeeNetApp("Coffee App", "coffeeapp.coffeenet", emptySet());
apps.put("apps", singletonList(coffeeNetApp));
CoffeeNetApp profileApp = new CoffeeNetApp("Profile", "profile.coffeenet", emptySet());
apps.put("profile", singletonList(profileApp));
when(dataExtractorMock.extractApps()).thenReturn(Optional.of(apps));
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()).isSameAs(profileApp);
Assertions.assertThat(coffeeNetNavigationInformation.getCoffeeNetApps()).hasSize(1);
Assertions.assertThat(coffeeNetNavigationInformation.getCoffeeNetApps().get(0)).isSameAs(coffeeNetApp);
assertThat(coffeeNetNavigationInformation.getCoffeeNetNavigationAppInformation()).isNull();
}
use of rocks.coffeenet.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetNavigationServiceImplTest method getNoProfileApp.
@Test
public void getNoProfileApp() {
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);
Map<String, List<CoffeeNetApp>> apps = new HashMap<>();
CoffeeNetApp coffeeNetApp = new CoffeeNetApp("Coffee App", "coffeeapp.coffeenet", emptySet());
apps.put("apps", singletonList(coffeeNetApp));
when(dataExtractorMock.extractApps()).thenReturn(Optional.of(apps));
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()).hasSize(1);
Assertions.assertThat(coffeeNetNavigationInformation.getCoffeeNetApps().get(0)).isSameAs(coffeeNetApp);
assertThat(coffeeNetNavigationInformation.getCoffeeNetNavigationAppInformation()).isSameAs(coffeeNetNavigationAppInformation.get());
}
Aggregations