CaseProvisioningServiceImpl implements CaseProvisioningService { @PostConstruct public void init() { if (settings.isProvisioningEnabled() == false) { return; } LOGGER.info("jBPM Case Management Showcase deployment enabled"); final InMemoryRuntimeRegistry runtimeRegistry = new InMemoryRuntimeRegistry(); final WildflyAccessInterface wildflyAccessInterface = new WildflyAccessInterfaceImpl(); final PipelineConfigStage runtimeExec = new PipelineConfigStage("Wildfly Runtime Exec", new ContextAwareWildflyRuntimeExecConfig()); final PipelineExecutor pipelineExecutor; final Pipeline pipeline; final Input input = new Input(); input.put(WildflyProviderConfig.WILDFLY_USER, settings.getUsername()); input.put(WildflyProviderConfig.WILDFLY_PASSWORD, settings.getPassword()); input.put(WildflyProviderConfig.HOST, settings.getHost()); input.put(WildflyProviderConfig.MANAGEMENT_PORT, settings.getManagementPort()); input.put(WildflyProviderConfig.PROVIDER_NAME, "WildFly"); input.put(WildflyRuntimeConfiguration.REDEPLOY_STRATEGY, "none"); if (settings.isDeployFromLocalPath()) { final PipelineConfigStage providerConfig = new PipelineConfigStage("Wildfly Provider Config", new WildflyProviderConfig() { }); pipelineExecutor = new PipelineExecutor(asList( new WildflyProviderConfigExecutor(runtimeRegistry), new WildflyRuntimeExecExecutor(runtimeRegistry, wildflyAccessInterface) )); pipeline = PipelineFactory .newBuilder() .addConfigStage(providerConfig) .addConfigStage(runtimeExec) .buildAs(PIPELINE_NAME); input.put(WildflyRuntimeConfiguration.WAR_PATH, settings.getPath()); } else { final PipelineConfigStage mavenConfig = new PipelineConfigStage("Maven Artifact", new MavenDependencyConfigImpl()); final PipelineConfigStage providerConfig = new PipelineConfigStage("Wildfly Provider Config", new WildflyProviderConfig() { }); final BuildRegistry buildRegistry = new InMemoryBuildRegistry(); pipelineExecutor = new PipelineExecutor(asList( new MavenDependencyConfigExecutor(buildRegistry), new WildflyProviderConfigExecutor(runtimeRegistry), new WildflyRuntimeExecExecutor(runtimeRegistry, wildflyAccessInterface) )); pipeline = PipelineFactory .newBuilder() .addConfigStage(mavenConfig) .addConfigStage(providerConfig) .addConfigStage(runtimeExec) .buildAs(PIPELINE_NAME); input.put("artifact", settings.getGAV()); } executor.execute(pipelineExecutor, pipeline, input); }  @PostConstruct void init(); @Override CaseProvisioningStatus getProvisioningStatus(); void onCaseManagementProvisioningStartedEvent(@Observes CaseProvisioningStartedEvent event); void onCaseManagementProvisioningCompletedEvent(@Observes CaseProvisioningCompletedEvent event); void onCaseManagementProvisioningFailedEvent(@Observes CaseProvisioningFailedEvent event); @Override String getApplicationContext();  }
@Test public void testProvisioningUsingWarPath() { final String path = "path/to/file.war"; when(settings.isProvisioningEnabled()).thenReturn(true); when(settings.isDeployFromLocalPath()).thenReturn(true); when(settings.getPath()).thenReturn(path); service.init(); ArgumentCaptor<Input> captor = ArgumentCaptor.forClass(Input.class); verify(executor).execute(any(PipelineExecutor.class), any(Pipeline.class), captor.capture()); assertEquals(path, captor.getValue().get("war-path")); }
@Test public void testProvisioningUsingMaven() { final String gav = "org.jbpm:jbpm-wb-case-mgmt-showcase:war:1.0.0"; when(settings.isProvisioningEnabled()).thenReturn(true); when(settings.isDeployFromLocalPath()).thenReturn(false); when(settings.getGAV()).thenReturn(gav); service.init(); ArgumentCaptor<Input> captor = ArgumentCaptor.forClass(Input.class); verify(executor).execute(any(PipelineExecutor.class), any(Pipeline.class), captor.capture()); assertEquals(gav, captor.getValue().get("artifact")); }