@Test
  public void testBatchAddInvalidState2() {
    // Add one more TestDummyNode and related Edges to the existing graph. However we attach the
    // TestDummyNode
    // to the existing StartProcessNode. This is invalid as a StartProcessNode can only contain one
    // outgoing Edge
    // and hence the batch should fail.
    final TestDummyNode testNode1 = new TestDummyNode();
    final BpmnEdge testEdge1 = new BpmnEdgeImpl(new DefaultRoleImpl("general_edge"));
    final AddGraphNodeCommand testCmd1 = new AddGraphNodeCommand(process, testNode1);
    final AddEdgeCommand testCmd2 = new AddEdgeCommand(node1, testNode1, testEdge1);
    final Results results1 =
        commandManager.execute(ruleManager, new BatchCommand(testCmd1, testCmd2));

    assertNotNull(results1);
    assertEquals(1, results1.getMessages().size());
    assertEquals(1, results1.getMessages(ResultType.ERROR).size());

    assertEquals(3, process.size());
    assertProcessNotContainsNodes(process, testNode1);
    assertEquals(1, node2.getOutEdges().size());
    assertNodeContainsOutgoingEdges(node2, e2);

    assertEquals(0, testNode1.getInEdges().size());
    assertEquals(0, testNode1.getOutEdges().size());
  }
  @Test
  public void testBatchAddInvalidState1() {
    // Add one more TestDummyNode and another EndProcessNode plus related Edges to the existing
    // graph.
    // This is invalid as a Process can only contain one EndProcessNode and hence the batch should
    // fail.
    final TestDummyNode testNode1 = new TestDummyNode();
    final EndProcessNode testNode2 = new EndProcessNode();
    final BpmnEdge testEdge1 = new BpmnEdgeImpl(new DefaultRoleImpl("general_edge"));
    final BpmnEdge testEdge2 = new BpmnEdgeImpl(new DefaultRoleImpl("general_edge"));
    final AddGraphNodeCommand testCmd1 = new AddGraphNodeCommand(process, testNode1);
    final AddGraphNodeCommand testCmd2 = new AddGraphNodeCommand(process, testNode2);
    final AddEdgeCommand testCmd3 = new AddEdgeCommand(node2, testNode1, testEdge1);
    final AddEdgeCommand testCmd4 = new AddEdgeCommand(testNode1, testNode2, testEdge2);
    final Results results1 =
        commandManager.execute(
            ruleManager, new BatchCommand(testCmd1, testCmd2, testCmd3, testCmd4));

    assertNotNull(results1);
    assertEquals(1, results1.getMessages().size());
    assertEquals(1, results1.getMessages(ResultType.ERROR).size());

    assertEquals(3, process.size());
    assertProcessNotContainsNodes(process, testNode1, testNode2);
    assertEquals(1, node2.getOutEdges().size());
    assertNodeContainsOutgoingEdges(node2, e2);

    assertEquals(0, testNode1.getInEdges().size());
    assertEquals(0, testNode1.getOutEdges().size());
    assertEquals(0, testNode2.getInEdges().size());
  }