StandardFDRemoteProcessGroupService extends BaseComponentService<VersionedRemoteProcessGroup,FDRemoteProcessGroup> implements FDRemoteProcessGroupService { @Override public FDRemoteProcessGroup create(final String flowId, final String processGroupId, final VersionedRemoteProcessGroup requestComponentConfig) { final String targetUris = requestComponentConfig.getTargetUris(); if (StringUtils.isBlank(targetUris)) { throw new IllegalArgumentException("Cannot add a Remote Process Group without specifying the Target URI(s)"); } validateRequestValues(requestComponentConfig); return createComponent( flowId, processGroupId, null, requestComponentConfig, () -> { final VersionedRemoteProcessGroup componentConfig = new VersionedRemoteProcessGroup(); componentConfig.setTransportProtocol(DEFAULT_TRANSPORT_PROTOCOL); componentConfig.setCommunicationsTimeout(DEFAULT_COMMUNICATION_TIMEOUT); componentConfig.setYieldDuration(DEFAULT_YIELD_DURATION); componentConfig.setLocalNetworkInterface(""); componentConfig.setProxyHost(""); componentConfig.setInputPorts(new HashSet<>()); componentConfig.setOutputPorts(new HashSet<>()); final FDRemoteProcessGroup component = new FDRemoteProcessGroup(); component.setComponentConfiguration(componentConfig); return component; }, VersionedProcessGroup::getRemoteProcessGroups, null); } StandardFDRemoteProcessGroupService(final FDFlowManager flowManager, final ValidationService validationService); @Override FDRemoteProcessGroup create(final String flowId, final String processGroupId, final VersionedRemoteProcessGroup requestComponentConfig); @Override FDRemoteProcessGroup get(final String flowId, final String componentId); @Override FDRemoteProcessGroup update(final String flowId, final VersionedRemoteProcessGroup requestComponentConfig); @Override void delete(final String flowId, final String componentId);  }
@Test public void testCreateSuccessWithValuesSpecified() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("http: requestConfig.setCommunicationsTimeout("30 seconds"); requestConfig.setYieldDuration("10 seconds"); requestConfig.setTransportProtocol("HTTP"); final FDRemoteProcessGroup createdRemoteProcessGroup = service.create(flowId, group1.getIdentifier(), requestConfig); assertNotNull(createdRemoteProcessGroup); assertEquals(requestConfig.getTargetUris(), createdRemoteProcessGroup.getComponentConfiguration().getTargetUris()); assertEquals(requestConfig.getCommunicationsTimeout(), createdRemoteProcessGroup.getComponentConfiguration().getCommunicationsTimeout()); assertEquals(requestConfig.getYieldDuration(), createdRemoteProcessGroup.getComponentConfiguration().getYieldDuration()); assertEquals(requestConfig.getTransportProtocol(), createdRemoteProcessGroup.getComponentConfiguration().getTransportProtocol()); }
@Test public void testCreateSuccessWithDefaults() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("http: final FDRemoteProcessGroup createdRemoteProcessGroup = service.create(flowId, group1.getIdentifier(), requestConfig); assertNotNull(createdRemoteProcessGroup); assertEquals(requestConfig.getTargetUris(), createdRemoteProcessGroup.getComponentConfiguration().getTargetUris()); }
@Test(expected = IllegalArgumentException.class) public void testCreateSuccessWithInvalidUris() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("uri-1,uri-2"); final FDRemoteProcessGroup createdRemoteProcessGroup = service.create(flowId, group1.getIdentifier(), requestConfig); assertNotNull(createdRemoteProcessGroup); assertEquals(requestConfig.getTargetUris(), createdRemoteProcessGroup.getComponentConfiguration().getTargetUris()); }
@Test public void testCreateSuccessWithTrimmedUris() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris(" http: final FDRemoteProcessGroup createdRemoteProcessGroup = service.create(flowId, group1.getIdentifier(), requestConfig); assertNotNull(createdRemoteProcessGroup); assertEquals("http: }
@Test(expected = IllegalArgumentException.class) public void testCreateWithInvalidTransportProtocol() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("uri-1,uri-2"); requestConfig.setTransportProtocol("INVALID"); service.create(flowId, group1.getIdentifier(), requestConfig); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithInvalidYieldDuration() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("uri-1,uri-2"); requestConfig.setYieldDuration("INVALID"); service.create(flowId, group1.getIdentifier(), requestConfig); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithInvalidCommsTimeout() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("uri-1,uri-2"); requestConfig.setCommunicationsTimeout("INVALID"); service.create(flowId, group1.getIdentifier(), requestConfig); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithProxyPortOfZero() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("http: requestConfig.setProxyPort(0); service.create(flowId, group1.getIdentifier(), requestConfig); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithProxyPortLessThanMin() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("http: requestConfig.setProxyPort(-2); service.create(flowId, group1.getIdentifier(), requestConfig); }
@Test(expected = IllegalArgumentException.class) public void testCreateWithProxyPortGreaterThanMsx() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("http: requestConfig.setProxyPort(65536); service.create(flowId, group1.getIdentifier(), requestConfig); }
@Test public void testCreateWithProxyPortOfNegativeOne() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("http: requestConfig.setProxyPort(-1); service.create(flowId, group1.getIdentifier(), requestConfig); }
@Test public void testCreateWithValidProxyPort() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setTargetUris("http: requestConfig.setProxyPort(100); service.create(flowId, group1.getIdentifier(), requestConfig); }