<commit_before>package com.yetu.oauth2provider.services.data

import com.yetu.oauth2provider.registry.{ TestRegistry, IntegrationTestRegistry }
import com.yetu.oauth2provider.services.data.iface.IPersonService
import com.yetu.oauth2provider.utils.DateUtility._
import org.joda.time.DateTime
import securesocial.core.PasswordInfo
import securesocial.core.services.SaveMode

abstract class UserServiceBase extends DataBaseSpec {

  def personService: IPersonService

  override def beforeEach {
    personService.deleteUser(testUser.identityId.userId)
  }

  override def afterEach {
    personService.deleteUser(testUser.identityId.userId)
  }

  "The LDAP user service" must {

    "store and retrieve a user " in {
      personService.save(testUser.toBasicProfile, SaveMode.SignUp)
      val Some(yetuUser) = personService.findYetuUser(testUser.userId)

      yetuUser.email mustEqual testUser.email
      yetuUser.firstName mustEqual testUser.firstName
      yetuUser.passwordInfo mustEqual <PASSWORD>User.passwordInfo
      dateToString(yetuUser.userAgreement.get.acceptTermsAndConditionsDate.toDate) mustEqual dateToString(DateTime.now().toDate)
      yetuUser.userAgreement.get.acceptTermsAndConditions mustEqual true
    }

    "store and retrieve a user with registration date " in {
      //registration date is automatically generated in LDAP

      personService.save(testUser.toBasicProfile, SaveMode.SignUp)
      val retrieved = personService.findYetuUser(testUser.userId)

      retrieved.isDefined mustBe true

      retrieved.get.registrationDate.get must not be None
      dateToString(retrieved.get.registrationDate.get) mustEqual dateToString(DateTime.now().toDate)
    }<commit_msg>Revert "Only comparing dates as year-month-day, not full ones -> tests run now."<commit_after>package com.yetu.oauth2provider.services.data

import com.yetu.oauth2provider.registry.{ TestRegistry, IntegrationTestRegistry }
import com.yetu.oauth2provider.services.data.iface.IPersonService
import com.yetu.oauth2provider.utils.DateUtility._
import org.joda.time.DateTime
import securesocial.core.PasswordInfo
import securesocial.core.services.SaveMode

abstract class UserServiceBase extends DataBaseSpec {

  def personService: IPersonService

  override def beforeEach {
    personService.deleteUser(testUser.identityId.userId)
  }

  override def afterEach {
    personService.deleteUser(testUser.identityId.userId)
  }

  "The LDAP user service" must {

    "store and retrieve a user " in {
      personService.save(testUser.toBasicProfile, SaveMode.SignUp)
      val Some(yetuUser) = personService.findYetuUser(testUser.userId)

      yetuUser.email mustEqual testUser.email
      yetuUser.firstName mustEqual testUser.firstName
      yetuUser.passwordInfo mustEqual <PASSWORD>.passwordInfo
      yetuUser.userAgreement mustEqual testUser.userAgreement
      yetuUser.userAgreement.get.acceptTermsAndConditions mustEqual true

    }

    "store and retrieve a user with registration date " in {
      //registration date is automatically generated in LDAP

      personService.save(testUser.toBasicProfile, SaveMode.SignUp)
      val retrieved = personService.findYetuUser(testUser.userId)

      retrieved.isDefined mustBe true

      retrieved.get.registrationDate.get must not be None
      dateToString(retrieved.get.registrationDate.get) mustEqual dateToString(DateTime.now().toDate)
    }
{'fraction_non_alphanumeric': 0.07233166715671861, 'fraction_numerical': 0.0023522493384298734, 'mean_word_length': 4.469453376205788, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, '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': '4262619', 'n_tokens_mistral': 1012, 'n_tokens_neox': 969, 'n_words': 201}