EngineTest.scala 1.39 KB
Newer Older
1 2 3 4
package com.cablelabs.eventgen

import java.io.{File, FileInputStream}
import java.text.SimpleDateFormat
5
import java.util.Date
6

7
import com.cablelabs.eventgen.model.{InputDefinition, OutputDefinition}
8 9 10 11

/**
 * Tests for the Engine class
 */
12
class EngineTest extends EngineTester {
13 14 15

  val dateFormat = "MM-dd-yyyy HH:mm:ss a"
  val dateFormatter = new SimpleDateFormat(dateFormat)
16
  var inputDef = InputDefinition.inputDefinition(
17
    new FileInputStream(new File("testData/generator/definition/cm-constant-short-input.yaml")))
Steven Pisarski's avatar
Steven Pisarski committed
18
  val outputDefs = OutputDefinition.outputDefinitions(
19
    new FileInputStream(new File("testData/cm/definition/cm-out.yaml")), inputDef)
20
  val eventUri = new File("testData/generator/events/cm.txt").toURI.toString
21 22 23 24 25 26 27
  val delim = '|'
  val outDef = outputDefs.iterator.next()

  engineTest("Test if 5 generated events get sent out to the broker", silenceSpark = true) {
    val notifier = new Notifier
    TestActors.activeMqConsumer(outDef.protocol, outDef.host, outDef.port, outDef.name,
      outDef.routeType, notifier)
28 29

    val seed = analyzer.lastEventByDim().toLocalIterator.next()
30
    val newSeed = seed._2 ++ Map(inputDef.temporal.name -> new Date())
31
    val dimString = inputDef.dimString(newSeed.toMap)
32

33
    engine.seed(dimString, newSeed.toMap)
34 35 36
    Thread.sleep(5100)
    // TODO - add more validation to ensure the output payload is as expected
    assert(5 == notifier.list.size)
37 38
  }
}