Commit d24d0cc6 authored by Steven Pisarski's avatar Steven Pisarski

Added tests to the OutputDefsYaml class and some housekeeping.

parent 881ebf5e
......@@ -154,15 +154,14 @@ object EventUtil {
* @return - returns an OutputDefinition
*/
def outputDefinition(is: InputStream, inputDef: InputDefinition): Set[OutputDefinition] = {
import scala.collection.JavaConverters._
val out = scala.collection.mutable.Set[OutputDefinition]()
val mapper = new ObjectMapper(new YAMLFactory())
val config = mapper.readValue(is, classOf[OutputDefsYaml])
config.jDefs.asScala.foreach(config => {
config.definitions.foreach(config => {
val fieldSet = scala.collection.mutable.Set[OutputField]()
config.jFields.asScala.foreach(field => {
config.fields.foreach(field => {
val inputFieldItem = inputDef.fieldMap.get(field.inputFieldName)
if (inputFieldItem != None) {
val inputField = inputFieldItem.get
......
......@@ -28,12 +28,10 @@ class InputDefinition(val temporal: Temporal, val dimensionSet: Set[Dimension],
*/
val dimensions = dimensionSet.map(d => d.name -> d).toMap
private[this] val dimPos = dimensionSet.map(d => d.name -> d.position).toSeq.sortBy( _._2 )
/**
* Dimensions in priority order
*/
val positionalDims = dimPos.map(d => dimensions(d._1))
val positionalDims = dimensionSet.map(d => d.name -> d.position).toSeq.sortBy( _._2 ).map(d => dimensions(d._1))
/**
* Contains all fields where the key is the field's name
......
......@@ -2,11 +2,16 @@ package com.cablelabs.eventgen.model
import com.fasterxml.jackson.annotation.JsonProperty
import scala.collection.JavaConverters._
/**
* Used by jackson when parsing the OutputDefinition YAML file
*/
class OutputDefsYaml(@JsonProperty("outputDefs") val jDefs: java.util.List[OutputDefinitionYaml])
class OutputDefsYaml(@JsonProperty("outputDefs") jDefs: java.util.List[OutputDefinitionYaml]) {
require(jDefs != null && jDefs.size() > 0)
val definitions = jDefs.asScala.toList
}
class OutputDefinitionYaml(@JsonProperty("protocol") val prototcol: String,
@JsonProperty("host") val host: String,
......@@ -14,9 +19,21 @@ class OutputDefinitionYaml(@JsonProperty("protocol") val prototcol: String,
@JsonProperty("routeType") val routeType: String,
@JsonProperty("name") val name: String,
@JsonProperty("format") val format: String,
@JsonProperty("fields") val jFields: java.util.List[OutputFieldYaml])
@JsonProperty("fields") jFields: java.util.List[OutputFieldYaml]) {
require(prototcol != null)
require(host != null)
require(port > 0)
require(routeType != null && (routeType == "topic" || routeType == "queue"))
require(name != null)
require(format != null)
require(jFields != null && jFields.size() > 1)
val fields = jFields.asScala.toList
}
class OutputFieldYaml(@JsonProperty("name") val name: String,
@JsonProperty("description") val description: String = "",
@JsonProperty("inputFieldName") val inputFieldName: String,
@JsonProperty("dateFmtStr") val dateFmtStr: String)
@JsonProperty("dateFmtStr") val dateFmtStr: String) {
require(name != null)
require(inputFieldName != null)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment