m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/src/test/java/pl
diff options
context:
space:
mode:
authorMartin <marcin.j.chrzanowski@gmail.com>2019-11-17 13:11:52 +0100
committerGitHub <noreply@github.com>2019-11-17 13:11:52 +0100
commit582448484ee914a55c46e6360c96ffc59d85ed94 (patch)
tree6811c456b2d50f20577649710e852a3c0150f195 /src/test/java/pl
parent42eef2f0804100728451afcc085f0940cbbc44c4 (diff)
Interpreter cli (#14)
* Add test hierarchy * Pass ZMI into interpreter * Add runInterpreter task * Ensure ZMI is modified after query execution
Diffstat (limited to 'src/test/java/pl')
-rw-r--r--src/test/java/pl/edu/mimuw/cloudatlas/interpreter/InterpreterTests.java28
1 files changed, 27 insertions, 1 deletions
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,15 +2,38 @@ 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());