use of coffee.synyx.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetWebEndpointTest method invokeWithEmptyUserRoles.
@Test
public void invokeWithEmptyUserRoles() {
CoffeeNetWebUser coffeeNetWebUser = new CoffeeNetWebUser("username", "email");
CoffeeNetApp coffeeNetApp = new CoffeeNetApp("NoRights", "urlNoRights", emptySet());
List<CoffeeNetApp> coffeeNetApps = singletonList(coffeeNetApp);
CoffeeNetWeb coffeeNetWeb = new CoffeeNetWeb(coffeeNetWebUser, coffeeNetApps, coffeeNetApp, "path");
when(coffeeNetWebServiceMock.get()).thenReturn(coffeeNetWeb);
CoffeeNetWebEndpoint sut = new CoffeeNetWebEndpoint(coffeeNetWebServiceMock);
CoffeeNetWeb receivedCoffeeNetWeb = sut.invoke();
assertThat(receivedCoffeeNetWeb.getCoffeeNetApps(), is(coffeeNetApps));
assertThat(receivedCoffeeNetWeb.getCoffeeNetWebUser(), Is.is(coffeeNetWebUser));
assertThat(receivedCoffeeNetWeb.getLogoutPath(), is("path"));
assertThat(receivedCoffeeNetWeb.getProfileApp(), is(coffeeNetApp));
}
use of coffee.synyx.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetWebExtractorTest 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(APP_SERVICE, coffeeNetAppServiceMock);
when(coffeeNetAppServiceMock.getApps(any())).thenReturn(apps);
// user
sut.registerService(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 coffee.synyx.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetWebExtractorTest method extractNoUserService.
@Test
public void extractNoUserService() {
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(APP_SERVICE, coffeeNetAppServiceMock);
when(coffeeNetAppServiceMock.getApps(any())).thenReturn(apps);
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 coffee.synyx.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetWebExtractorTest 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(APP_SERVICE, coffeeNetAppServiceMock);
when(coffeeNetAppServiceMock.getApps(any())).thenReturn(apps);
// user
sut.registerService(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 coffee.synyx.autoconfigure.discovery.service.CoffeeNetApp in project coffeenet-starter by coffeenet.
the class CoffeeNetWebExtractorTest method extractAppsNoUser.
@Test
public void extractAppsNoUser() {
Map<String, List<CoffeeNetApp>> apps = new HashMap<>();
CoffeeNetApp coffeeNetApp = new CoffeeNetApp("Coffee App", "coffeeapp.coffeenet", emptySet());
CoffeeNetApp coffeeNetApp2 = new CoffeeNetApp("Coffee App2", "coffeeapp.coffeenet", new HashSet<>(singletonList("ROLE_COFFEENET-USER")));
apps.put("cna1", singletonList(coffeeNetApp));
apps.put("cna2", singletonList(coffeeNetApp2));
CoffeeNetApp profileApp = new CoffeeNetApp("Profile", "profile.coffeenet", emptySet());
apps.put("profile", singletonList(profileApp));
sut.registerService(APP_SERVICE, coffeeNetAppServiceMock);
when(coffeeNetAppServiceMock.getApps(any())).thenReturn(apps);
// user
sut.registerService(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(2);
assertThat(coffeeNetApps.get("apps")).hasSize(2);
assertThat(coffeeNetApps.get("apps").get(0)).isSameAs(coffeeNetApp);
assertThat(coffeeNetApps.get("apps").get(1)).isSameAs(coffeeNetApp2);
assertThat(coffeeNetApps.get("profile")).hasSize(1);
assertThat(coffeeNetApps.get("profile").get(0)).isSameAs(profileApp);
}
Aggregations