Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Utilizando BDD tentando não aumentar a complexibilidade.
package com.softsimples.persistence
import mongodb.DataWrapperMongoDB
import org.specs2.mutable._
import org.junit.runner._
import org.specs2.runner._
@RunWith(classOf[JUnitRunner])
class DataWrapperMongoDBSpec extends Specification {
"Para executar persistencia com mongodb" should {
"Criar dataWrapper para base test e collection test" in datawrapper().connect
"dataWrapper deve salvar um JSON simples" in datawrapper().save
"dataWrapper deve buscar todos JSONs salvos" in datawrapper().findAll
"dataWrapper deve saber excluir todos JSONs salvos" in datawrapper().deleteAll
}
case class datawrapper() {
val dataWrapper = DataWrapperMongoDB.buildDBWrapper("test", "test")
def connect = dataWrapper must not beNull
def save = dataWrapper.save(json) get("_id") must not beEmpty
private def json: Map[String, Any] = Map[String, Any]("teste" -> "novo teste", "teste2" -> "novo teste2")
def findAll = dataWrapper.findAll() must have size 1
def deleteAll = {
val array = dataWrapper.findAll()
array must have size 1
for (cada <- array) dataWrapper.remove( cada )
dataWrapper.findAll() must have size 0
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.