added Ref semantics to MongoStorage + refactoring for commonality + added test cases
This commit is contained in:
parent
cee665ba9a
commit
73bc685515
5 changed files with 82 additions and 7 deletions
|
|
@ -269,4 +269,38 @@ class MongoStorageSpec extends TestCase {
|
|||
changeSetM += "4" -> List(10, 20, 30)
|
||||
changeSetM
|
||||
}
|
||||
|
||||
@Test
|
||||
def testRefStorage = {
|
||||
MongoStorage.getRefStorageFor("U-R1") match {
|
||||
case None =>
|
||||
case Some(o) => fail("should be None")
|
||||
}
|
||||
|
||||
val m = Map("1"->1, "2"->4, "3"->9)
|
||||
MongoStorage.insertRefStorageFor("U-R1", m)
|
||||
MongoStorage.getRefStorageFor("U-R1") match {
|
||||
case None => fail("should not be empty")
|
||||
case Some(r) => {
|
||||
val a = r.asInstanceOf[Map[String, Int]]
|
||||
assertEquals(a.size, 3)
|
||||
assertEquals(a.get("1").get, 1)
|
||||
assertEquals(a.get("2").get, 4)
|
||||
assertEquals(a.get("3").get, 9)
|
||||
}
|
||||
}
|
||||
|
||||
// insert another one
|
||||
// the previous one should be replaced
|
||||
val b = List("100", "jonas")
|
||||
MongoStorage.insertRefStorageFor("U-R1", b)
|
||||
MongoStorage.getRefStorageFor("U-R1") match {
|
||||
case None => fail("should not be empty")
|
||||
case Some(r) => {
|
||||
val a = r.asInstanceOf[List[String]]
|
||||
assertEquals("100", a(0))
|
||||
assertEquals("jonas", a(1))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue