/**
   * flow-part.
   *
   * @throws Exception if failed
   */
  @Test
  public void flowpart() throws Exception {
    MapReduceCompilerToolkit tk = new MapReduceCompilerToolkit();

    FlowPortMap ports = tk.newFlowPortMap();
    In<MockData> in = ports.addInput("in", MockData.class);
    Out<MockData> out = ports.addOutput("out", MockData.class);
    SimpleJobflow flow = new SimpleJobflow(in, out);

    CompilerConfiguration conf = getConf(tk);
    try (CompilerSession session = tk.newSession(conf)) {
      ArtifactMirror artifact = session.compileFlow(flow, ports);
      check(artifact);
      JobflowMirror single = single(artifact.getBatch());

      assertThat(single.getInputs(), hasSize(1));
      PortMirror<? extends ImporterDescription> i0 = single.findInput("in");
      assertThat(i0, is(notNullValue()));
      assertThat(i0.getDescription(), is(instanceOf(TemporaryInputDescription.class)));

      assertThat(single.getOutputs(), hasSize(1));
      PortMirror<? extends ExporterDescription> o0 = single.findOutput("out");
      assertThat(o0, is(notNullValue()));
      assertThat(o0.getDescription(), is(instanceOf(TemporaryOutputDescription.class)));
    }
  }
 private void check(ArtifactMirror artifact) {
   File batchDir = artifact.getContents();
   assertThat(batchDir.isDirectory(), is(true));
   for (JobflowMirror jobflow : artifact.getBatch().getElements()) {
     File jobflowLib = CompilerConstants.getJobflowLibraryPath(batchDir, jobflow.getFlowId());
     assertThat(jobflowLib.isFile(), is(true));
   }
 }
  private void checkSimpleJobflow(JobflowMirror single) {
    assertThat(single.getFlowId(), is("simple"));

    assertThat(single.getInputs(), hasSize(1));
    PortMirror<? extends ImporterDescription> i0 = single.findInput("IN");
    assertThat(i0, is(notNullValue()));
    assertThat(i0.getDescription(), is(instanceOf(SimpleInputDescription.class)));

    assertThat(single.getOutputs(), hasSize(1));
    PortMirror<? extends ExporterDescription> o0 = single.findOutput("OUT");
    assertThat(o0, is(notNullValue()));
    assertThat(o0.getDescription(), is(instanceOf(SimpleOutputDescription.class)));
  }