@Override
  public void process(Object elem) throws Exception {
    try (Closeable scope = context.enterProcess()) {
      checkStarted();
      Receiver receiver = receivers[0];
      if (receiver != null) {
        receiver.process(elem);
      }
    }
  }
@Test
  public void testFlattenOperationContext() throws Exception {
    OperationContext context = Mockito.mock(OperationContext.class);

    OutputReceiver receiver = Mockito.mock(OutputReceiver.class);
    FlattenOperation operation = new FlattenOperation(receiver, context);

    Closeable startCloseable = Mockito.mock(Closeable.class);
    Closeable processCloseable = Mockito.mock(Closeable.class);
    Closeable finishCloseable = Mockito.mock(Closeable.class);
    when(context.enterStart()).thenReturn(startCloseable);
    when(context.enterProcess()).thenReturn(processCloseable);
    when(context.enterFinish()).thenReturn(finishCloseable);

    operation.start();
    operation.process("hello");
    operation.finish();

    InOrder inOrder =
        Mockito.inOrder(receiver, context, startCloseable, processCloseable, finishCloseable);

    inOrder.verify(context).enterProcess();
    inOrder.verify(receiver).process("hello");
    inOrder.verify(processCloseable).close();
  }