Package org.apache.agila.impl

Source Code of org.apache.agila.impl.BusinessProcessImplTestCase

/*
* Copyright 2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*     http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.agila.impl;

import junit.framework.TestCase;
import org.apache.agila.model.BusinessProcess;
import org.apache.agila.model.BusinessProcessID;
import org.apache.agila.model.Connection;
import org.apache.agila.model.Node;
import org.apache.agila.model.NodeContext;
import org.apache.agila.model.NodeID;
import org.apache.agila.model.node.BaseNodeImpl;
import org.apache.agila.model.node.StartNode;

public class BusinessProcessImplTestCase extends TestCase {

    /**
     * Test the BusinessProcessImpl constructor. XML graph should not be null.
     */
    public void testGraphNotNull() {
        BusinessProcessImpl businessProcess = new BusinessProcessImpl();
        businessProcess.setBusinessProcessID( new BusinessProcessID( 1 ) );
        businessProcess.setName( "process" );
        businessProcess.setRoot( new StartNode() );
        businessProcess.setGraphAsXML( "<process-model name='sample Process'/>" );

        BusinessProcess bizProc = new BusinessProcessImpl( businessProcess );
       
        assertNotNull( bizProc.getGraphAsXML() );
    }

    public void testSetName() {

        BusinessProcessImpl bpl = new BusinessProcessImpl();

        bpl.setName( "process" );
        assertEquals( "process", bpl.getName() );
    }

    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)));
    }

    public void testAddConnections() {

        BusinessProcessImpl bpl = new BusinessProcessImpl();

        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() );

    }

    public void testSetGraphAsXML() {
        BusinessProcessImpl bpl = new BusinessProcessImpl();

        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;
    }
}
TOP

Related Classes of org.apache.agila.impl.BusinessProcessImplTestCase

TOP
Copyright © 2018 www.massapi.com. 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.