StandardFDRemoteProcessGroupService extends BaseComponentService<VersionedRemoteProcessGroup,FDRemoteProcessGroup> implements FDRemoteProcessGroupService { @Override public FDRemoteProcessGroup update(final String flowId, final VersionedRemoteProcessGroup requestComponentConfig) { validateRequestValues(requestComponentConfig); return updateComponent(flowId, requestComponentConfig, 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 testUpdateSuccess() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final String updatedTargetUris = "http: final String updatedCommsTimeout = "1 seconds"; final String updatedYieldDuration = "1 seconds"; final String updatedTransportProtocol = "HTTP"; assertNotEquals(updatedTargetUris, remoteProcessGroup.getTargetUris()); assertNotEquals(updatedCommsTimeout, remoteProcessGroup.getCommunicationsTimeout()); assertNotEquals(updatedYieldDuration, remoteProcessGroup.getYieldDuration()); assertNotEquals(updatedTransportProtocol, remoteProcessGroup.getTransportProtocol()); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setIdentifier(remoteProcessGroup.getIdentifier()); requestConfig.setTargetUris(updatedTargetUris); requestConfig.setCommunicationsTimeout(updatedCommsTimeout); requestConfig.setYieldDuration(updatedYieldDuration); requestConfig.setTransportProtocol(updatedTransportProtocol); final FDRemoteProcessGroup updatedRemoteProcessGroup = service.update(flowId, requestConfig); assertNotNull(updatedRemoteProcessGroup); assertEquals(requestConfig.getIdentifier(), updatedRemoteProcessGroup.getComponentConfiguration().getIdentifier()); assertEquals(updatedTargetUris, updatedRemoteProcessGroup.getComponentConfiguration().getTargetUris()); assertEquals(updatedCommsTimeout, updatedRemoteProcessGroup.getComponentConfiguration().getCommunicationsTimeout()); assertEquals(updatedYieldDuration, updatedRemoteProcessGroup.getComponentConfiguration().getYieldDuration()); assertEquals(updatedTransportProtocol, updatedRemoteProcessGroup.getComponentConfiguration().getTransportProtocol()); }
@Test(expected = IllegalArgumentException.class) public void testUpdateWithInvalidTransportProtocol() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setIdentifier(remoteProcessGroup.getIdentifier()); requestConfig.setTransportProtocol("INVALID"); service.update(flowId, requestConfig); }
@Test(expected = IllegalArgumentException.class) public void testUpdateWithInvalidYieldDuration() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setIdentifier(remoteProcessGroup.getIdentifier()); requestConfig.setYieldDuration("INVALID"); service.update(flowId, requestConfig); }
@Test(expected = IllegalArgumentException.class) public void testUpdateWithInvalidCommsTimeout() { final String flowId = flow.getFlowMetadata().getIdentifier(); when(flowManager.getFlow(flowId)).thenReturn(Optional.of(flow)); final VersionedRemoteProcessGroup requestConfig = new VersionedRemoteProcessGroup(); requestConfig.setIdentifier(remoteProcessGroup.getIdentifier()); requestConfig.setCommunicationsTimeout("INVALID"); service.update(flowId, requestConfig); }