- def testMergePolicies = {
- val vm = DSLResource("vmtime")
- val bup = DSLResource("bup")
- val bdown = DSLResource("bdown")
-
- val a = DSLPolicy(
- "1", Some("2"),
- Map(vm -> "abc", bup -> "def"),
- DSLTimeFrame(
- new Date(0), Option(new Date(12345)), Some(List(
- DSLTimeFrameRepeat(
- List(DSLCronSpec(12, 34, 2, -1, -1)),
- List(DSLCronSpec(12, 34, 4, -1, -1))
- ))
- )
- )
- )
- val b = DSLPolicy("2", Some(""),
- Map(vm -> "xyz", bdown -> "foo"),
- DSLTimeFrame(new Date(0), Option(new Date(45678)), Option(List()))
- )
-
- val result = DSL.mergePolicy(a, b)
-
- assertEquals(result.name, "2")
- assertEquals(result.algorithms.size, 3)
- assertEquals(result.algorithms.get(vm), Some("abc"))
- assertEquals(result.algorithms.get(bup), Some("def"))
- assertEquals(result.algorithms.get(bdown), Some("foo"))
- assertEquals(1, result.effective.repeat.size)
- }
-
- @Test
- def testMergeTimeframes = {
- val a = DSLTimeFrame(
- new Date(0), Option(new Date(12345)), Some(List(
- DSLTimeFrameRepeat(
- List(DSLCronSpec(12, 34, 2, -1, -1)),
- List(DSLCronSpec(12, 34, 4, -1, -1))
- ))
- )
- )
- val b = DSLTimeFrame(new Date(0), Option(new Date(45678)), Some(List()))
-
- var result = DSL.mergeTimeFrames(a, b)
- assertEquals(a.from, result.from)
- assertEquals(a.to, result.to)
- assertEquals(1, result.repeat.get.size)
-
- result = DSL.mergeTimeFrames(b, a)
- assertEquals(b.from, result.from)
- assertEquals(b.to, result.to)
- assertEquals(1, result.repeat.get.size)
- }
-
- @Test