Commit 4f5ea9f5 authored by Romain Reuillon's avatar Romain Reuillon
Browse files

Fix tests.

parent d965a897
......@@ -26,13 +26,10 @@ import org.openmole.core.workflow.data._
import org.openmole.core.workflow.task._
import org.openmole.core.workflow.transition._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.scalatest.junit._
import scala.collection.mutable.ListBuffer
@RunWith(classOf[JUnitRunner])
class DataChannelSpec extends FlatSpec with Matchers {
implicit val plugins = PluginSet.empty
......@@ -47,7 +44,7 @@ class DataChannelSpec extends FlatSpec with Matchers {
override def process(context: Context) = context + (p -> "Test")
}
val t2 = EmptyTask("Inter task")
val t2 = EmptyTask()
val t3 = new TestTask {
val name = "Test read"
......@@ -58,9 +55,9 @@ class DataChannelSpec extends FlatSpec with Matchers {
}
}
val t1c = new Capsule(t1)
val t2c = new Capsule(t2)
val t3c = Slot(new Capsule(t3))
val t1c = Capsule(t1)
val t2c = Capsule(t2)
val t3c = Slot(Capsule(t3))
val ex = (t1c -- t2c -- t3c) + (t1c oo t3c)
......@@ -81,7 +78,7 @@ class DataChannelSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = Capsule(ExplorationTask(sampling))
val res = new ListBuffer[String]
......
......@@ -18,13 +18,10 @@
package org.openmole.core.workflow.data
import org.openmole.core.workflow.data._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.scalatest.junit._
import scala.collection.mutable.ListBuffer
@RunWith(classOf[JUnitRunner])
class PrototypeSpec extends FlatSpec with Matchers {
"ToArray of dim 0" should "return the prototype itself" in {
val a = Prototype[Int]("a")
......
......@@ -24,12 +24,9 @@ import org.openmole.core.workflow.data._
import org.openmole.core.workflow.job._
import org.openmole.core.workflow.mole._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.scalatest.junit._
@RunWith(classOf[JUnitRunner])
class HookSpec extends FlatSpec with Matchers {
"A capsule execution misc" should "intercept the execution of a capsule" in {
......@@ -47,7 +44,7 @@ class HookSpec extends FlatSpec with Matchers {
val hook = new HookBuilder {
def toHook = new Hook with Built {
override def perform(context: Context, executionContext: ExecutionContext) = {
override def process(context: Context, executionContext: ExecutionContext) = {
context.contains(p) should equal(true)
context(p) should equal("test")
executed = true
......@@ -79,7 +76,7 @@ class HookSpec extends FlatSpec with Matchers {
val hook = new HookBuilder {
def toHook = new Hook with Built {
override def perform(context: Context, executionContext: ExecutionContext) = {
override def process(context: Context, executionContext: ExecutionContext) = {
context.contains(p) should equal(true)
context(p) should equal("test")
executed = true
......
......@@ -17,17 +17,14 @@
package org.openmole.core.workflow.mole
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.scalatest.junit._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.task._
import org.openmole.core.workflow.transition._
@RunWith(classOf[JUnitRunner])
class InputStrainerCapsuleSpec extends FlatSpec with Matchers {
"The input strainer capsule" should "let the data in but not out" in {
val p = Prototype[String]("p")
......
......@@ -24,16 +24,13 @@ import org.openmole.core.workflow.data._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.task._
import org.openmole.core.workflow.transition._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.scalatest.junit._
import scala.collection.mutable.ListBuffer
import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.task._
import org.openmole.core.workflow.transition._
@RunWith(classOf[JUnitRunner])
class MasterCapsuleSpec extends FlatSpec with Matchers {
implicit val plugins = PluginSet.empty
......@@ -56,8 +53,8 @@ class MasterCapsuleSpec extends FlatSpec with Matchers {
}
}
val t1c = new MasterCapsule(t1)
val t2c = new MasterCapsule(t2)
val t1c = MasterCapsule(t1)
val t2c = MasterCapsule(t2)
val ex = t1c -- t2c toExecution
......@@ -71,9 +68,9 @@ class MasterCapsuleSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = Capsule(ExplorationTask(sampling))
val emptyT = EmptyTask("Slave")
val emptyT = EmptyTask()
emptyT.addInput(i)
emptyT.addOutput(i)
......@@ -81,14 +78,14 @@ class MasterCapsuleSpec extends FlatSpec with Matchers {
val name = "select"
override val inputs = DataSet(n, i)
override val outputs = DataSet(n, i)
override val defaults = DefaultSet(n -> 0)
override val defaults = DefaultSet(Default(n, 0))
override def process(context: Context) = {
val nVal = context(n)
context + Variable(n, nVal + 1) + Variable(i, (nVal + 1).toString)
}
}
val emptyC = new Capsule(emptyT)
val emptyC = Capsule(emptyT)
val slot1 = Slot(emptyC)
val slot2 = Slot(emptyC)
......@@ -110,9 +107,9 @@ class MasterCapsuleSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, 0 until 10)
val exploration = ExplorationTask("Exploration", sampling)
val exploration = ExplorationTask(sampling)
val model = EmptyTask("model")
val model = EmptyTask()
model addInput i
model addOutput i
......@@ -124,7 +121,7 @@ class MasterCapsuleSpec extends FlatSpec with Matchers {
val name = "select"
override val inputs = DataSet(archive, i)
override val outputs = DataSet(archive, i)
override val defaults = DefaultSet(archive -> Array.empty[Int])
override val defaults = DefaultSet(Default(archive, Array.empty[Int]))
override def process(context: Context) = {
context.contains(archive) should equal(true)
selectTaskExecuted += 1
......@@ -163,15 +160,15 @@ class MasterCapsuleSpec extends FlatSpec with Matchers {
override def process(context: Context) = context
}
val mole = t1 toMole
val mole = Mole(t1)
val mt = MoleTask("MoleTask", mole, mole.root)
val mt = MoleTask(mole, mole.root)
val t1c = new MasterCapsule(mt.toTask)
val t1c = MasterCapsule(mt.toTask)
val i = Prototype[Int]("i")
val explo = ExplorationTask("Exploration", new ExplicitSampling(i, 0 to 100))
val explo = ExplorationTask(new ExplicitSampling(i, 0 to 100))
val ex = explo -< t1c
......
......@@ -29,13 +29,10 @@ import org.openmole.core.workflow.mole._
import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.task._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.scalatest.junit._
import scala.collection.mutable.ListBuffer
@RunWith(classOf[JUnitRunner])
class MoleExecutionSpec extends FlatSpec with Matchers {
implicit val plugins = PluginSet.empty
......@@ -57,9 +54,9 @@ class MoleExecutionSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = Capsule(ExplorationTask(sampling))
val emptyT = EmptyTask("Empty")
val emptyT = EmptyTask()
emptyT.addInput(i)
emptyT.addOutput(i)
......@@ -86,7 +83,7 @@ class MoleExecutionSpec extends FlatSpec with Matchers {
"Implicits" should "be used when input is missing" in {
val i = Prototype[String]("i")
val emptyT = EmptyTask("Empty")
val emptyT = EmptyTask()
emptyT.addInput(i)
val emptyC = Capsule(emptyT)
......
......@@ -23,12 +23,8 @@ import org.openmole.core.workflow.transition._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.task.EmptyTask
import org.openmole.core.workflow.transition._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
@RunWith(classOf[JUnitRunner])
class StrainerCapsuleSpec extends FlatSpec with Matchers {
"The strainer capsule" should "let the data pass through" in {
......@@ -40,7 +36,7 @@ class StrainerCapsuleSpec extends FlatSpec with Matchers {
override def process(context: Context) = context + (p -> "Test")
}
val strainer = EmptyTask("Strainer")
val strainer = EmptyTask()
val t2 = new TestTask {
val name = "Test read"
......@@ -51,9 +47,9 @@ class StrainerCapsuleSpec extends FlatSpec with Matchers {
}
}
val t1c = new Capsule(t1)
val strainerC = new StrainerCapsule(strainer)
val t2c = new Capsule(t2)
val t1c = Capsule(t1)
val strainerC = StrainerCapsule(strainer)
val t2c = Capsule(t2)
val ex = t1c -- strainerC -- t2c
ex.start.waitUntilEnded
......@@ -62,7 +58,7 @@ class StrainerCapsuleSpec extends FlatSpec with Matchers {
"The strainer capsule" should "let the data pass through even if linked with a data channel to the root" in {
val p = Prototype[String]("p")
val root = new StrainerCapsule(EmptyTask("root"))
val root = StrainerCapsule(EmptyTask())
val t1 = new TestTask {
val name = "Test write"
......@@ -70,10 +66,10 @@ class StrainerCapsuleSpec extends FlatSpec with Matchers {
override def process(context: Context) = context + (p -> "Test")
}
val tNone = new StrainerCapsule(EmptyTask("None"))
val tNone2 = new StrainerCapsule(EmptyTask("None"))
val tNone = StrainerCapsule(EmptyTask())
val tNone2 = StrainerCapsule(EmptyTask())
val strainer = EmptyTask("Strainer")
val strainer = EmptyTask()
val t2 = new TestTask {
val name = "Test read"
......@@ -84,7 +80,7 @@ class StrainerCapsuleSpec extends FlatSpec with Matchers {
}
}
val strainerC = Slot(new StrainerCapsule(strainer))
val strainerC = Slot(StrainerCapsule(strainer))
val ex = (root -- tNone -- (t1, tNone2) -- strainerC -- t2) + (root oo strainerC)
ex.start.waitUntilEnded
......
......@@ -20,7 +20,9 @@ package org.openmole.core.workflow.sampling
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.sampling._
import scala.util.Random
class EmptySampling extends Sampling {
override def prototypes = List.empty
override def build(context: Context) = Iterator.empty
override def build(context: Context)(implicit rng: Random) = Iterator.empty
}
......@@ -20,7 +20,9 @@ package org.openmole.core.workflow.sampling
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.sampling._
import scala.util.Random
class ExplicitSampling[T](prototype: Prototype[T], data: Iterable[T]) extends Sampling {
override def prototypes = List(prototype)
override def build(context: Context) = data.map { v List(Variable(prototype, v)) }.iterator
override def build(context: Context)(implicit rng: Random) = data.map { v List(Variable(prototype, v)) }.iterator
}
......@@ -19,30 +19,23 @@ package org.openmole.core.workflow.task
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.data._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import org.openmole.core.workflow.mole._
import org.openmole.core.workflow.task.{MoleTask, EmptyTask, PluginSet}
@RunWith(classOf[JUnitRunner])
class MoleTaskSpec extends FlatSpec with Matchers {
"Implicits" should "work with mole task" in {
val i = Prototype[String]("i")
val emptyT = EmptyTask("Empty")
val emptyT = EmptyTask()
emptyT.addInput(i)
val emptyC = new Capsule(emptyT)
val moleTask =
MoleTask(
"MoleTask",
Mole(emptyC), emptyC)(PluginSet.empty)
MoleTask(Mole(emptyC), emptyC)
moleTask addImplicit i
moleTask addParameter (i -> "test")
moleTask setDefault (i, "test")
MoleExecution(Mole(moleTask)).start.waitUntilEnded
}
......
......@@ -19,21 +19,16 @@ package org.openmole.core.workflow.task
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.task.EmptyTask
import org.openmole.core.serializer.SerialiserService
import org.openmole.misc.tools.io.BufferInputStream
import org.openmole.misc.tools.io.BufferOutputStream
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
@RunWith(classOf[JUnitRunner])
class SerializationSpec extends FlatSpec with Matchers {
"Task " should "be the same after serialization and deserialization" in {
val p = Prototype[Int]("p")
val t = EmptyTask("Test")
val t = EmptyTask()
t.addInput(p)
t.addOutput(p)
......
......@@ -17,9 +17,6 @@
package org.openmole.core.workflow.tools
import org.openmole.core.workflow.tools.VariableExpansion
import org.scalatest.FlatSpec
import org.scalatest.junit.JUnitRunner
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.tools._
......@@ -27,9 +24,7 @@ import org.scalatest._
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import org.junit.runner.RunWith
@RunWith(classOf[JUnitRunner])
class VariableExpansionSpec extends FlatSpec with Matchers {
"A expandData" should "expand all the ${} top level sequence from an inputStream and return a parsed OuputStream" in {
......
......@@ -26,13 +26,9 @@ import org.openmole.core.workflow.data._
import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.task._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import scala.collection.mutable.ListBuffer
@RunWith(classOf[JUnitRunner])
class AggregationTransitionSpec extends FlatSpec with Matchers {
implicit val plugins = PluginSet.empty
......@@ -45,13 +41,13 @@ class AggregationTransitionSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = Capsule(ExplorationTask(sampling))
val emptyT = EmptyTask("Empty")
val emptyT = EmptyTask()
emptyT addInput i
emptyT addOutput i
val emptyC = new Capsule(emptyT)
val emptyC = Capsule(emptyT)
val testT = new TestTask {
val name = "Test"
......@@ -82,13 +78,13 @@ class AggregationTransitionSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = Capsule(ExplorationTask(sampling))
val emptyT = EmptyTask("Empty")
val emptyT = EmptyTask()
emptyT addInput i
emptyT addOutput i
val emptyC = new Capsule(emptyT)
val emptyC = Capsule(emptyT)
val testT = new TestTask {
val name = "Test"
......@@ -103,7 +99,7 @@ class AggregationTransitionSpec extends FlatSpec with Matchers {
}
}
val testC = new Capsule(testT)
val testC = Capsule(testT)
val ex = exc -< emptyC >- testC
......@@ -119,13 +115,13 @@ class AggregationTransitionSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = new Capsule(ExplorationTask(sampling))
val emptyT = EmptyTask("Empty")
val emptyT = EmptyTask()
emptyT addInput i
emptyT addOutput i
val emptyC = new Capsule(emptyT)
val emptyC = Capsule(emptyT)
val testT = new TestTask {
val name = "Test"
......@@ -138,7 +134,7 @@ class AggregationTransitionSpec extends FlatSpec with Matchers {
}
}
val testC = new Capsule(testT)
val testC = Capsule(testT)
val mole = exc -< emptyC >- testC toMole
......
......@@ -24,13 +24,9 @@ import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.task._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import scala.collection.mutable.ListBuffer
@RunWith(classOf[JUnitRunner])
class EndExplorationTransitionSpec extends FlatSpec with Matchers {
implicit val plugins = PluginSet.empty
......@@ -43,9 +39,9 @@ class EndExplorationTransitionSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = new Capsule(ExplorationTask(sampling))
val emptyT = EmptyTask("Empty")
val emptyT = EmptyTask()
emptyT addInput i
emptyT addOutput i
......
......@@ -24,13 +24,9 @@ import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.data._
import org.openmole.core.workflow.sampling._
import org.openmole.core.workflow.task._
import org.scalatest.FlatSpec
import org.scalatest._
import org.scalatest.junit.JUnitRunner
import org.junit.runner.RunWith
import scala.collection.mutable.ListBuffer
@RunWith(classOf[JUnitRunner])
class ExplorationTransitionSpec extends FlatSpec with Matchers {
implicit val plugins = PluginSet.empty
......@@ -42,7 +38,7 @@ class ExplorationTransitionSpec extends FlatSpec with Matchers {
val sampling = new ExplicitSampling(i, data)
val exc = new Capsule(ExplorationTask("Exploration", sampling))
val exc = Capsule(ExplorationTask(sampling))
val res = new ListBuffer[String]
......@@ -68,7 +64,7 @@ class ExplorationTransitionSpec extends FlatSpec with Matchers {
val data = List("A", "B", "C")
val i = Prototype[String]("i")
val explo = ExplorationTask("Exploration", new ExplicitSampling(i, data))
val explo = ExplorationTask(new ExplicitSampling(i, data))
val res = new ListBuffer[String]