Skip to content
This repository has been archived by the owner on Oct 7, 2023. It is now read-only.

Commit

Permalink
Parse test data and convert to Map / List of Map
Browse files Browse the repository at this point in the history
  • Loading branch information
sri-rang committed Aug 11, 2012
1 parent 3ac4549 commit ac86871
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
@@ -1,19 +1,15 @@
package net.srirangan.sortablechallenge.parsers

object TestDataParser {
import util.parsing.json.JSON

def parse(filePath: String): List[String] = {
// Read file per line
// Convert line into map
// Append map to result list
// return
null
}
object TestDataParser {

private def parseObject(string: String): Map[String, String] = {
// JSON object to map
// return
null
def parse(lines: Iterator[String]): List[Any] = {
var result: List[Any] = List()
lines.foreach((line: String) => {
result ::= JSON.parseFull(line)
})
result
}

}
@@ -0,0 +1,23 @@
package net.srirangan.sortablechallenge.parser

import org.scalatest.FunSuite
import org.scalatest.BeforeAndAfter
import net.srirangan.sortablechallenge.parsers.TestDataParser
import io.BufferedSource

class TestDataParserSuite extends FunSuite with BeforeAndAfter {

var productsFile: BufferedSource = scala.io.Source.fromFile("/home/srirangan/Projects/sortable-challenge/src/test/resources/products.txt")
var listingsFile: BufferedSource = scala.io.Source.fromFile("/home/srirangan/Projects/sortable-challenge/src/test/resources/listings.txt")

test("Parse and verifiy test data") {
val lines: Iterator[String] = productsFile.getLines()
TestDataParser.parse(lines)
}

after {
productsFile.close()
listingsFile.close()
}

}

0 comments on commit ac86871

Please sign in to comment.