Package org.apache.agila.model

Examples of org.apache.agila.model.Node


    public void testAddNodes() {

        BusinessProcessImpl bpl = new BusinessProcessImpl();

        Node n = new BaseNodeImpl() {

            public Connection[] doEnd( NodeContext ctx ) {
                return null;
            }
        };
        n.setNodeId(new NodeID(1));

        bpl.addNode(n);

        assertEquals(n, bpl.getNode(new NodeID(1)));
    }
View Full Code Here


        bpl.addNode( createNode( new NodeID(1)));
        bpl.addNode( createNode(new NodeID(2)));

        bpl.addConnection(1, 2, "");
        Node n1 = bpl.getNode( new NodeID(1) );
        Node n2 = bpl.getNode( new NodeID(2) );

        assertNotNull( n1.getOutboundConnections() );
        assertNotNull( n2.getInboundConnections() );

    }
View Full Code Here

        bpl.setGraphAsXML( "<process-model name='sample Process'/>" );
        assertEquals( "<process-model name='sample Process'/>", bpl.getGraphAsXML() );
    }

    private Node createNode( NodeID nodeID ) {
        Node n = new BaseNodeImpl() {

            public Connection[] doEnd( NodeContext ctx ) {
                return null;
            }
        };

        n.setNodeId(nodeID);
        return n;
    }
View Full Code Here

    public void testStart() {
        // get a business process id
        BusinessProcessImpl bProcess = new BusinessProcessImpl();
        String graphName = "Graph" + count++;
        bProcess.setName(graphName);
        Node rootNode = new BaseNodeImpl() {

            public Connection[] doEnd(NodeContext ctx) {
                return null;
            }
        };

        rootNode.setNodeId(new NodeID(1));
        rootNode.setDisplayName("root");

        bProcess.setRoot(rootNode);
        BusinessProcessID bpId = bpService.addGraph(bProcess);

        // then create a map of parameters
View Full Code Here

    public void testNextToken() {
       
        // retrieve a token from the service given the ff. instance and node id's
        InstanceID instanceId = new InstanceID(instanceCounter++);
       
        Node parentNode = new FullBaseNode();
        parentNode.setDisplayName("parent_node");
        parentNode.setNodeId(new NodeID(nodeCounter++));
       
        Token parentToken = tokenService.newToken(instanceId, parentNode.getNodeId(), Token.PRE);
        TokenID tokenId = parentToken.getTokenID();
       
        // create n child nodes
        Node[] childrenNode = new Node[5];
        for(int i = 0; i < childrenNode.length; i++) {
            Node childNode = new FullBaseNode();
            childNode.setDisplayName("child_node_"+ i);
            childNode.setNodeId(new NodeID(nodeCounter++));

            childrenNode[i] = childNode;
        }
       
        // create childrenNode.length connections
        Connection[] connections = new Connection[childrenNode.length];
        for(int i = 0; i < connections.length; i++) {
            Connection connection = new ConnectionImpl("connection_"+ i);           
           
            connection.setParentNode(parentNode);
            connection.setChildNode(childrenNode[i]);
           
            parentNode.addOutboundConnection(connection);
            childrenNode[i].addInboundConnection(connection);
           
            connections[i] = connection;
        }
       
        // tokens are created in the order of connections -- this test will be using that fact.
        // question: would it be proper to do so? Is that a property of the engine?
        Token[] tokens = tokenService.nextToken(connections, parentToken);
       
        for(int i = 0; i < tokens.length; i++) {
            Token token = tokens[i];
           
            InstanceID instance_id = token.getInstanceID();
            NodeID currentNodeId = token.getCurrentNodeID();
            int currentState = token.getCurrentState();
            Node currentNode = childrenNode[i];
            Connection[] inbound = currentNode.getInboundConnections();
           
            assertNotNull(instance_id);
            assertEquals(instanceId, instance_id);
            // here is where we use the ordering
            assertEquals(currentNode.getNodeId(), currentNodeId);
            assertEquals(Token.PRE, currentState);
            assertNotNull(inbound);
            assertEquals(1, inbound.length);
            assertNotNull(inbound[0].getParentNode());
            assertSame(parentNode, inbound[0].getParentNode());
View Full Code Here

      connectionImpl.setDisplayName("foo");
      assertEquals("foo",connectionImpl.getDisplayName());
    }
   
    public void testParentNode(){
      Node n = createNode(1);
      connectionImpl.setParentNode(n);
      assertEquals(n,connectionImpl.getParentNode());
    }
View Full Code Here

      connectionImpl.setParentNode(n);
      assertEquals(n,connectionImpl.getParentNode());
    }
   
    public void testChildNode(){
      Node child = createNode(1);
      connectionImpl.setChildNode(child);
      assertEquals(child,connectionImpl.getChildNode());
    }
View Full Code Here

    public void testTraverse(){
      TokenService tokenService = new TokenServiceImpl();
      InstanceID instanceId = new InstanceID(1);
      Token token = tokenService.newToken(instanceId, new NodeID(2), Token.PRE);
     
      Node child = createNode(50);
      connectionImpl.setChildNode(child);
           
      connectionImpl.traverse(token);
      assertEquals(50,token.getCurrentNodeID().getID());
    }
View Full Code Here

      connectionImpl.traverse(token);
      assertEquals(50,token.getCurrentNodeID().getID());
    }
   
    private Node createNode(int nodeID) {
      Node n = new BaseNodeImpl() {

            public Connection[] doEnd(NodeContext ctx) {
                return null;
            }
        };
        n.setNodeId(new NodeID(nodeID));
        return n;
    }
View Full Code Here

        // create a business process with a root node and get a business process
        // id
        BusinessProcessImpl bProcess = new BusinessProcessImpl();
        String graphName = "Graph1";
        bProcess.setName( graphName );
        Node rootNode = new BaseNodeImpl() {

            public Connection[] doEnd( NodeContext ctx ) {
                return null;
            }
        };

        rootNode.setNodeId(new NodeID(1));
        rootNode.setDisplayName("root");

        bProcess.setRoot( rootNode );

        // add the business process graph
        BusinessProcessID bpId = bpService.addGraph( bProcess );
View Full Code Here

TOP

Related Classes of org.apache.agila.model.Node

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.