@Test public void getAppRoleListMoreThanTwoElement() { List<com.intuit.wasabi.repository.cassandra.pojo.AppRole> appRoleList = new ArrayList<>(); appRoleList.add(com.intuit.wasabi.repository.cassandra.pojo.AppRole.builder() .appName("testApp") .userId("role1") .userId("user1") .build() ); appRoleList.add(com.intuit.wasabi.repository.cassandra.pojo.AppRole.builder() .appName("testApp") .userId("role2") .userId("user2") .build() ); appRoleList.add(com.intuit.wasabi.repository.cassandra.pojo.AppRole.builder() .appName("testApp") .userId("role3") .userId("user3") .build() ); when(appRoleAccessor.getAppRoleByAppName(eq("testApp"))).thenReturn(appRoleResult); when(appRoleResult.iterator()).thenReturn(appRoleList.iterator()); List<com.intuit.wasabi.repository.cassandra.pojo.AppRole> result = repository.getAppRoleList(Application.Name.valueOf("testApp")); assertThat(result.size(), is(3)); assertThat(result.get(0), is(appRoleList.get(0))); assertThat(result.get(1), is(appRoleList.get(1))); assertThat(result.get(2), is(appRoleList.get(2))); }
List<AppRole> getAppRoleList(Application.Name applicationName) { List<AppRole> resultList = Collections.EMPTY_LIST; try { Result<AppRole> result = appRoleAccessor.getAppRoleByAppName(applicationName.toString()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve info for app \"" + applicationName + "\"", e); } return resultList; }
CassandraAuthorizationRepository implements AuthorizationRepository { List<AppRole> getAppRoleList(Application.Name applicationName) { List<AppRole> resultList = Collections.EMPTY_LIST; try { Result<AppRole> result = appRoleAccessor.getAppRoleByAppName(applicationName.toString()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve info for app \"" + applicationName + "\"", e); } return resultList; } }
CassandraAuthorizationRepository implements AuthorizationRepository { List<AppRole> getAppRoleList(Application.Name applicationName) { List<AppRole> resultList = Collections.EMPTY_LIST; try { Result<AppRole> result = appRoleAccessor.getAppRoleByAppName(applicationName.toString()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve info for app \"" + applicationName + "\"", e); } return resultList; } @Inject  CassandraAuthorizationRepository(ApplicationListAccessor applicationListAccessor,
                                            AppRoleAccessor appRoleAccessor,
                                            UserRoleAccessor userRoleAccessor,
                                            UserInfoAccessor userInfoAccessor,
                                            UserDirectory userDirectory,
                                            MappingManager mappingManager); }
CassandraAuthorizationRepository implements AuthorizationRepository { List<AppRole> getAppRoleList(Application.Name applicationName) { List<AppRole> resultList = Collections.EMPTY_LIST; try { Result<AppRole> result = appRoleAccessor.getAppRoleByAppName(applicationName.toString()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve info for app \"" + applicationName + "\"", e); } return resultList; } @Inject  CassandraAuthorizationRepository(ApplicationListAccessor applicationListAccessor,
                                            AppRoleAccessor appRoleAccessor,
                                            UserRoleAccessor userRoleAccessor,
                                            UserInfoAccessor userInfoAccessor,
                                            UserDirectory userDirectory,
                                            MappingManager mappingManager); @Override UserPermissionsList getUserPermissionsList(UserInfo.Username userID); @Override UserRoleList getApplicationUsers(Application.Name applicationName); @Override UserPermissions getUserPermissions(@Nonnull UserInfo.Username username,
                                              @Nonnull Application.Name applicationName); @Override void deleteUserRole(UserInfo.Username userID, Application.Name applicationName); @Override void setUserRole(UserRole userRole); @Override UserRoleList getUserRoleList(UserInfo.Username userID); @Override UserInfo getUserInfo(UserInfo.Username userID); @Override void setUserInfo(UserInfo userInfo); @Override UserPermissions checkSuperAdminPermissions(UserInfo.Username userID, Application.Name applicationName); @Override void assignUserToSuperAdminRole(UserInfo candidateUser); @Override void removeUserFromSuperAdminRole(UserInfo candidateUser); @Override List<UserRole> getSuperAdminRoleList(); }
CassandraAuthorizationRepository implements AuthorizationRepository { List<AppRole> getAppRoleList(Application.Name applicationName) { List<AppRole> resultList = Collections.EMPTY_LIST; try { Result<AppRole> result = appRoleAccessor.getAppRoleByAppName(applicationName.toString()); resultList = StreamSupport.stream( Spliterators.spliteratorUnknownSize(result.iterator(), Spliterator.ORDERED), false) .collect(Collectors.toList()); } catch (ReadTimeoutException | UnavailableException | NoHostAvailableException e) { throw new RepositoryException("Could not retrieve info for app \"" + applicationName + "\"", e); } return resultList; } @Inject  CassandraAuthorizationRepository(ApplicationListAccessor applicationListAccessor,
                                            AppRoleAccessor appRoleAccessor,
                                            UserRoleAccessor userRoleAccessor,
                                            UserInfoAccessor userInfoAccessor,
                                            UserDirectory userDirectory,
                                            MappingManager mappingManager); @Override UserPermissionsList getUserPermissionsList(UserInfo.Username userID); @Override UserRoleList getApplicationUsers(Application.Name applicationName); @Override UserPermissions getUserPermissions(@Nonnull UserInfo.Username username,
                                              @Nonnull Application.Name applicationName); @Override void deleteUserRole(UserInfo.Username userID, Application.Name applicationName); @Override void setUserRole(UserRole userRole); @Override UserRoleList getUserRoleList(UserInfo.Username userID); @Override UserInfo getUserInfo(UserInfo.Username userID); @Override void setUserInfo(UserInfo userInfo); @Override UserPermissions checkSuperAdminPermissions(UserInfo.Username userID, Application.Name applicationName); @Override void assignUserToSuperAdminRole(UserInfo candidateUser); @Override void removeUserFromSuperAdminRole(UserInfo candidateUser); @Override List<UserRole> getSuperAdminRoleList(); static final String ALL_APPLICATIONS; }