Java Code Examples for org.apache.nifi.web.api.dto.FlowSnippetDTO#getInputPorts()

The following examples show how to use org.apache.nifi.web.api.dto.FlowSnippetDTO#getInputPorts() . 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: SnippetUtils.java    From localization_nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Gets all components, but not connections, that are part of the specified template.
 *
 * @param contents snippet
 * @return component dtos
 */
private static Collection<ComponentDTO> getComponents(FlowSnippetDTO contents) {
    final Collection<ComponentDTO> components = new HashSet<>();

    // add all components
    if (contents.getInputPorts() != null) {
        components.addAll(contents.getInputPorts());
    }
    if (contents.getLabels() != null) {
        components.addAll(contents.getLabels());
    }
    if (contents.getOutputPorts() != null) {
        components.addAll(contents.getOutputPorts());
    }
    if (contents.getProcessGroups() != null) {
        components.addAll(contents.getProcessGroups());
    }
    if (contents.getProcessors() != null) {
        components.addAll(contents.getProcessors());
    }
    if (contents.getFunnels() != null) {
        components.addAll(contents.getFunnels());
    }
    if (contents.getRemoteProcessGroups() != null) {
        components.addAll(contents.getRemoteProcessGroups());
    }

    return components;
}
 
Example 2
Source File: SnippetUtils.java    From nifi with Apache License 2.0 5 votes vote down vote up
/**
 * Gets all components, but not connections, that are part of the specified template.
 *
 * @param contents snippet
 * @return component dtos
 */
private static Collection<ComponentDTO> getComponents(FlowSnippetDTO contents) {
    final Collection<ComponentDTO> components = new HashSet<>();

    // add all components
    if (contents.getInputPorts() != null) {
        components.addAll(contents.getInputPorts());
    }
    if (contents.getLabels() != null) {
        components.addAll(contents.getLabels());
    }
    if (contents.getOutputPorts() != null) {
        components.addAll(contents.getOutputPorts());
    }
    if (contents.getProcessGroups() != null) {
        components.addAll(contents.getProcessGroups());
    }
    if (contents.getProcessors() != null) {
        components.addAll(contents.getProcessors());
    }
    if (contents.getFunnels() != null) {
        components.addAll(contents.getFunnels());
    }
    if (contents.getRemoteProcessGroups() != null) {
        components.addAll(contents.getRemoteProcessGroups());
    }

    return components;
}
 
Example 3
Source File: StandardFlowServiceTest.java    From localization_nifi with Apache License 2.0 4 votes vote down vote up
private void assertEquals(FlowSnippetDTO expected, FlowSnippetDTO actual) {
    if (expected == null && actual == null) {
        return;
    }

    // check connections
    Assert.assertEquals(expected.getConnections().size(), actual.getConnections().size());
    List<ConnectionDTO> expectedConnections = new ArrayList<>(expected.getConnections());
    List<ConnectionDTO> actualConnections = new ArrayList<>(actual.getConnections());
    for (int i = 0; i < expectedConnections.size(); i++) {
        assertEquals(expectedConnections.get(i), actualConnections.get(i));
    }

    // check groups
    Assert.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size());
    List<ProcessGroupDTO> expectedProcessGroups = new ArrayList<>(expected.getProcessGroups());
    List<ProcessGroupDTO> actualProcessGroups = new ArrayList<>(actual.getProcessGroups());
    for (int i = 0; i < expectedProcessGroups.size(); i++) {
        assertEquals(expectedProcessGroups.get(i), actualProcessGroups.get(i));
    }

    // check input ports
    Assert.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size());
    List<PortDTO> expectedInputPorts = new ArrayList<>(expected.getInputPorts());
    List<PortDTO> actualInputPort = new ArrayList<>(actual.getInputPorts());
    for (int i = 0; i < expectedInputPorts.size(); i++) {
        assertEquals(expectedInputPorts.get(i), actualInputPort.get(i));
    }

    // check labels
    Assert.assertEquals(expected.getLabels().size(), actual.getLabels().size());
    List<LabelDTO> expectedLabels = new ArrayList<>(expected.getLabels());
    List<LabelDTO> actualLabels = new ArrayList<>(actual.getLabels());
    for (int i = 0; i < expectedLabels.size(); i++) {
        assertEquals(expectedLabels.get(i), actualLabels.get(i));
    }

    // check output ports
    Assert.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size());
    List<PortDTO> expectedOutputPorts = new ArrayList<>(expected.getOutputPorts());
    List<PortDTO> actualOutputPort = new ArrayList<>(actual.getOutputPorts());
    for (int i = 0; i < expectedOutputPorts.size(); i++) {
        assertEquals(expectedOutputPorts.get(i), actualOutputPort.get(i));
    }

    // check processors
    Assert.assertEquals(expected.getProcessors().size(), actual.getProcessors().size());
    List<ProcessorDTO> expectedProcessors = new ArrayList<>(expected.getProcessors());
    List<ProcessorDTO> actualProcessors = new ArrayList<>(actual.getProcessors());
    for (int i = 0; i < expectedProcessors.size(); i++) {
        assertEquals(expectedProcessors.get(i), actualProcessors.get(i));
    }
}
 
Example 4
Source File: StandardFlowServiceTest.java    From nifi with Apache License 2.0 4 votes vote down vote up
private void assertEquals(FlowSnippetDTO expected, FlowSnippetDTO actual) {
    if (expected == null && actual == null) {
        return;
    }

    // check connections
    Assert.assertEquals(expected.getConnections().size(), actual.getConnections().size());
    List<ConnectionDTO> expectedConnections = new ArrayList<>(expected.getConnections());
    List<ConnectionDTO> actualConnections = new ArrayList<>(actual.getConnections());
    for (int i = 0; i < expectedConnections.size(); i++) {
        assertEquals(expectedConnections.get(i), actualConnections.get(i));
    }

    // check groups
    Assert.assertEquals(expected.getProcessGroups().size(), actual.getProcessGroups().size());
    List<ProcessGroupDTO> expectedProcessGroups = new ArrayList<>(expected.getProcessGroups());
    List<ProcessGroupDTO> actualProcessGroups = new ArrayList<>(actual.getProcessGroups());
    for (int i = 0; i < expectedProcessGroups.size(); i++) {
        assertEquals(expectedProcessGroups.get(i), actualProcessGroups.get(i));
    }

    // check input ports
    Assert.assertEquals(expected.getInputPorts().size(), actual.getInputPorts().size());
    List<PortDTO> expectedInputPorts = new ArrayList<>(expected.getInputPorts());
    List<PortDTO> actualInputPort = new ArrayList<>(actual.getInputPorts());
    for (int i = 0; i < expectedInputPorts.size(); i++) {
        assertEquals(expectedInputPorts.get(i), actualInputPort.get(i));
    }

    // check labels
    Assert.assertEquals(expected.getLabels().size(), actual.getLabels().size());
    List<LabelDTO> expectedLabels = new ArrayList<>(expected.getLabels());
    List<LabelDTO> actualLabels = new ArrayList<>(actual.getLabels());
    for (int i = 0; i < expectedLabels.size(); i++) {
        assertEquals(expectedLabels.get(i), actualLabels.get(i));
    }

    // check output ports
    Assert.assertEquals(expected.getOutputPorts().size(), actual.getOutputPorts().size());
    List<PortDTO> expectedOutputPorts = new ArrayList<>(expected.getOutputPorts());
    List<PortDTO> actualOutputPort = new ArrayList<>(actual.getOutputPorts());
    for (int i = 0; i < expectedOutputPorts.size(); i++) {
        assertEquals(expectedOutputPorts.get(i), actualOutputPort.get(i));
    }

    // check processors
    Assert.assertEquals(expected.getProcessors().size(), actual.getProcessors().size());
    List<ProcessorDTO> expectedProcessors = new ArrayList<>(expected.getProcessors());
    List<ProcessorDTO> actualProcessors = new ArrayList<>(actual.getProcessors());
    for (int i = 0; i < expectedProcessors.size(); i++) {
        assertEquals(expectedProcessors.get(i), actualProcessors.get(i));
    }
}