DefaultServiceTaskBehavior extends AbstractBpmnActivityBehavior { public boolean hasConnectorBean(DelegateExecution execution) { String implementation = getServiceTaskImplementation(execution); return applicationContext.containsBean(implementation) && applicationContext.getBean(implementation) instanceof Connector; } DefaultServiceTaskBehavior(ApplicationContext applicationContext,
                                      IntegrationContextBuilder integrationContextBuilder,
                                      VariablesCalculator variablesCalculator); @Override void execute(DelegateExecution execution); boolean hasConnectorBean(DelegateExecution execution);  }
@Test public void hasConnectorBeanShouldReturnTrueIfABeanOfConnectorTypeIsFound() { String connectorName = "connector"; DelegateExecution execution = ConnectorRuntimeApiTestHelper.buildExecution(connectorName); given(context.containsBean(connectorName)).willReturn(true); given(context.getBean(connectorName)).willReturn(mock(Connector.class)); boolean hasConnectorBean = behavior.hasConnectorBean(execution); assertThat(hasConnectorBean).isTrue(); }
@Test public void hasConnectorBeanShouldReturnFalseIfNoBeanIsFoundWithTheGivenName() { String connectorName = "connector"; DelegateExecution execution = ConnectorRuntimeApiTestHelper.buildExecution(connectorName); given(context.containsBean(connectorName)).willReturn(false); boolean hasConnectorBean = behavior.hasConnectorBean(execution); assertThat(hasConnectorBean).isFalse(); }
@Test public void hasConnectorBeanShouldReturnFalseIfABeanOfDifferentTypeIsFound() { String connectorName = "connector"; DelegateExecution execution = ConnectorRuntimeApiTestHelper.buildExecution(connectorName); given(context.containsBean(connectorName)).willReturn(true); DelegateExecution nonConnectorBean = mock(DelegateExecution.class); given(context.getBean(connectorName)).willReturn(nonConnectorBean); boolean hasConnectorBean = behavior.hasConnectorBean(execution); assertThat(hasConnectorBean).isFalse(); }