Search in sources :

Example 36 with ProcessApplicationReference

use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.

the class RedeploymentRegistrationTest method processDefinitionTestProvider.

protected static TestProvider processDefinitionTestProvider() {
    return new TestProvider() {

        @Override
        public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
            return new Command<ProcessApplicationReference>() {

                public ProcessApplicationReference execute(CommandContext commandContext) {
                    ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
                    DeploymentCache deploymentCache = configuration.getDeploymentCache();
                    ProcessDefinitionEntity definition = deploymentCache.findDeployedProcessDefinitionById(definitionId);
                    return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
                }
            };
        }

        @Override
        public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
            return repositoryService.createProcessDefinitionQuery().processDefinitionKey(key).latestVersion().singleResult().getId();
        }
    };
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Command(org.camunda.bpm.engine.impl.interceptor.Command) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessDefinitionEntity(org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 37 with ProcessApplicationReference

use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.

the class RedeploymentRegistrationTest method registrationNotFoundByDeploymentId.

@Test
public void registrationNotFoundByDeploymentId() {
    // given
    ProcessApplicationReference reference = processApplication.getReference();
    Deployment deployment1 = repositoryService.createDeployment(reference).name(DEPLOYMENT_NAME).addClasspathResource(resource1).deploy();
    assertEquals(reference, getProcessApplicationForDeployment(deployment1.getId()));
    // when
    Deployment deployment2 = repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResources(deployment1.getId()).deploy();
    // then
    assertNull(getProcessApplicationForDeployment(deployment2.getId()));
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) Deployment(org.camunda.bpm.engine.repository.Deployment) Test(org.junit.Test)

Example 38 with ProcessApplicationReference

use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.

the class RedeploymentRegistrationTest method decisionDefinitionTestProvider.

protected static TestProvider decisionDefinitionTestProvider() {
    return new TestProvider() {

        @Override
        public Command<ProcessApplicationReference> createGetProcessApplicationCommand(final String definitionId) {
            return new Command<ProcessApplicationReference>() {

                public ProcessApplicationReference execute(CommandContext commandContext) {
                    ProcessEngineConfigurationImpl configuration = commandContext.getProcessEngineConfiguration();
                    DeploymentCache deploymentCache = configuration.getDeploymentCache();
                    DecisionDefinitionEntity definition = deploymentCache.findDeployedDecisionDefinitionById(definitionId);
                    return ProcessApplicationContextUtil.getTargetProcessApplication(definition);
                }
            };
        }

        @Override
        public String getLatestDefinitionIdByKey(RepositoryService repositoryService, String key) {
            return repositoryService.createDecisionDefinitionQuery().decisionDefinitionKey(key).latestVersion().singleResult().getId();
        }
    };
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) CommandContext(org.camunda.bpm.engine.impl.interceptor.CommandContext) Command(org.camunda.bpm.engine.impl.interceptor.Command) DeploymentCache(org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache) ProcessEngineConfigurationImpl(org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl) DecisionDefinitionEntity(org.camunda.bpm.engine.impl.dmn.entity.repository.DecisionDefinitionEntity) RepositoryService(org.camunda.bpm.engine.RepositoryService)

Example 39 with ProcessApplicationReference

use of org.camunda.bpm.application.ProcessApplicationReference in project camunda-bpm-platform by camunda.

the class RedeploymentRegistrationTest method registrationFoundFromDifferentDeployment.

@Test
public void registrationFoundFromDifferentDeployment() {
    // given
    // first deployment
    ProcessApplicationReference reference1 = processApplication.getReference();
    Deployment deployment1 = repositoryService.createDeployment(reference1).name(DEPLOYMENT_NAME).addClasspathResource(resource1).addClasspathResource(resource2).deploy();
    // second deployment
    ProcessApplicationReference reference2 = processApplication.getReference();
    repositoryService.createDeployment(reference2).name(DEPLOYMENT_NAME).addClasspathResource(resource1).deploy();
    // when
    repositoryService.createDeployment().name(DEPLOYMENT_NAME).addDeploymentResources(deployment1.getId()).deploy();
    String firstDefinitionId = getLatestDefinitionIdByKey(definitionKey1);
    String secondDefinitionId = getLatestDefinitionIdByKey(definitionKey2);
    // then
    assertEquals(reference2, getProcessApplicationForDefinition(firstDefinitionId));
    assertEquals(reference1, getProcessApplicationForDefinition(secondDefinitionId));
}
Also used : ProcessApplicationReference(org.camunda.bpm.application.ProcessApplicationReference) Deployment(org.camunda.bpm.engine.repository.Deployment) Test(org.junit.Test)

Aggregations

ProcessApplicationReference (org.camunda.bpm.application.ProcessApplicationReference)39 Deployment (org.camunda.bpm.engine.repository.Deployment)10 Test (org.junit.Test)10 ProcessApplicationUnavailableException (org.camunda.bpm.application.ProcessApplicationUnavailableException)7 ProcessEngineConfigurationImpl (org.camunda.bpm.engine.impl.cfg.ProcessEngineConfigurationImpl)7 EmbeddedProcessApplication (org.camunda.bpm.application.impl.EmbeddedProcessApplication)6 CommandContext (org.camunda.bpm.engine.impl.interceptor.CommandContext)5 ProcessApplicationInterface (org.camunda.bpm.application.ProcessApplicationInterface)4 ProcessEngineException (org.camunda.bpm.engine.ProcessEngineException)4 RepositoryService (org.camunda.bpm.engine.RepositoryService)4 Command (org.camunda.bpm.engine.impl.interceptor.Command)4 DeploymentCache (org.camunda.bpm.engine.impl.persistence.deploy.cache.DeploymentCache)4 InvocationContext (org.camunda.bpm.application.InvocationContext)3 AuthorizationException (org.camunda.bpm.engine.AuthorizationException)3 ProcessApplicationManager (org.camunda.bpm.engine.impl.application.ProcessApplicationManager)2 ProcessDefinitionEntity (org.camunda.bpm.engine.impl.persistence.entity.ProcessDefinitionEntity)2 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Callable (java.util.concurrent.Callable)1