Skip to content

Instantly share code, notes, and snippets.

@kornysietsma
Created March 25, 2011 10:31
Show Gist options
  • Save kornysietsma/886660 to your computer and use it in GitHub Desktop.
Save kornysietsma/886660 to your computer and use it in GitHub Desktop.
def ingestAllFromDatabase() {
solrIngester.clear
personRepository.foreach(solrIngester.addDocument(_))
solrIngester.commit()
}
def stubForEach[T](list: List[T]): (Any) => Unit = {
providedFunction => {
val function = providedFunction.asInstanceOf[(T) => Unit]
list.foreach {
value =>
function.apply(value)
}
}
}
"Ingestion Manager should" {
"ingest all people from the database" in {
val solrIngester = mock[SolrIngester]
val personRepository = mock[PersonRepository]
val ingestionManager = new IngestionManager(ldifLoader, solrIngester, personRepository)
val person1 = mock[Person]
val person2 = mock[Person]
personRepository.foreach(any) answers { stubForEach(List(person1,person2)) }
ingestionManager.ingestAllFromDatabase
there was one(solrIngester).clear
there was one(solrIngester).addDocument(person1)
there was one(solrIngester).addDocument(person2)
there was one(solrIngester).commit
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment