Java Code Examples for org.apache.nifi.web.api.dto.ControllerServiceDTO#setRestricted()

The following examples show how to use org.apache.nifi.web.api.dto.ControllerServiceDTO#setRestricted() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestFlowController.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test(expected = IllegalArgumentException.class)
public void testInstantiateSnippetWhenControllerServiceMissingBundle() throws ProcessorInstantiationException {
    final String id = UUID.randomUUID().toString();
    final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
    final ControllerServiceNode controllerServiceNode = controller.getFlowManager().createControllerService(ServiceA.class.getName(), id, coordinate, null, true, true);

    // create the controller service dto
    final ControllerServiceDTO csDto = new ControllerServiceDTO();
    csDto.setId(UUID.randomUUID().toString()); // use a different id
    csDto.setParentGroupId(controllerServiceNode.getProcessGroup() == null ? null : controllerServiceNode.getProcessGroup().getIdentifier());
    csDto.setName(controllerServiceNode.getName());
    csDto.setType(controllerServiceNode.getCanonicalClassName());
    csDto.setBundle(null); // missing bundle
    csDto.setState(controllerServiceNode.getState().name());
    csDto.setAnnotationData(controllerServiceNode.getAnnotationData());
    csDto.setComments(controllerServiceNode.getComments());
    csDto.setPersistsState(controllerServiceNode.getControllerServiceImplementation().getClass().isAnnotationPresent(Stateful.class));
    csDto.setRestricted(controllerServiceNode.isRestricted());
    csDto.setExtensionMissing(controllerServiceNode.isExtensionMissing());
    csDto.setDescriptors(new LinkedHashMap<>());
    csDto.setProperties(new LinkedHashMap<>());

    // create the snippet with the controller service
    final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO();
    flowSnippetDTO.setControllerServices(Collections.singleton(csDto));

    // instantiate the snippet
    assertEquals(0, controller.getFlowManager().getRootGroup().getControllerServices(false).size());
    controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
}
 
Example 2
Source File: TestFlowController.java    From nifi with Apache License 2.0 5 votes vote down vote up
@Test
public void testInstantiateSnippetWithControllerService() throws ProcessorInstantiationException {
    final String id = UUID.randomUUID().toString();
    final BundleCoordinate coordinate = systemBundle.getBundleDetails().getCoordinate();
    final ControllerServiceNode controllerServiceNode = controller.getFlowManager().createControllerService(ServiceA.class.getName(), id, coordinate, null, true, true);

    // create the controller service dto
    final ControllerServiceDTO csDto = new ControllerServiceDTO();
    csDto.setId(UUID.randomUUID().toString()); // use a different id
    csDto.setParentGroupId(controllerServiceNode.getProcessGroup() == null ? null : controllerServiceNode.getProcessGroup().getIdentifier());
    csDto.setName(controllerServiceNode.getName());
    csDto.setType(controllerServiceNode.getCanonicalClassName());
    csDto.setBundle(new BundleDTO(coordinate.getGroup(), coordinate.getId(), coordinate.getVersion()));
    csDto.setState(controllerServiceNode.getState().name());
    csDto.setAnnotationData(controllerServiceNode.getAnnotationData());
    csDto.setComments(controllerServiceNode.getComments());
    csDto.setPersistsState(controllerServiceNode.getControllerServiceImplementation().getClass().isAnnotationPresent(Stateful.class));
    csDto.setRestricted(controllerServiceNode.isRestricted());
    csDto.setExtensionMissing(controllerServiceNode.isExtensionMissing());
    csDto.setDescriptors(new LinkedHashMap<>());
    csDto.setProperties(new LinkedHashMap<>());

    // create the snippet with the controller service
    final FlowSnippetDTO flowSnippetDTO = new FlowSnippetDTO();
    flowSnippetDTO.setControllerServices(Collections.singleton(csDto));

    // instantiate the snippet
    assertEquals(0, controller.getFlowManager().getRootGroup().getControllerServices(false).size());
    controller.getFlowManager().instantiateSnippet(controller.getFlowManager().getRootGroup(), flowSnippetDTO);
    assertEquals(1, controller.getFlowManager().getRootGroup().getControllerServices(false).size());
}