//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: protected void deployOnTwoConcurrentThreads(org.camunda.bpm.engine.repository.DeploymentBuilder deploymentOne, org.camunda.bpm.engine.repository.DeploymentBuilder deploymentTwo) throws InterruptedException protected internal virtual void deployOnTwoConcurrentThreads(DeploymentBuilder deploymentOne, DeploymentBuilder deploymentTwo) { assertThat("you can not use the same deployment builder for both deployments", deploymentOne, @is(not(deploymentTwo))); // STEP 1: bring two threads to a point where they have // 1) started a new transaction // 2) are ready to deploy ThreadControl thread1 = executeControllableCommand(new ControllableDeployCommand(deploymentOne)); thread1.waitForSync(); ThreadControl thread2 = executeControllableCommand(new ControllableDeployCommand(deploymentTwo)); thread2.waitForSync(); // STEP 2: make Thread 1 proceed and wait until it has deployed but not yet committed // -> will still hold the exclusive lock thread1.makeContinue(); thread1.waitForSync(); // STEP 3: make Thread 2 continue // -> it will attempt to acquire the exclusive lock and block on the lock thread2.makeContinue(); // wait for 2 seconds (Thread 2 is blocked on the lock) Thread.Sleep(2000); // STEP 4: allow Thread 1 to terminate // -> Thread 1 will commit and release the lock thread1.waitUntilDone(); // STEP 5: wait for Thread 2 to terminate thread2.waitForSync(); thread2.waitUntilDone(); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml() public virtual void testCreateBothJobDefinitionWithParseListenerAndAsynBothInXml() { //given the asyncBefore AND asyncAfter is set in the xml string modelFileName = "jobAsyncBothCreationWithinParseListener.bpmn20.xml"; Stream @in = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName); DeploymentBuilder builder = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in); //when the asyncBefore and asyncAfter is set to true in the parse listener Deployment deployment = builder.deploy(); engineRule.manageDeployment(deployment); //then there exists two job definitions JobDefinitionQuery query = engineRule.ManagementService.createJobDefinitionQuery(); IList <JobDefinition> definitions = query.orderByJobConfiguration().asc().list(); assertEquals(definitions.Count, 2); //asyncAfter JobDefinition asyncAfterAfter = definitions[0]; assertEquals(asyncAfterAfter.ProcessDefinitionKey, "oneTaskProcess"); assertEquals(asyncAfterAfter.ActivityId, "servicetask1"); assertEquals(asyncAfterAfter.JobConfiguration, MessageJobDeclaration.ASYNC_AFTER); //asyncBefore JobDefinition asyncAfterBefore = definitions[1]; assertEquals(asyncAfterBefore.ProcessDefinitionKey, "oneTaskProcess"); assertEquals(asyncAfterBefore.ActivityId, "servicetask1"); assertEquals(asyncAfterBefore.JobConfiguration, MessageJobDeclaration.ASYNC_BEFORE); }
public void RegisterPlugin() { var crmConnectionString = ConfigurationManager.ConnectionStrings["CrmOrganisationService"]; var deployer = DeploymentBuilder.CreateDeployment() .ForTheAssemblyContainingThisPlugin <TestPlugin>("Test plugin assembly") .RunsInSandboxMode() .RegisterInDatabase() .HasPlugin <TestPlugin>() .WhichExecutesOn(SdkMessageNames.Create, "contact") .Synchronously() .PostOperation() .OnlyOnCrmServer() .AndExecutesOn(SdkMessageNames.Update, "contact") .Synchronously() .PostOperation() .OnCrmServerAndOffline() .DeployTo(crmConnectionString.ConnectionString); RegistrationInfo = deployer.Deploy(); if (!RegistrationInfo.Success) { var reason = RegistrationInfo.Error.Message; Assert.Fail("Registration failed because: {0}.", reason); // registrationInfo.Undeploy(); // Console.WriteLine("Deployment was rolled back.."); } //.AndExecutesOn(SdkMessageNames.Delete, "contact") // .Synchronously() // .PostOperation() // .OnlyOffline() }
protected internal virtual DeploymentWithDefinitions tryToRedeploy(RedeploymentDto redeployment) { RepositoryService repositoryService = ProcessEngine.RepositoryService; DeploymentBuilder builder = repositoryService.createDeployment(); builder.nameFromDeployment(deploymentId); string tenantId = Deployment.TenantId; if (!string.ReferenceEquals(tenantId, null)) { builder.tenantId(tenantId); } if (redeployment != null) { builder = addRedeploymentResources(builder, redeployment); } else { builder.addDeploymentResources(deploymentId); } return(builder.deployWithResult()); }
private void RegisterSyncPlugin() { var orgConnectionString = this._CrmOrgConnectionString; var deployer = DeploymentBuilder.CreateDeployment() .ForTheAssemblyContainingThisPlugin <CrmSyncChangeTrackerPlugin>("Test plugin assembly") .RunsInSandboxMode() .RegisterInDatabase() .HasPlugin <CrmSyncChangeTrackerPlugin>() .WhichExecutesOn(SdkMessageNames.Create, TestDynamicsCrmServerSyncProvider.TestEntityName) .Synchronously() .PostOperation() .OnlyOnCrmServer() .DeployTo(orgConnectionString); PluginRegistrationInfo = deployer.Deploy(); if (!PluginRegistrationInfo.Success) { Console.WriteLine("Plugin registration failed.. rolling back.."); try { PluginRegistrationInfo.Undeploy(); } catch (Exception e) { Console.WriteLine("Rollback failed. " + e.Message); } Assert.Fail("Could not register plugin."); } }
public void Can_Register_Crm_Plugin() { var serviceProvider = new CrmServiceProvider(new ExplicitConnectionStringProviderWithFallbackToConfig(), new CrmClientCredentialsProvider()); //PluginAssembly, PluginType, SdkMessageProcessingStep, and SdkMessageProcessingStepImage. var crmOrgConnectionString = ConfigurationManager.ConnectionStrings["CrmOrganisation"]; var deployer = DeploymentBuilder.CreateDeployment() .ForTheAssemblyContainingThisPlugin <CrmSyncChangeTrackerPlugin>("Test plugin assembly") .RunsInSandboxMode() .RegisterInDatabase() .HasPlugin <CrmSyncChangeTrackerPlugin>() .WhichExecutesOn(SdkMessageNames.Create, "contact") .Synchronously() .PostOperation() .OnlyOnCrmServer() .DeployTo(crmOrgConnectionString.ConnectionString); RegistrationInfo = deployer.Deploy(); if (!RegistrationInfo.Success) { Assert.Fail("Registration failed.."); //deployer.Undeploy(updateInfo); //Console.WriteLine("Registration was rolled back.."); } }
protected internal virtual string deploymentWithBuilder(DeploymentBuilder builder) { deploymentId = builder.deploy().Id; deploymentIds.Add(deploymentId); return(deploymentId); }
protected internal virtual DeploymentBuilder addRedeploymentResources(DeploymentBuilder builder, RedeploymentDto redeployment) { builder.source(redeployment.Source); IList <string> resourceIds = redeployment.ResourceIds; IList <string> resourceNames = redeployment.ResourceNames; bool isResourceIdListEmpty = resourceIds == null || resourceIds.Count == 0; bool isResourceNameListEmpty = resourceNames == null || resourceNames.Count == 0; if (isResourceIdListEmpty && isResourceNameListEmpty) { builder.addDeploymentResources(deploymentId); } else { if (!isResourceIdListEmpty) { builder.addDeploymentResourcesById(deploymentId, resourceIds); } if (!isResourceNameListEmpty) { builder.addDeploymentResourcesByName(deploymentId, resourceNames); } } return(builder); }
protected internal virtual Deployment deploy(BpmnModelInstance modelInstance) { DeploymentBuilder deploymentbuilder = processEngineConfiguration.RepositoryService.createDeployment(); deploymentbuilder.addModelInstance("process0.bpmn", modelInstance); return(testRule.deploy(deploymentbuilder)); }
public virtual DeploymentWithDefinitions deploy(DeploymentBuilder deploymentBuilder) { DeploymentWithDefinitions deployment = deploymentBuilder.deployWithResult(); processEngineRule.manageDeployment(deployment); return(deployment); }
protected internal virtual string deployment(DeploymentBuilder deploymentBuilder, params string[] resources) { for (int i = 0; i < resources.Length; i++) { deploymentBuilder.addClasspathResource(resources[i]); } return(deploymentWithBuilder(deploymentBuilder)); }
protected internal virtual string deployment(DeploymentBuilder deploymentBuilder, params BpmnModelInstance[] bpmnModelInstances) { for (int i = 0; i < bpmnModelInstances.Length; i++) { BpmnModelInstance bpmnModelInstance = bpmnModelInstances[i]; deploymentBuilder.addModelInstance("testProcess-" + i + ".bpmn", bpmnModelInstance); } return(deploymentWithBuilder(deploymentBuilder)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void setUp() throws Exception public override void setUp() { DeploymentBuilder deploymentbuilder = repositoryService.createDeployment(); BpmnModelInstance defaultModel = createDefaultExternalTaskModel().build(); BpmnModelInstance modifiedModel = createDefaultExternalTaskModel().processKey(ANOTHER_PROCESS_KEY).build(); deploymentId = deployment(deploymentbuilder, defaultModel, modifiedModel); base.setUp(); }
public virtual void run() { DeploymentBuilder deploymentbuilder = engine.RepositoryService.createDeployment(); for (int i = 0; i < modelInstances.Count; i++) { deploymentbuilder.addModelInstance("process" + i + ".bpmn", modelInstances[i]); } deploymentbuilder.deploy(); }
protected internal virtual Deployment deploy(IList <BpmnModelInstance> modelInstances) { DeploymentBuilder deploymentbuilder = processEngineConfiguration.RepositoryService.createDeployment(); for (int i = 0; i < modelInstances.Count; i++) { deploymentbuilder.addModelInstance("process" + i + ".bpmn", modelInstances[i]); } return(testRule.deploy(deploymentbuilder)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: //ORIGINAL LINE: @Override public void setUp() throws Exception public override void setUp() { ProcessEngineConfigurationImpl config = (ProcessEngineConfigurationImpl)ProcessEngine.ProcessEngineConfiguration; optimizeService = config.OptimizeService; DeploymentBuilder deploymentbuilder = repositoryService.createDeployment(); BpmnModelInstance defaultModel = Bpmn.createExecutableProcess("process").startEvent().endEvent().done(); deploymentId = deployment(deploymentbuilder, defaultModel); base.setUp(); }
public virtual void testParseExternalTaskWithoutTopic() { DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/bpmn/external/ExternalTaskParseTest.testParseExternalTaskWithoutTopic.bpmn20.xml"); try { deploymentBuilder.deploy(); fail("exception expected"); } catch (ProcessEngineException e) { assertTextPresent("External tasks must specify a 'topic' attribute in the camunda namespace", e.Message); } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeleteJobDefinitionWithParseListenerAndAsyncInXml() public virtual void testDeleteJobDefinitionWithParseListenerAndAsyncInXml() { //given the asyncBefore is set in the xml string modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml"; Stream @in = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName); DeploymentBuilder builder = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in); //when the asyncBefore is set to false in the parse listener Deployment deployment = builder.deploy(); engineRule.manageDeployment(deployment); //then there exists no job definition JobDefinitionQuery query = engineRule.ManagementService.createJobDefinitionQuery(); assertNull(query.singleResult()); }
protected internal virtual DeploymentWithDefinitions deploy(DeploymentBuilder deploymentBuilder, IList <BpmnModelInstance> bpmnModelInstances, IList <string> resources) { int i = 0; foreach (BpmnModelInstance bpmnModelInstance in bpmnModelInstances) { deploymentBuilder.addModelInstance(i + "_" + DEFAULT_BPMN_RESOURCE_NAME, bpmnModelInstance); i++; } foreach (string resource in resources) { deploymentBuilder.addClasspathResource(resource); } return(deploy(deploymentBuilder)); }
protected internal virtual void autoDeployResources(ProcessEngine processEngine) { if (deploymentResources != null && deploymentResources.Length > 0) { RepositoryService repositoryService = processEngine.RepositoryService; DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().enableDuplicateFiltering(deployChangedOnly).name(deploymentName).tenantId(deploymentTenantId); foreach (Resource resource in deploymentResources) { string resourceName = null; if (resource is ContextResource) { resourceName = ((ContextResource)resource).PathWithinContext; } else if (resource is ByteArrayResource) { resourceName = resource.Description; } else { resourceName = getFileResourceName(resource); } try { if (resourceName.EndsWith(".bar", StringComparison.Ordinal) || resourceName.EndsWith(".zip", StringComparison.Ordinal) || resourceName.EndsWith(".jar", StringComparison.Ordinal)) { deploymentBuilder.addZipInputStream(new ZipInputStream(resource.InputStream)); } else { deploymentBuilder.addInputStream(resourceName, resource.InputStream); } } catch (IOException e) { throw new ProcessEngineException("couldn't auto deploy resource '" + resource + "': " + e.Message, e); } } deploymentBuilder.deploy(); } }
private DeploymentBuilder extractDeploymentInformation(MultipartFormData payload) { DeploymentBuilder deploymentBuilder = ProcessEngine.RepositoryService.createDeployment(); ISet <string> partNames = payload.PartNames; foreach (string name in partNames) { MultipartFormData.FormPart part = payload.getNamedPart(name); if (!RESERVED_KEYWORDS.Contains(name)) { string fileName = part.FileName; if (!string.ReferenceEquals(fileName, null)) { deploymentBuilder.addInputStream(part.FileName, new MemoryStream(part.BinaryContent)); } else { throw new InvalidRequestException(Status.BAD_REQUEST, "No file name found in the deployment resource described by form parameter '" + fileName + "'."); } } } MultipartFormData.FormPart deploymentName = payload.getNamedPart(DEPLOYMENT_NAME); if (deploymentName != null) { deploymentBuilder.name(deploymentName.TextContent); } MultipartFormData.FormPart deploymentSource = payload.getNamedPart(DEPLOYMENT_SOURCE); if (deploymentSource != null) { deploymentBuilder.source(deploymentSource.TextContent); } MultipartFormData.FormPart deploymentTenantId = payload.getNamedPart(TENANT_ID); if (deploymentTenantId != null) { deploymentBuilder.tenantId(deploymentTenantId.TextContent); } extractDuplicateFilteringForDeployment(payload, deploymentBuilder); return(deploymentBuilder); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void shouldPropagateTenantIdToCandidateStarterUser() public virtual void shouldPropagateTenantIdToCandidateStarterUser() { // when DeploymentBuilder builder = repositoryService.createDeployment().addClasspathResource(CANDIDATE_STARTER_USER).tenantId(TENANT_ONE); testRule.deploy(builder); // then ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult(); IList <IdentityLink> links = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.Id); assertEquals(1, links.Count); IdentityLink link = links[0]; assertNotNull(link.TenantId); assertEquals(TENANT_ONE, link.TenantId); }
public override void createDeployment(string processArchiveName, DeploymentBuilder deploymentBuilder) { ProcessEngine processEngine = BpmPlatform.ProcessEngineService.getProcessEngine("default"); // Hack: deploy the first version of the invoice process once before the process application // is deployed the first time if (processEngine != null) { RepositoryService repositoryService = processEngine.RepositoryService; if (!isProcessDeployed(repositoryService, "invoice")) { ClassLoader classLoader = ProcessApplicationClassloader; repositoryService.createDeployment(this.Reference).addInputStream("invoice.v1.bpmn", classLoader.getResourceAsStream("invoice.v1.bpmn")).addInputStream("invoiceBusinessDecisions.dmn", classLoader.getResourceAsStream("invoiceBusinessDecisions.dmn")).addInputStream("review-invoice.cmmn", classLoader.getResourceAsStream("review-invoice.cmmn")).deploy(); } } }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testCreateJobDefinitionWithParseListenerAndAsyncInXml() public virtual void testCreateJobDefinitionWithParseListenerAndAsyncInXml() { //given the asyncBefore is set in the xml string modelFileName = "jobAsyncBeforeCreationWithinParseListener.bpmn20.xml"; Stream @in = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName); DeploymentBuilder builder = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in); //when the asyncBefore is set in the parse listener Deployment deployment = builder.deploy(); engineRule.manageDeployment(deployment); //then there exists only one job definition JobDefinitionQuery query = engineRule.ManagementService.createJobDefinitionQuery(); JobDefinition jobDef = query.singleResult(); assertNotNull(jobDef); assertEquals(jobDef.ProcessDefinitionKey, "oneTaskProcess"); assertEquals(jobDef.ActivityId, "servicetask1"); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeleteNonExistingAndCreateNewJobDefinitionWithParseListener() public virtual void testDeleteNonExistingAndCreateNewJobDefinitionWithParseListener() { //given string modelFileName = "jobCreationWithinParseListener.bpmn20.xml"; Stream @in = typeof(JobDefinitionCreationWithParseListenerTest).getResourceAsStream(modelFileName); DeploymentBuilder builder = engineRule.RepositoryService.createDeployment().addInputStream(modelFileName, @in); //when the asyncBefore is set to false and the asyncAfter to true in the parse listener Deployment deployment = builder.deploy(); engineRule.manageDeployment(deployment); //then there exists one job definition JobDefinitionQuery query = engineRule.ManagementService.createJobDefinitionQuery(); JobDefinition jobDef = query.singleResult(); assertNotNull(jobDef); assertEquals(jobDef.ProcessDefinitionKey, "oneTaskProcess"); assertEquals(jobDef.ActivityId, "servicetask1"); assertEquals(jobDef.JobConfiguration, MessageJobDeclaration.ASYNC_AFTER); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeployEmptyDecisionDefinition() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testDeployEmptyDecisionDefinition() { // given empty decision model DmnModelInstance modelInstance = Dmn.createEmptyModel(); Definitions definitions = modelInstance.newInstance(typeof(Definitions)); definitions.Id = DmnModelConstants.DMN_ELEMENT_DEFINITIONS; definitions.Name = DmnModelConstants.DMN_ELEMENT_DEFINITIONS; definitions.Namespace = DmnModelConstants.CAMUNDA_NS; modelInstance.Definitions = definitions; // when decision model is deployed DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", modelInstance); DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder); // then deployment contains no definitions assertNull(deployment.DeployedDecisionDefinitions); assertNull(deployment.DeployedDecisionRequirementsDefinitions); // and there are no persisted definitions assertNull(repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName("foo.dmn").singleResult()); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Test public void testDeployAndGetDecisionDefinition() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET: public virtual void testDeployAndGetDecisionDefinition() { // given decision model DmnModelInstance dmnModelInstance = createDmnModelInstance(); // when decision model is deployed DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().addModelInstance("foo.dmn", dmnModelInstance); DeploymentWithDefinitions deployment = testRule.deploy(deploymentBuilder); // then deployment contains definition IList <DecisionDefinition> deployedDecisionDefinitions = deployment.DeployedDecisionDefinitions; assertEquals(1, deployedDecisionDefinitions.Count); assertNull(deployment.DeployedDecisionRequirementsDefinitions); assertNull(deployment.DeployedProcessDefinitions); assertNull(deployment.DeployedCaseDefinitions); // and persisted definition are equal to deployed definition DecisionDefinition persistedDecisionDef = repositoryService.createDecisionDefinitionQuery().decisionDefinitionResourceName("foo.dmn").singleResult(); assertEquals(persistedDecisionDef.Id, deployedDecisionDefinitions[0].Id); }
public virtual DeploymentWithDefinitionsDto createDeployment(UriInfo uriInfo, MultipartFormData payload) { DeploymentBuilder deploymentBuilder = extractDeploymentInformation(payload); if (deploymentBuilder.ResourceNames.Count > 0) { DeploymentWithDefinitions deployment = deploymentBuilder.deployWithResult(); DeploymentWithDefinitionsDto deploymentDto = DeploymentWithDefinitionsDto.fromDeployment(deployment); URI uri = uriInfo.BaseUriBuilder.path(relativeRootResourcePath).path(org.camunda.bpm.engine.rest.DeploymentRestService_Fields.PATH).path(deployment.Id).build(); // GET deploymentDto.addReflexiveLink(uri, HttpMethod.GET, "self"); return(deploymentDto); } else { throw new InvalidRequestException(Status.BAD_REQUEST, "No deployment resources contained in the form upload."); } }
protected internal virtual string deploymentForTenant(string tenantId, params BpmnModelInstance[] bpmnModelInstances) { DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().tenantId(tenantId); return(deployment(deploymentBuilder, bpmnModelInstances)); }
protected internal virtual string deploymentForTenant(string tenantId, params string[] resources) { DeploymentBuilder deploymentBuilder = repositoryService.createDeployment().tenantId(tenantId); return(deployment(deploymentBuilder, resources)); }