コード例 #1
0
  private ProcessorDTO createProcessor(final String token) throws Exception {
    String url = BASE_URL + "/process-groups/root/processors";

    // authorization header
    Map<String, String> headers = new HashMap<>();
    headers.put("Authorization", "Bearer " + token);

    // create the processor
    ProcessorDTO processor = new ProcessorDTO();
    processor.setName("Copy");
    processor.setType(SourceTestProcessor.class.getName());

    // create the revision
    final RevisionDTO revision = new RevisionDTO();
    revision.setClientId(CLIENT_ID);
    revision.setVersion(0l);

    // create the entity body
    ProcessorEntity entity = new ProcessorEntity();
    entity.setRevision(revision);
    entity.setComponent(processor);

    // perform the request
    ClientResponse response = TOKEN_USER.testPostWithHeaders(url, entity, headers);

    // ensure the request is successful
    Assert.assertEquals(201, response.getStatus());

    // get the entity body
    entity = response.getEntity(ProcessorEntity.class);

    // verify creation
    processor = entity.getComponent();
    Assert.assertEquals("Copy", processor.getName());
    Assert.assertEquals(
        "org.apache.nifi.integration.util.SourceTestProcessor", processor.getType());

    return processor;
  }