use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class DeploymentServiceWithSyncTest method testDeactivateAndActivateOfProcessesBySync.
@Test
public void testDeactivateAndActivateOfProcessesBySync() throws Exception {
CoundDownDeploymentListener countDownListener = configureListener(2, false, false, true, true);
Collection<DeployedUnit> deployed = deploymentService.getDeployedUnits();
assertNotNull(deployed);
assertEquals(0, deployed.size());
KModuleDeploymentUnit unit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION);
deploymentService.deploy(unit);
units.add(unit);
deployed = deploymentService.getDeployedUnits();
assertNotNull(deployed);
assertEquals(1, deployed.size());
assertTrue(deployed.iterator().next().isActive());
store.deactivateDeploymentUnit(unit);
countDownListener.waitTillCompleted(10000);
deployed = deploymentService.getDeployedUnits();
assertNotNull(deployed);
assertEquals(1, deployed.size());
assertFalse(deployed.iterator().next().isActive());
store.activateDeploymentUnit(unit);
countDownListener.reset(1);
countDownListener.waitTillCompleted(10000);
deployed = deploymentService.getDeployedUnits();
assertNotNull(deployed);
assertEquals(1, deployed.size());
assertTrue(deployed.iterator().next().isActive());
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesFromOrderPackage.
@Test
public void testDeploymentOfProcessesFromOrderPackage() {
prepare("order.repo.processes.general");
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION + ":" + "KBase-test" + ":" + "ksession-test", deployed.getDeploymentUnit().getIdentifier());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "Import");
assertNotNull(process);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class FilteredKModuleDeploymentServiceTest method verifyDeployedUnitContainsCorrectClasses.
private void verifyDeployedUnitContainsCorrectClasses(DeploymentUnit deploymentUnit) {
DeployedUnit deployedUnit = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
DeploymentDescriptor descriptor = ((KModuleDeploymentUnit) deployedUnit.getDeploymentUnit()).getDeploymentDescriptor();
boolean limitClasses = descriptor.getLimitSerializationClasses();
boolean unAnnotatedClassesFound = false;
for (Class<?> depdClass : deployedUnit.getDeployedClasses()) {
Annotation[] declAnnos = depdClass.getDeclaredAnnotations();
boolean xmlOrRemotAnnoFound = false;
for (Annotation depdClassAnno : declAnnos) {
Class annoType = depdClassAnno.annotationType();
if (XmlRootElement.class.equals(annoType) || Remotable.class.equals(annoType)) {
xmlOrRemotAnnoFound = true;
break;
}
}
assertTrue("Expected to find annotations on " + depdClass.getSimpleName(), (xmlOrRemotAnnoFound && limitClasses) || !limitClasses);
if (!xmlOrRemotAnnoFound) {
unAnnotatedClassesFound = true;
}
}
assertTrue("Expected to find unannotated classes in " + deployedUnit.getDeploymentUnit().getIdentifier(), (limitClasses && !unAnnotatedClassesFound) || (!limitClasses && unAnnotatedClassesFound));
if (limitClasses) {
try {
JAXBContext.newInstance(deployedUnit.getDeployedClasses().toArray(new Class[0]));
} catch (JAXBException e) {
e.printStackTrace();
fail("JAXBContext creation with deployed unit classes failed: " + e.getMessage());
}
}
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class FilteredKModuleDeploymentServiceTest method testDeploymentOfProcessesFromCustomerPackage.
@Test
public void testDeploymentOfProcessesFromCustomerPackage() {
prepare("customer.repo.processes.general");
assertNotNull(deploymentService);
DeploymentUnit deploymentUnit = new KModuleDeploymentUnit(GROUP_ID, ARTIFACT_ID, VERSION, "KBase-test", "ksession-test");
deploymentService.deploy(deploymentUnit);
units.add(deploymentUnit);
DeployedUnit deployed = deploymentService.getDeployedUnit(deploymentUnit.getIdentifier());
assertNotNull(deployed);
assertNotNull(deployed.getDeploymentUnit());
assertNotNull(deployed.getRuntimeManager());
assertEquals(GROUP_ID + ":" + ARTIFACT_ID + ":" + VERSION + ":" + "KBase-test" + ":" + "ksession-test", deployed.getDeploymentUnit().getIdentifier());
assertNotNull(runtimeDataService);
Collection<ProcessDefinition> processes = runtimeDataService.getProcesses(new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
processes = runtimeDataService.getProcessesByFilter("custom", new QueryContext());
assertNotNull(processes);
assertEquals(1, processes.size());
processes = runtimeDataService.getProcessesByDeploymentId(deploymentUnit.getIdentifier(), new QueryContext());
assertNotNull(processes);
assertEquals(2, processes.size());
ProcessDefinition process = runtimeDataService.getProcessesByDeploymentIdProcessId(deploymentUnit.getIdentifier(), "customtask");
assertNotNull(process);
}
use of org.jbpm.kie.services.impl.KModuleDeploymentUnit in project jbpm by kiegroup.
the class FilteredKModuleDeploymentServiceTest method testSerializationClassesLimitedInDeploymentItself.
@Test
public void testSerializationClassesLimitedInDeploymentItself() {
String groupId = "org.test";
String artifactId = "jbpm-kie-services-filter-test";
String version = VERSION;
FluentKieModuleDeploymentHelper.newFluentInstance().setGroupId(groupId).setArtifactId(artifactId).setVersion(version).addClass(Building.class, House.class, Person.class, OtherPerson.class, Thing.class).createKieJarAndDeployToMaven();
KModuleDeploymentUnit limitDeploymentUnit = new KModuleDeploymentUnit(groupId, artifactId, version);
FluentKieModuleDeploymentHelper.newFluentInstance().setGroupId(groupId).setArtifactId(artifactId + "-all").setVersion(version).addClass(Building.class, House.class, Person.class, OtherPerson.class, Thing.class).createKieJarAndDeployToMaven();
KModuleDeploymentUnit allDeploymentUnit = new KModuleDeploymentUnit(groupId, artifactId + "-all", version);
configureServices();
DeploymentDescriptor depDesc = new DeploymentDescriptorImpl().getBuilder().setLimitSerializationClasses(true).get();
limitDeploymentUnit.setDeploymentDescriptor(depDesc);
deploymentService.deploy(limitDeploymentUnit);
verifyDeployedUnitContainsCorrectClasses(limitDeploymentUnit);
depDesc = new DeploymentDescriptorImpl().getBuilder().setLimitSerializationClasses(false).get();
allDeploymentUnit.setDeploymentDescriptor(depDesc);
deploymentService.deploy(allDeploymentUnit);
verifyDeployedUnitContainsCorrectClasses(allDeploymentUnit);
}
Aggregations