org.activiti.engine.impl.interceptor.Command Java Examples
The following examples show how to use
org.activiti.engine.impl.interceptor.Command.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ProcessDefinitionInfoCache.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public ProcessDefinitionInfoCacheObject get(final String processDefinitionId) { ProcessDefinitionInfoCacheObject infoCacheObject = null; Command<ProcessDefinitionInfoCacheObject> cacheCommand = new Command<ProcessDefinitionInfoCacheObject>() { @Override public ProcessDefinitionInfoCacheObject execute(CommandContext commandContext) { return retrieveProcessDefinitionInfoCacheObject(processDefinitionId, commandContext); } }; if (Context.getCommandContext() != null) { infoCacheObject = retrieveProcessDefinitionInfoCacheObject(processDefinitionId, Context.getCommandContext()); } else { infoCacheObject = commandExecutor.execute(cacheCommand); } return infoCacheObject; }
Example #2
Source File: MessageEventsAndNewVersionDeploymentsTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private List<String> getExecutionIdsForMessageEventSubscription(final String messageName) { return managementService.executeCommand(new Command<List<String>>() { public List<String> execute(CommandContext commandContext) { EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext); query.eventType("message"); query.eventName(messageName); query.orderByCreated().desc(); List<EventSubscriptionEntity> eventSubscriptions = query.list(); List<String> executionIds = new ArrayList<String>(); for (EventSubscriptionEntity eventSubscription : eventSubscriptions) { executionIds.add(eventSubscription.getExecutionId()); } return executionIds; } }); }
Example #3
Source File: JobQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private void createJobWithoutExceptionMsg() { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor(); commandExecutor.execute(new Command<Void>() { public Void execute(CommandContext commandContext) { jobEntity = commandContext.getJobEntityManager().create(); jobEntity.setJobType(Job.JOB_TYPE_MESSAGE); jobEntity.setLockOwner(UUID.randomUUID().toString()); jobEntity.setRetries(0); StringWriter stringWriter = new StringWriter(); NullPointerException exception = new NullPointerException(); exception.printStackTrace(new PrintWriter(stringWriter)); jobEntity.setExceptionStacktrace(stringWriter.toString()); commandContext.getJobEntityManager().insert(jobEntity); assertNotNull(jobEntity.getId()); return null; } }); }
Example #4
Source File: JobQueryTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private void createJobWithoutExceptionStacktrace() { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor(); commandExecutor.execute(new Command<Void>() { public Void execute(CommandContext commandContext) { jobEntity = commandContext.getJobEntityManager().create(); jobEntity.setJobType(Job.JOB_TYPE_MESSAGE); jobEntity.setLockOwner(UUID.randomUUID().toString()); jobEntity.setRetries(0); jobEntity.setExceptionMessage("I'm supposed to fail"); commandContext.getJobEntityManager().insert(jobEntity); assertNotNull(jobEntity.getId()); return null; } }); }
Example #5
Source File: CustomMybatisXMLMapperTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testSelectTaskList() { // Create test data for (int i = 0; i < 5; i++) { createTask(i + "", null, null, 0); } List<CustomTask> tasks = managementService.executeCommand(new Command<List<CustomTask>>() { @SuppressWarnings("unchecked") @Override public List<CustomTask> execute(CommandContext commandContext) { return (List<CustomTask>) commandContext.getDbSqlSession().selectList("selectCustomTaskList"); } }); assertEquals(5, tasks.size()); // Cleanup deleteCustomTasks(tasks); }
Example #6
Source File: JobQueryTest.java From flowable-engine with Apache License 2.0 | 6 votes |
private void createJobWithoutExceptionStacktrace() { CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor(); commandExecutor.execute(new Command<Void>() { public Void execute(CommandContext commandContext) { JobEntityManager jobManager = commandContext.getJobEntityManager(); jobEntity = new JobEntity(); jobEntity.setJobType(Job.JOB_TYPE_MESSAGE); jobEntity.setRevision(1); jobEntity.setLockOwner(UUID.randomUUID().toString()); jobEntity.setRetries(0); jobEntity.setExceptionMessage("I'm supposed to fail"); jobManager.insert(jobEntity); assertNotNull(jobEntity.getId()); return null; } }); }
Example #7
Source File: MessageEventsAndNewVersionDeploymentsWithTenantIdTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private List<EventSubscriptionEntity> getAllEventSubscriptions() { return managementService.executeCommand(new Command<List<EventSubscriptionEntity>>() { public List<EventSubscriptionEntity> execute(CommandContext commandContext) { EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext); query.tenantId(TENANT_ID); query.orderByCreated().desc(); List<EventSubscriptionEntity> eventSubscriptionEntities = query.list(); for (EventSubscriptionEntity entity : eventSubscriptionEntities) { assertEquals("message", entity.getEventType()); assertNotNull(entity.getProcessDefinitionId()); } return eventSubscriptionEntities; } }); }
Example #8
Source File: MessageEventsAndNewVersionDeploymentsWithTenantIdTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private List<String> getExecutionIdsForMessageEventSubscription(final String messageName) { return managementService.executeCommand(new Command<List<String>>() { public List<String> execute(CommandContext commandContext) { EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext); query.eventType("message"); query.eventName(messageName); query.tenantId(TENANT_ID); query.orderByCreated().desc(); List<EventSubscriptionEntity> eventSubscriptions = query.list(); List<String> executionIds = new ArrayList<String>(); for (EventSubscriptionEntity eventSubscription : eventSubscriptions) { executionIds.add(eventSubscription.getExecutionId()); } return executionIds; } }); }
Example #9
Source File: MessageEventsAndNewVersionDeploymentsTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
private List<String> getExecutionIdsForMessageEventSubscription(final String messageName) { return managementService.executeCommand(new Command<List<String>>() { public List<String> execute(CommandContext commandContext) { EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext); query.eventType("message"); query.eventName(messageName); query.orderByCreated().desc(); List<EventSubscriptionEntity> eventSubscriptions = query.list(); List<String> executionIds = new ArrayList<String>(); for (EventSubscriptionEntity eventSubscription : eventSubscriptions) { executionIds.add(eventSubscription.getExecutionId()); } return executionIds; } }); }
Example #10
Source File: JobExecutorCmdHappyTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testJobCommandsWithMessage() { ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawProcessConfiguration(); CommandExecutor commandExecutor = activiti5ProcessEngineConfig.getCommandExecutor(); String jobId = commandExecutor.execute(new Command<String>() { public String execute(CommandContext commandContext) { JobEntity message = createTweetMessage("i'm coding a test"); commandContext.getJobEntityManager().send(message); return message.getId(); } }); Job job = managementService.createJobQuery().singleResult(); assertNotNull(job); assertEquals(jobId, job.getId()); assertEquals(0, tweetHandler.getMessages().size()); activiti5ProcessEngineConfig.getManagementService().executeJob(job.getId()); assertEquals("i'm coding a test", tweetHandler.getMessages().get(0)); assertEquals(1, tweetHandler.getMessages().size()); }
Example #11
Source File: ExecuteAsyncRunnable.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void run() { if (job == null) { job = processEngineConfiguration.getCommandExecutor().execute(new Command<JobEntity>() { @Override public JobEntity execute(CommandContext commandContext) { return commandContext.getJobEntityManager().findById(jobId); } }); } if (isHandledByActiviti5Engine()) { return; } boolean lockNotNeededOrSuccess = lockJobIfNeeded(); if (lockNotNeededOrSuccess) { executeJob(); unlockJobIfNeeded(); } }
Example #12
Source File: CustomMybatisXMLMapperTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testSelectTaskList() { // Create test data for (int i = 0; i < 5; i++) { createTask(String.valueOf(i), null, null, 0); } org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl activiti5ProcessEngineConfig = (org.activiti.engine.impl.cfg.ProcessEngineConfigurationImpl) processEngineConfiguration.getFlowable5CompatibilityHandler() .getRawProcessConfiguration(); List<CustomTask> tasks = activiti5ProcessEngineConfig.getManagementService().executeCommand(new Command<List<CustomTask>>() { @SuppressWarnings("unchecked") @Override public List<CustomTask> execute(CommandContext commandContext) { return (List<CustomTask>) commandContext.getDbSqlSession().selectList("selectCustomTaskList"); } }); assertEquals(5, tasks.size()); // Cleanup deleteCustomTasks(tasks); }
Example #13
Source File: CommandContextTest.java From flowable-engine with Apache License 2.0 | 6 votes |
public void testCommandContextGetCurrentAfterException() { try { CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor(); commandExecutor.execute(new Command<Object>() { public Object execute(CommandContext commandContext) { throw new IllegalStateException("here i come!"); } }); fail("expected exception"); } catch (IllegalStateException e) { // OK } assertNull(Context.getCommandContext()); }
Example #14
Source File: SpringTransactionInterceptor.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public <T> T execute(final CommandConfig config, final Command<T> command) { LOGGER.debug("Running command with propagation {}", config.getTransactionPropagation()); TransactionTemplate transactionTemplate = new TransactionTemplate(transactionManager); transactionTemplate.setPropagationBehavior(getPropagation(config)); T result = transactionTemplate.execute(new TransactionCallback<T>() { @Override public T doInTransaction(TransactionStatus status) { return next.execute(config, command); } }); return result; }
Example #15
Source File: MetaDataTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
public void testMetaData() { ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor().execute(new Command<Object>() { public Object execute(CommandContext commandContext) { // PRINT THE TABLE NAMES TO CHECK IF WE CAN USE METADATA INSTEAD // THIS IS INTENDED FOR TEST THAT SHOULD RUN ON OUR QA // INFRASTRUCTURE TO SEE IF METADATA // CAN BE USED INSTEAD OF PERFORMING A QUERY THAT MIGHT FAIL try { SqlSession sqlSession = commandContext.getDbSqlSession().getSqlSession(); ResultSet tables = sqlSession.getConnection().getMetaData().getTables(null, null, null, null); while (tables.next()) { ResultSetMetaData resultSetMetaData = tables.getMetaData(); int columnCount = resultSetMetaData.getColumnCount(); for (int i = 1; i <= columnCount; i++) { log.info("result set column {}|{}|{}|{}", i, resultSetMetaData.getColumnName(i), resultSetMetaData.getColumnLabel(i), tables.getString(i)); } log.info("-------------------------------------------------------"); } } catch (Exception e) { e.printStackTrace(); } return null; } }); }
Example #16
Source File: DefaultFlowable5CompatibilityHandler.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public ProcessDefinitionCacheEntry resolveProcessDefinition(final ProcessDefinition processDefinition) { try { final ProcessEngineConfigurationImpl processEngineConfig = (ProcessEngineConfigurationImpl) getProcessEngine().getProcessEngineConfiguration(); ProcessDefinitionCacheEntry cacheEntry = processEngineConfig.getCommandExecutor().execute(new Command<ProcessDefinitionCacheEntry>() { @Override public ProcessDefinitionCacheEntry execute(CommandContext commandContext) { return commandContext.getProcessEngineConfiguration().getDeploymentManager().resolveProcessDefinition(processDefinition); } }); return cacheEntry; } catch (org.activiti.engine.ActivitiException e) { handleActivitiException(e); return null; } }
Example #17
Source File: Application.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Bean CommandLineRunner customMybatisXmlMapper(final ManagementService managementService) { return new CommandLineRunner() { @Override public void run(String... args) throws Exception { String processDefinitionDeploymentId = managementService.executeCommand(new Command<String>() { @Override public String execute(CommandContext commandContext) { return (String) commandContext .getDbSqlSession() .selectOne("selectProcessDefinitionDeploymentIdByKey", "waiter"); } }); logger.info("Process definition deployment id = {}", processDefinitionDeploymentId); } }; }
Example #18
Source File: DefaultFlowable5CompatibilityHandler.java From flowable-engine with Apache License 2.0 | 6 votes |
@Override public void signalEventReceived(final SignalEventSubscriptionEntity signalEventSubscriptionEntity, final Object payload, final boolean async) { final ProcessEngineConfigurationImpl processEngineConfig = (ProcessEngineConfigurationImpl) getProcessEngine().getProcessEngineConfiguration(); processEngineConfig.getCommandExecutor().execute(new Command<Void>() { @Override public Void execute(CommandContext commandContext) { org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity activiti5SignalEvent = new org.activiti.engine.impl.persistence.entity.SignalEventSubscriptionEntity(); activiti5SignalEvent.setId(signalEventSubscriptionEntity.getId()); activiti5SignalEvent.setExecutionId(signalEventSubscriptionEntity.getExecutionId()); activiti5SignalEvent.setActivityId(signalEventSubscriptionEntity.getActivityId()); activiti5SignalEvent.setEventName(signalEventSubscriptionEntity.getEventName()); activiti5SignalEvent.setEventType(signalEventSubscriptionEntity.getEventType()); activiti5SignalEvent.setConfiguration(signalEventSubscriptionEntity.getConfiguration()); activiti5SignalEvent.setProcessDefinitionId(signalEventSubscriptionEntity.getProcessDefinitionId()); activiti5SignalEvent.setProcessInstanceId(signalEventSubscriptionEntity.getProcessInstanceId()); activiti5SignalEvent.setTenantId(signalEventSubscriptionEntity.getTenantId()); activiti5SignalEvent.setRevision(signalEventSubscriptionEntity.getRevision()); activiti5SignalEvent.eventReceived(payload, async); return null; } }); }
Example #19
Source File: FailedJobListener.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override public void execute(CommandContext commandContext) { CommandConfig commandConfig = commandExecutor.getDefaultConfig().transactionRequiresNew(); FailedJobCommandFactory failedJobCommandFactory = commandContext.getFailedJobCommandFactory(); Command<Object> cmd = failedJobCommandFactory.getCommand(jobId, exception); LOGGER.trace("Using FailedJobCommandFactory '{}' and command of type '{}'", failedJobCommandFactory.getClass(), cmd.getClass()); commandExecutor.execute(commandConfig, cmd); }
Example #20
Source File: EventSubscriptionQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
public void testQueryByActivityId() { CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor(); commandExecutor.execute(new Command<Void>() { public Void execute(CommandContext commandContext) { MessageEventSubscriptionEntity messageEventSubscriptionEntity1 = new MessageEventSubscriptionEntity(); messageEventSubscriptionEntity1.setEventName("messageName"); messageEventSubscriptionEntity1.setActivityId("someActivity"); messageEventSubscriptionEntity1.insert(); MessageEventSubscriptionEntity messageEventSubscriptionEntity2 = new MessageEventSubscriptionEntity(); messageEventSubscriptionEntity2.setEventName("messageName"); messageEventSubscriptionEntity2.setActivityId("someActivity"); messageEventSubscriptionEntity2.insert(); SignalEventSubscriptionEntity signalEventSubscriptionEntity3 = new SignalEventSubscriptionEntity(); signalEventSubscriptionEntity3.setEventName("messageName2"); signalEventSubscriptionEntity3.setActivityId("someOtherActivity"); signalEventSubscriptionEntity3.insert(); return null; } }); List<EventSubscriptionEntity> list = newEventSubscriptionQuery() .activityId("someOtherActivity") .list(); assertEquals(1, list.size()); list = newEventSubscriptionQuery() .activityId("someActivity") .eventType("message") .list(); assertEquals(2, list.size()); cleanDb(); }
Example #21
Source File: ProcessInstanceSuspensionTest.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void makeSureJobDue(final Job job) { CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor(); commandExecutor.execute(new Command<Void>() { public Void execute(CommandContext commandContext) { Date currentTime = processEngineConfiguration.getClock().getCurrentTime(); commandContext.getTimerJobEntityManager() .findJobById(job.getId()) .setDuedate(new Date(currentTime.getTime() - 10000)); return null; } }); }
Example #22
Source File: EventSubscriptionQueryTest.java From flowable-engine with Apache License 2.0 | 5 votes |
protected void cleanDb() { CommandExecutor commandExecutor = (CommandExecutor) processEngineConfiguration.getFlowable5CompatibilityHandler().getRawCommandExecutor(); commandExecutor.execute(new Command<Void>() { public Void execute(CommandContext commandContext) { final List<EventSubscriptionEntity> subscriptions = new EventSubscriptionQueryImpl(commandContext).list(); for (EventSubscriptionEntity eventSubscriptionEntity : subscriptions) { eventSubscriptionEntity.delete(); } return null; } }); }
Example #23
Source File: BaseJPARestTestCase.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb() throws Throwable { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = managementService.getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngineConfiguration.getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" " + tableName + ": " + count + " record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor(); commandExecutor.execute(new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getDbSqlSession(); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); if (exception != null) { throw exception; } else { Assert.fail(outputMessage.toString()); } } else { log.info("database was clean"); } }
Example #24
Source File: JobExecutorTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testBasicJobExecutorOperation() throws Exception { CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor(); commandExecutor.execute(new Command<Void>() { public Void execute(CommandContext commandContext) { JobManager jobManager = commandContext.getJobManager(); jobManager.execute(createTweetMessage("message-one")); jobManager.execute(createTweetMessage("message-two")); jobManager.execute(createTweetMessage("message-three")); jobManager.execute(createTweetMessage("message-four")); TimerJobEntityManager timerJobManager = commandContext.getTimerJobEntityManager(); timerJobManager.insert(createTweetTimer("timer-one", new Date())); timerJobManager.insert(createTweetTimer("timer-one", new Date())); timerJobManager.insert(createTweetTimer("timer-two", new Date())); return null; } }); GregorianCalendar currentCal = new GregorianCalendar(); currentCal.add(Calendar.MINUTE, 1); processEngineConfiguration.getClock().setCurrentTime(currentCal.getTime()); waitForJobExecutorToProcessAllJobs(8000L, 200L); Set<String> messages = new HashSet<String>(tweetHandler.getMessages()); Set<String> expectedMessages = new HashSet<String>(); expectedMessages.add("message-one"); expectedMessages.add("message-two"); expectedMessages.add("message-three"); expectedMessages.add("message-four"); expectedMessages.add("timer-one"); expectedMessages.add("timer-two"); assertEquals(new TreeSet<String>(expectedMessages), new TreeSet<String>(messages)); }
Example #25
Source File: CommandContextTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testCommandContextGetCurrentAfterException() { try { processEngineConfiguration.getCommandExecutor().execute(new Command<Object>() { public Object execute(CommandContext commandContext) { throw new IllegalStateException("here i come!"); } }); fail("expected exception"); } catch (IllegalStateException e) { // OK } assertNull(Context.getCommandContext()); }
Example #26
Source File: CustomMybatisXMLMapperTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testSelectOneTask() { // Create test data for (int i = 0; i < 4; i++) { createTask(i + "", null, null, 0); } final String taskId = createTask("4", null, null, 0); CustomTask customTask = managementService.executeCommand(new Command<CustomTask>() { @Override public CustomTask execute(CommandContext commandContext) { return (CustomTask) commandContext.getDbSqlSession().selectOne("selectOneCustomTask", taskId); } }); assertEquals("4", customTask.getName()); // test default query as well List<Task> tasks = taskService.createTaskQuery().list(); assertEquals(5, tasks.size()); Task task = taskService.createTaskQuery().taskName("2").singleResult(); assertEquals("2", task.getName()); // Cleanup deleteTasks(taskService.createTaskQuery().list()); }
Example #27
Source File: SignalEventsAndNewVersionDeploymentsTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private List<EventSubscriptionEntity> getAllEventSubscriptions() { return managementService.executeCommand(new Command<List<EventSubscriptionEntity>>() { public List<EventSubscriptionEntity> execute(CommandContext commandContext) { EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext); query.orderByCreated().desc(); List<EventSubscriptionEntity> eventSubscriptionEntities = query.list(); for (EventSubscriptionEntity eventSubscriptionEntity : eventSubscriptionEntities) { assertEquals("signal", eventSubscriptionEntity.getEventType()); assertNotNull(eventSubscriptionEntity.getProcessDefinitionId()); } return eventSubscriptionEntities; } }); }
Example #28
Source File: MessageEventsAndNewVersionDeploymentsTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private List<EventSubscriptionEntity> getAllEventSubscriptions() { return managementService.executeCommand(new Command<List<EventSubscriptionEntity>>() { public List<EventSubscriptionEntity> execute(CommandContext commandContext) { EventSubscriptionQueryImpl query = new EventSubscriptionQueryImpl(commandContext); query.orderByCreated().desc(); List<EventSubscriptionEntity> eventSubscriptionEntities = query.list(); for (EventSubscriptionEntity entity : eventSubscriptionEntities) { assertEquals("message", entity.getEventType()); assertNotNull(entity.getProcessDefinitionId()); } return eventSubscriptionEntities; } }); }
Example #29
Source File: BpmnDeploymentTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void testDiagramCreationDisabled() { // disable diagram generation processEngineConfiguration.setCreateDiagramOnDeploy(false); try { repositoryService.createDeployment().addClasspathResource("org/activiti/engine/test/bpmn/parse/BpmnParseTest.testParseDiagramInterchangeElements.bpmn20.xml").deploy(); // Graphical information is not yet exposed publicly, so we need to // do some plumbing CommandExecutor commandExecutor = processEngineConfiguration.getCommandExecutor(); ProcessDefinition processDefinition = commandExecutor.execute(new Command<ProcessDefinition>() { public ProcessDefinition execute(CommandContext commandContext) { return Context.getProcessEngineConfiguration().getDeploymentManager().findDeployedLatestProcessDefinitionByKey("myProcess"); } }); assertNotNull(processDefinition); BpmnModel processModel = repositoryService.getBpmnModel(processDefinition.getId()); assertEquals(14, processModel.getMainProcess().getFlowElements().size()); assertEquals(7, processModel.getMainProcess().findFlowElementsOfType(SequenceFlow.class).size()); // Check that no diagram has been created List<String> resourceNames = repositoryService.getDeploymentResourceNames(processDefinition.getDeploymentId()); assertEquals(1, resourceNames.size()); repositoryService.deleteDeployment(repositoryService.createDeploymentQuery().singleResult().getId(), true); } finally { processEngineConfiguration.setCreateDiagramOnDeploy(true); } }
Example #30
Source File: AbstractMuleTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Each test is assumed to clean up all DB content it entered. After a test method executed, this method scans all tables to see if the DB is completely clean. It throws AssertionFailed in case the * DB is not clean. If the DB is not clean, it is cleaned by performing a create a drop. */ protected void assertAndEnsureCleanDb(ProcessEngine processEngine) throws Exception { log.debug("verifying that db is clean after test"); Map<String, Long> tableCounts = processEngine.getManagementService().getTableCount(); StringBuilder outputMessage = new StringBuilder(); for (String tableName : tableCounts.keySet()) { String tableNameWithoutPrefix = tableName.replace(processEngine.getProcessEngineConfiguration().getDatabaseTablePrefix(), ""); if (!TABLENAMES_EXCLUDED_FROM_DB_CLEAN_CHECK.contains(tableNameWithoutPrefix)) { Long count = tableCounts.get(tableName); if (count != 0L) { outputMessage.append(" " + tableName + ": " + count + " record(s) "); } } } if (outputMessage.length() > 0) { outputMessage.insert(0, "DB NOT CLEAN: \n"); log.error(EMPTY_LINE); log.error(outputMessage.toString()); log.info("dropping and recreating db"); CommandExecutor commandExecutor = ((ProcessEngineImpl) processEngine).getProcessEngineConfiguration().getCommandExecutor(); CommandConfig config = new CommandConfig().transactionNotSupported(); commandExecutor.execute(config, new Command<Object>() { public Object execute(CommandContext commandContext) { DbSqlSession session = commandContext.getSession(DbSqlSession.class); session.dbSchemaDrop(); session.dbSchemaCreate(); return null; } }); Assert.fail(outputMessage.toString()); } else { log.info("database was clean"); } }