From 582448484ee914a55c46e6360c96ffc59d85ed94 Mon Sep 17 00:00:00 2001 From: Martin Date: Sun, 17 Nov 2019 13:11:52 +0100 Subject: Interpreter cli (#14) * Add test hierarchy * Pass ZMI into interpreter * Add runInterpreter task * Ensure ZMI is modified after query execution --- .../cloudatlas/interpreter/InterpreterTests.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/test/java/pl/edu/mimuw') diff --git a/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java index 20f7c2e..1794cf9 100644 --- a/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java +++ b/src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java @@ -2,14 +2,37 @@ package pl.edu.mimuw.cloudatlas.interpreter; import java.io.PrintStream; import java.io.FileInputStream; +import java.io.InputStream; import java.io.File; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.net.URL; import static org.junit.Assert.*; import org.junit.Test; +import pl.edu.mimuw.cloudatlas.model.AttributesMap; +import pl.edu.mimuw.cloudatlas.model.ValueTime; +import pl.edu.mimuw.cloudatlas.model.ZMI; + public class InterpreterTests { + @Test + public void modifiesZmi() throws Exception { + ZMI root = Main.createTestHierarchy(); + InputStream in = new ByteArrayInputStream("SELECT epoch() AS timestamp".getBytes("UTF-8")); + ByteArrayOutputStream outByteArray = new ByteArrayOutputStream(); + PrintStream outPrint = new PrintStream(outByteArray); + Main.runTest(in, outPrint, root); + + AttributesMap rootAttributes = root.getAttributes(); + assertEquals(new ValueTime("2000/01/01 00:00:00.000"), rootAttributes.get("timestamp")); + + for (ZMI son : root.getSons()) { + AttributesMap sonAttributes = son.getAttributes(); + assertEquals(new ValueTime("2000/01/01 00:00:00.000"), sonAttributes.get("timestamp")); + } + } + @Test public void fileTest01() throws Exception { runFileTest(1); @@ -112,7 +135,10 @@ public class InterpreterTests { FileInputStream in = new FileInputStream(test.getFile()); ByteArrayOutputStream outByteArray = new ByteArrayOutputStream(); PrintStream outPrint = new PrintStream(outByteArray); - Main.runTest(in, outPrint); + + ZMI root = Main.createTestHierarchy(); + Main.runTest(in, outPrint, root); + String actual = outByteArray.toString(); File expectedFile = new File(testOut.getFile()); -- cgit v1.2.3