use of org.junit.experimental.theories.Theory in project zeppelin by apache.
the class ElasticsearchInterpreterTest method testDelete.
@Theory
public void testDelete(ElasticsearchInterpreter interpreter) {
InterpreterResult res = interpreter.interpret("delete /logs/http/unknown", null);
assertEquals(Code.ERROR, res.code());
res = interpreter.interpret("delete /unknown/unknown/unknown", null);
assertEquals(Code.ERROR, res.code());
final int testDeleteId = deleteId.decrementAndGet();
res = interpreter.interpret("delete /logs/http/" + testDeleteId, null);
assertEquals(Code.SUCCESS, res.code());
assertEquals("" + testDeleteId, res.message().get(0).getData());
}
use of org.junit.experimental.theories.Theory in project zeppelin by apache.
the class ElasticsearchInterpreterTest method testCount.
@Theory
public void testCount(ElasticsearchInterpreter interpreter) {
final InterpreterContext ctx = buildContext("testCount");
InterpreterResult res = interpreter.interpret("count /unknown", ctx);
assertEquals(Code.ERROR, res.code());
res = interpreter.interpret("count /logs", ctx);
assertEquals(Code.SUCCESS, res.code());
assertEquals("50", res.message().get(0).getData());
assertNotNull(ctx.getAngularObjectRegistry().get("count_testCount", null, null));
assertEquals(50l, ctx.getAngularObjectRegistry().get("count_testCount", null, null).get());
res = interpreter.interpret("count /logs { \"query\": { \"match\": { \"status\": 500 } } }", ctx);
assertEquals(Code.SUCCESS, res.code());
}
use of org.junit.experimental.theories.Theory in project zeppelin by apache.
the class ElasticsearchInterpreterTest method testIndex.
@Theory
public void testIndex(ElasticsearchInterpreter interpreter) {
InterpreterResult res = interpreter.interpret("index /logs { \"date\": \"" + new Date() + "\", \"method\": \"PUT\", \"status\": \"500\" }", null);
assertEquals(Code.ERROR, res.code());
res = interpreter.interpret("index /logs/http { bad ", null);
assertEquals(Code.ERROR, res.code());
res = interpreter.interpret("index /logs/http { \"date\": \"2015-12-06T14:54:23.368Z\", \"method\": \"PUT\", \"status\": \"500\" }", null);
assertEquals(Code.SUCCESS, res.code());
res = interpreter.interpret("index /logs/http/1000 { \"date\": \"2015-12-06T14:54:23.368Z\", \"method\": \"PUT\", \"status\": \"500\" }", null);
assertEquals(Code.SUCCESS, res.code());
}
use of org.junit.experimental.theories.Theory in project zeppelin by apache.
the class ElasticsearchInterpreterTest method testGet.
@Theory
public void testGet(ElasticsearchInterpreter interpreter) {
final InterpreterContext ctx = buildContext("get");
InterpreterResult res = interpreter.interpret("get /logs/http/unknown", ctx);
assertEquals(Code.ERROR, res.code());
res = interpreter.interpret("get /logs/http/unknown/unknown", ctx);
assertEquals(Code.ERROR, res.code());
res = interpreter.interpret("get /unknown/unknown/unknown", ctx);
assertEquals(Code.ERROR, res.code());
res = interpreter.interpret("get /logs/http/very/strange/id#1", ctx);
assertEquals(Code.SUCCESS, res.code());
res = interpreter.interpret("get /logs/http/4", ctx);
assertEquals(Code.SUCCESS, res.code());
res = interpreter.interpret("get /logs/_all/4", ctx);
assertEquals(Code.SUCCESS, res.code());
}
use of org.junit.experimental.theories.Theory in project cryptomator by cryptomator.
the class AutoClosingIntStreamTest method testTerminalOperationDelegatesToAndClosesDelegate.
@Theory
public void testTerminalOperationDelegatesToAndClosesDelegate(@FromDataPoints("terminalOperations") TerminalOperation terminalOperation) {
Object expectedResult = terminalOperation.result();
if (expectedResult != null) {
when(terminalOperation.apply(delegate)).thenReturn(expectedResult);
}
Object result = terminalOperation.apply(inTest);
InOrder inOrder = inOrder(delegate);
assertThat(result, is(expectedResult));
inOrder.verify(delegate).close();
}
Aggregations