<commit_before>package im.actor.server.util

import scala.language.postfixOps

import im.actor.api.rpc.auth.AuthService
import im.actor.api.rpc.users.User
import im.actor.server.{ ImplicitRegions, BaseAppSuite }

class UserUtilsSpec extends BaseAppSuite with ImplicitRegions {

  import UserUtils._

  it should "generate proper User struct" in e1

  implicit val authService: AuthService = buildAuthService()

  val (users, authIds, phones) =
    Seq(createUser(), createUser()).foldLeft(Seq.empty[User], Seq.empty[Long], Seq.empty[Long]) {
      case ((uacc, aacc, pacc), (u, a, p)) ⇒
        (uacc :+ u, aacc :+ a, pacc :+ p)
    }

  val userIds = users map (_.id) toSet

  def e1() = {
    val (requestingUser, requestingAuthId, _) = createUser()

    val structs = userStructs(userIds, requestingUser.id, requestingAuthId)
  }
}<commit_msg>test(util): completed spec for UserUtils<commit_after>package im.actor.server.util

import scala.concurrent.Await
import scala.concurrent.duration._
import scala.language.postfixOps

import im.actor.api.rpc.auth.AuthService
import im.actor.api.rpc.users.{ ContactRecord, ContactType, User }
import im.actor.server.{ persist, ImplicitRegions, BaseAppSuite }

class UserUtilsSpec extends BaseAppSuite with ImplicitRegions {

  import UserUtils._

  it should "generate proper User struct" in e1

  implicit val authService: AuthService = buildAuthService()

  val userTups = Seq(createUser(), createUser()) map {
    case (struct, authId, phone) ⇒
      (Await.result(db.run(persist.User.find(struct.id) map (_.head)), 5.seconds), authId, phone)
  }

  val userIds = userTups map (_._1.id) toSet

  def e1() = {
    val (requestingUser, requestingAuthId, _) = createUser()

    whenReady(db.run(userStructs(userIds, requestingUser.id, requestingAuthId))) { structs ⇒
      val expectedStructs = userTups map {
        case (user, authId, phone) ⇒
          User(
            user.id,
            ACLUtils.userAccessHash(requestingAuthId, user),
            user.name,
            None,
            None,
            Some(phone),
            None,
            Some(false),
            Vector(ContactRecord(ContactType.Phone, None, Some(phone), Some("Mobile phone"), None))
          )
      }

      structs shouldEqual expectedStructs
    }
  }
}
{'fraction_non_alphanumeric': 0.1131004366812227, 'fraction_numerical': 0.0026200873362445414, 'mean_word_length': 3.2822429906542054, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5831936', 'n_tokens_mistral': 739, 'n_tokens_neox': 719, 'n_words': 178}