A few assertions based on the example policy file
authorGeorgios Gousios <gousiosg@gmail.com>
Thu, 27 Oct 2011 09:49:41 +0000 (12:49 +0300)
committerGeorgios Gousios <gousiosg@gmail.com>
Thu, 27 Oct 2011 09:49:52 +0000 (12:49 +0300)
logic/src/test/scala/gr/grnet/aquarium/logic/test/DSLTest.scala

index dfcd3b2..ee6f7b2 100644 (file)
@@ -2,8 +2,7 @@ package gr.grnet.aquarium.logic.test
 
 import org.junit.Assert._
 import gr.grnet.aquarium.logic.accounting.dsl._
-import java.io.{StringReader, InputStreamReader}
-import org.junit.{Before, Test}
+import org.junit.{Test}
 import java.util.Date
 
 class DSLTest {
@@ -21,6 +20,16 @@ class DSLTest {
   def testParsePolicies = {
     before
     assertEquals(creditpolicy.policies.size, 2)
+    assertEquals(creditpolicy.policies(0).algorithms.size,
+      creditpolicy.resources.size)
+    assertEquals(creditpolicy.policies(1).algorithms.size,
+      creditpolicy.resources.size)
+
+    val d = DSL.findResource(creditpolicy, "diskspace").get
+    assertNotNone(d)
+
+    assertNotSame(creditpolicy.policies(0).algorithms(d),
+      creditpolicy.policies(1).algorithms(d))
   }
 
   @Test
@@ -105,4 +114,14 @@ class DSLTest {
       case e: Exception => assert(true)
     }
   }
+
+  def assertNone(a: AnyRef) = a match {
+    case None =>
+    case x => fail()
+  }
+
+  def assertNotNone(a: AnyRef) = a match {
+    case None => fail()
+    case _ =>
+  }
 }
\ No newline at end of file