Search in sources :

Example 1 with CountAnswer

use of org.apache.hyracks.api.test.CountAnswer in project asterixdb by apache.

the class LogMarkerTest method create.

public static TestTupleCounterFrameWriter create(RecordDescriptor recordDescriptor, Collection<FrameWriterOperation> exceptionThrowingOperations, Collection<FrameWriterOperation> errorThrowingOperations, boolean deepCopyInputFrames) {
    CountAnswer openAnswer = FrameWriterTestUtils.createAnswer(FrameWriterOperation.Open, exceptionThrowingOperations, errorThrowingOperations);
    CountAnswer nextAnswer = FrameWriterTestUtils.createAnswer(FrameWriterOperation.NextFrame, exceptionThrowingOperations, errorThrowingOperations);
    CountAnswer flushAnswer = FrameWriterTestUtils.createAnswer(FrameWriterOperation.Flush, exceptionThrowingOperations, errorThrowingOperations);
    CountAnswer failAnswer = FrameWriterTestUtils.createAnswer(FrameWriterOperation.Fail, exceptionThrowingOperations, errorThrowingOperations);
    CountAnswer closeAnswer = FrameWriterTestUtils.createAnswer(FrameWriterOperation.Close, exceptionThrowingOperations, errorThrowingOperations);
    return new TestTupleCounterFrameWriter(recordDescriptor, openAnswer, nextAnswer, flushAnswer, failAnswer, closeAnswer, deepCopyInputFrames);
}
Also used : CountAnswer(org.apache.hyracks.api.test.CountAnswer) TestTupleCounterFrameWriter(org.apache.asterix.app.data.gen.TestTupleCounterFrameWriter)

Example 2 with CountAnswer

use of org.apache.hyracks.api.test.CountAnswer in project asterixdb by apache.

the class FramewriterTest method createOutputWriters.

public IFrameWriter[] createOutputWriters() throws Exception {
    CountAnswer[] opens = new CountAnswer[] { openNormal, openException, openError };
    CountAnswer[] nextFrames = new CountAnswer[] { nextFrameNormal, nextFrameException, nextFrameError };
    CountAnswer[] fails = new CountAnswer[] { failNormal, failException, failError };
    CountAnswer[] closes = new CountAnswer[] { closeNormal, closeException, closeError };
    List<IFrameWriter> outputWriters = new ArrayList<>();
    for (CountAnswer openAnswer : opens) {
        for (CountAnswer nextFrameAnswer : nextFrames) {
            for (CountAnswer failAnswer : fails) {
                for (CountAnswer closeAnswer : closes) {
                    IFrameWriter writer = Mockito.mock(IFrameWriter.class);
                    Mockito.doAnswer(openAnswer).when(writer).open();
                    Mockito.doAnswer(nextFrameAnswer).when(writer).nextFrame(Mockito.any());
                    Mockito.doAnswer(failAnswer).when(writer).fail();
                    Mockito.doAnswer(closeAnswer).when(writer).close();
                    outputWriters.add(writer);
                }
            }
        }
    }
    return outputWriters.toArray(new IFrameWriter[outputWriters.size()]);
}
Also used : CountAnswer(org.apache.hyracks.api.test.CountAnswer) IFrameWriter(org.apache.hyracks.api.comm.IFrameWriter) ArrayList(java.util.ArrayList)

Aggregations

CountAnswer (org.apache.hyracks.api.test.CountAnswer)2 ArrayList (java.util.ArrayList)1 TestTupleCounterFrameWriter (org.apache.asterix.app.data.gen.TestTupleCounterFrameWriter)1 IFrameWriter (org.apache.hyracks.api.comm.IFrameWriter)1