use of com.cloudera.thunderhead.service.usermanagement.UserManagementProto.ListUsersResponse.Builder in project cloudbreak by hortonworks.
the class MockUserManagementService method listUsers.
@Override
public void listUsers(ListUsersRequest request, StreamObserver<ListUsersResponse> responseObserver) {
LOGGER.info("List users for account: {}", request.getAccountId());
Builder userBuilder = ListUsersResponse.newBuilder();
if (request.getUserIdOrCrnCount() == 0) {
if (isNotEmpty(request.getAccountId())) {
ofNullable(accountUsers.get(request.getAccountId())).orElse(Set.of()).stream().map(userName -> createUser(request.getAccountId(), userName)).forEach(userBuilder::addUser);
for (int i = 0; i < MOCK_USER_COUNT; i++) {
User user = createUser(request.getAccountId(), "fakeMockUser" + i);
userBuilder.addUser(user);
}
}
responseObserver.onNext(userBuilder.build());
} else {
String userIdOrCrn = request.getUserIdOrCrn(0);
String[] splittedCrn = userIdOrCrn.split(":");
String userName = splittedCrn[6];
String accountId = splittedCrn[4];
responseObserver.onNext(userBuilder.addUser(createUser(accountId, userName)).build());
}
responseObserver.onCompleted();
}
Aggregations