Search in sources :

Example 1 with DeploymentEventListener

use of org.jbpm.services.api.DeploymentEventListener in project jbpm by kiegroup.

the class PostDeploymentServiceTest method testDuplicatedDeployment.

@Test
public void testDuplicatedDeployment() {
    assertNotNull(deploymentService);
    ((KModuleDeploymentService) deploymentService).addListener(new DeploymentEventListener() {

        @Override
        public void onUnDeploy(DeploymentEvent event) {
        }

        @Override
        public void onDeploy(DeploymentEvent event) {
            throw new IllegalArgumentException("On purpose");
        }

        @Override
        public void onActivate(DeploymentEvent event) {
        }

        @Override
        public void onDeactivate(DeploymentEvent event) {
        }
    });
    DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
    try {
        deploymentService.deploy(deploymentUnit);
        units.add(deploymentUnit);
        fail("Deployment should fail due to post process failuer - see ThrowExceptionOnDeploymentEvent");
    } catch (RuntimeException e) {
    }
    DeployedUnit deployedGeneral = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
    assertNull(deployedGeneral);
    assertFalse(RuntimeManagerRegistry.get().isRegistered(deploymentUnit.getIdentifier()));
}
Also used : KModuleDeploymentService(org.jbpm.kie.services.impl.KModuleDeploymentService) DeployedUnit(org.jbpm.services.api.model.DeployedUnit) DeploymentEventListener(org.jbpm.services.api.DeploymentEventListener) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentUnit(org.jbpm.services.api.model.DeploymentUnit) KModuleDeploymentUnit(org.jbpm.kie.services.impl.KModuleDeploymentUnit) DeploymentEvent(org.jbpm.services.api.DeploymentEvent) AbstractKieServicesBaseTest(org.jbpm.kie.test.util.AbstractKieServicesBaseTest) Test(org.junit.Test)

Aggregations

KModuleDeploymentService (org.jbpm.kie.services.impl.KModuleDeploymentService)1 KModuleDeploymentUnit (org.jbpm.kie.services.impl.KModuleDeploymentUnit)1 AbstractKieServicesBaseTest (org.jbpm.kie.test.util.AbstractKieServicesBaseTest)1 DeploymentEvent (org.jbpm.services.api.DeploymentEvent)1 DeploymentEventListener (org.jbpm.services.api.DeploymentEventListener)1 DeployedUnit (org.jbpm.services.api.model.DeployedUnit)1 DeploymentUnit (org.jbpm.services.api.model.DeploymentUnit)1 Test (org.junit.Test)1