Created
March 25, 2011 10:31
-
-
Save kornysietsma/886660 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def ingestAllFromDatabase() { | |
solrIngester.clear | |
personRepository.foreach(solrIngester.addDocument(_)) | |
solrIngester.commit() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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