Search in sources :

Example 1 with Theory

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());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) DataPoint(org.junit.experimental.theories.DataPoint) Theory(org.junit.experimental.theories.Theory)

Example 2 with Theory

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());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) Theory(org.junit.experimental.theories.Theory)

Example 3 with Theory

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());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) Date(java.util.Date) Theory(org.junit.experimental.theories.Theory)

Example 4 with Theory

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());
}
Also used : InterpreterResult(org.apache.zeppelin.interpreter.InterpreterResult) InterpreterContext(org.apache.zeppelin.interpreter.InterpreterContext) Theory(org.junit.experimental.theories.Theory)

Example 5 with Theory

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();
}
Also used : InOrder(org.mockito.InOrder) Theory(org.junit.experimental.theories.Theory)

Aggregations

Theory (org.junit.experimental.theories.Theory)97 DataPoint (org.junit.experimental.theories.DataPoint)23 Test (org.junit.Test)22 Header (io.aeron.logbuffer.Header)15 DirectBuffer (org.agrona.DirectBuffer)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)13 DebugReceiveChannelEndpoint (io.aeron.driver.ext.DebugReceiveChannelEndpoint)11 DebugSendChannelEndpoint (io.aeron.driver.ext.DebugSendChannelEndpoint)11 UdpChannel (io.aeron.driver.media.UdpChannel)11 MediaDriver (io.aeron.driver.MediaDriver)8 InterpreterResult (org.apache.zeppelin.interpreter.InterpreterResult)7 LongAdder (java.util.concurrent.atomic.LongAdder)6 UnsafeBuffer (org.agrona.concurrent.UnsafeBuffer)6 PrimitiveCollection (org.neo4j.collection.primitive.PrimitiveCollection)6 InOrder (org.mockito.InOrder)5 InputStream (java.io.InputStream)4 BaseStream (java.util.stream.BaseStream)4 InterpreterContext (org.apache.zeppelin.interpreter.InterpreterContext)4 Metric (org.springframework.boot.actuate.metrics.Metric)4 BufferClaim (io.aeron.logbuffer.BufferClaim)3