@Test
  public void testValidateContext() {
    processDefinitionName = "process1";
    expect(processFactory.createProcessModel(processName, processDefinitionName, contextParameters))
        .andReturn(mockProcessModel);
    expect(processDefinitionFactory.getProcessDefinition(processDefinitionName))
        .andReturn(mockProcessDefinition);
    final Map params = new HashMap<String, ContextParameterDeclaration>();
    final Map nodes = new HashMap<String, Node>();

    final Node node =
        new Node() {

          @Override
          public void trigger(final BusinessProcessModel process) {
            // null
          }

          @Override
          public String execute(final BusinessProcessModel process)
              throws RetryLaterException, NodeExecutionException {
            return "OK";
          }

          @Override
          public String getId() {
            return "NodeId";
          }
        };
    nodes.put("NodeId", node);
    mockProcessDefinition =
        new ProcessDefinition(
            processDefinitionName,
            node,
            null,
            nodes,
            params,
            "de.hybris.processengine.model.BusinessProcessModel") {
          // null
        };

    final DefaultBusinessProcessService defaultService = new DefaultBusinessProcessService();
    try {
      defaultService.validateContext(mockProcessModel, mockProcessDefinition);
    } catch (final UnsatisfiedContextParameterException exception) {
      fail("validateContext throws " + exception.toString());
    }
  }
  /** Test of correct use of startProcess */
  @Test(expected = UnsatisfiedContextParameterException.class)
  public void testStartProcessValidationException() {
    expect(processFactory.createProcessModel(processName, processDefinitionName, contextParameters))
        .andReturn(mockProcessModel);
    expect(processDefinitionFactory.getProcessDefinition(processDefinitionName))
        .andReturn(mockProcessDefinition);

    replay(processFactory, processDefinitionFactory);
    final DefaultBusinessProcessService defaultService =
        new DefaultBusinessProcessService() {
          @Override
          protected void validateContext(
              final BusinessProcessModel processModel, final ProcessDefinition processDefinition) {
            assertEquals(
                "mockProcessModel not equals to processModel", mockProcessModel, processModel);
            assertEquals(
                "mockProcessDefinition not equals to processDefinition",
                mockProcessDefinition,
                processDefinition);
            throw new UnsatisfiedContextParameterException();
          }
        };
    defaultService.setProcessFactory(processFactory);
    defaultService.setProcessDefinitionFactory(processDefinitionFactory);
    defaultService.setModelService(modelService);
    defaultService.setTransactionTemplate(transactionTemplate);

    defaultService.startProcess(processName, processDefinitionName, contextParameters);
    verify(processFactory, processDefinitionFactory);
  }
  /** Test of correct use of startProcess */
  @Test
  public void testStartProcess() {
    expect(processFactory.createProcessModel(processName, processDefinitionName, contextParameters))
        .andReturn(mockProcessModel);
    expect(processDefinitionFactory.getProcessDefinition(processDefinitionName))
        .andReturn(mockProcessDefinition);

    modelService.save(mockProcessModel);

    mockProcessDefinition.start(mockProcessModel);

    replay(processFactory, processDefinitionFactory, modelService);
    final DefaultBusinessProcessService defaultService =
        new DefaultBusinessProcessService() {
          @Override
          protected void validateContext(
              final BusinessProcessModel processModel, final ProcessDefinition processDefinition) {
            assertEquals(
                "mockProcessModel not equals to processModel", mockProcessModel, processModel);
            assertEquals(
                "mockProcessDefinition not equals to processDefinition",
                mockProcessDefinition,
                processDefinition);
          }
        };
    defaultService.setProcessFactory(processFactory);
    defaultService.setProcessDefinitionFactory(processDefinitionFactory);
    defaultService.setModelService(modelService);
    defaultService.setTransactionTemplate(transactionTemplate);

    defaultService.startProcess(processName, processDefinitionName, contextParameters);
    verify(processFactory, processDefinitionFactory, modelService);
    assertEquals(
        "mockProcessModel.getState() not in RUNNING state",
        ProcessState.RUNNING,
        mockProcessModel.getState());
  }