StandardFDProcessorService extends BaseExtensionComponentService<VersionedProcessor, ProcessorDefinition, FDProcessor> implements FDProcessorService { @Override public FDProcessor update(final String flowId, final VersionedProcessor requestComponentConfig) { final FDFlow currentFlow = getFlowOrNotFound(flowId); validateRequestValues(requestComponentConfig); final FDProcessor processor = updateExtensionComponent(currentFlow, requestComponentConfig, VersionedProcessGroup::getProcessors, this::validate); final String groupId = processor.getComponentConfiguration().getGroupIdentifier(); ComponentUtils.populateControllerServicePropertyDescriptors(currentFlow, groupId, processor.getComponentDefinition()); return processor; } @Autowired  StandardFDProcessorService(final FDFlowManager flowManager, final FDExtensionManagers extensionManagers, final ValidationService validationService); @Override FDComponentTypes getProcessorTypes(final String flowId); @Override FDPropertyDescriptor getPropertyDescriptor(final String flowId, final String processorId, final String propertyName); @Override FDProcessor create(final String flowId, final String processGroupId, final VersionedProcessor requestComponentConfig); @Override FDProcessor get(final String flowId, final String processorId); @Override FDProcessor update(final String flowId, final VersionedProcessor requestComponentConfig); @Override void delete(final String flowId, final String processorId); @Override ProcessorDefinition getComponentDefinition(final String agentClass, final VersionedProcessor componentConfig);  }
@Test(expected = ResourceNotFoundException.class) public void testUpdateProcessorWhenFlowDoesNotExist() { final String flowId = "DOES-NOT-EXIST"; when(flowManager.getFlow(flowId)).thenReturn(Optional.empty()); processorService.update(flowId, group2Processor1); }
@Test(expected = ResourceNotFoundException.class) public void testUpdateProcessorWhenProcessorDoesNotExist() { when(flowManager.getFlow(flow.getFlowMetadata().getIdentifier())).thenReturn(Optional.of(flow)); final VersionedProcessor requestProcessor = new VersionedProcessor(); requestProcessor.setIdentifier("DOES-NOT-EXIST"); processorService.update(flow.getFlowMetadata().getIdentifier(), requestProcessor); }
@Test(expected = IllegalArgumentException.class) public void testUpdateProcessorInvalidSchedulingStrategy() { when(flowManager.getFlow(flow.getFlowMetadata().getIdentifier())).thenReturn(Optional.of(flow)); when(extensionManagers.getExtensionManager(flow.getFlowMetadata().getAgentClass())) .thenReturn(Optional.of(extensionManager)); when(extensionManager.getProcessorDefinition(group2Processor1.getType(), group2Processor1.getBundle())) .thenReturn(new ProcessorDefinition()); final String updatedSchedulingStrategy = "INVALID"; final VersionedProcessor requestProcessor = new VersionedProcessor(); requestProcessor.setIdentifier(group2Processor1.getIdentifier()); requestProcessor.setSchedulingStrategy(updatedSchedulingStrategy); processorService.update(flow.getFlowMetadata().getIdentifier(), requestProcessor); }