<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="spec.xsl" ?>
<spec title="XML Tools: Analysis View Test Specification (not finished)" version="1.2" last-updated="10 April 2006" author="Daria Titova" author-email="daria_titova@netbeans.org">
	<intro>
           ***This specification is not finished.*** TBD: add usecases for new queries.
	   This specification provides usecases of Analysis View features of the XML Tools in NetBeans Enterprise Pack 5.5 Preview.
        This specification is based on XML Schema Analysis View specification derived by developers. 
        This specification uses Purchase Order Schema from the IDE as a sample of XML schema. For testing needs any other XML schema may be used.
	</intro>
	<caseblock name="Open Purchase Order Schema">
		<purpose> Open Sample XML Schema to test Analysis View with.</purpose>
		<setup> Run IDE. A JavaApplication project should be opened. In this case JavaApplication project named 'JavaApplication1' is opened.</setup>
		<usecase name="Opening the Purchase Order Schema Sample">
			<action>In the Projects window, expand the JavaApplication1 project node and select the Source Packages node.</action>
			<action>Right-click Source Packages node and choose New > File/Folder.</action>
			<action>In "New File" dialog in the Categories list, expand the XML node and select Sample Schemas.</action>
			<action>In the File Types list, select Purchase Order Schema and click Next.</action>
			<action>Type 'po' in File Name field, accept other defaults and click Finish.</action>
			<result>Result of step 2: "New File" dialog is opened. The Project drop-down list contains the name of the project JavaApplication1.</result>
			<result>Result of step 5: In the Projects window, the Source Packages node contains a subnode labeled po.xsd under &lt;default package&gt;, which is selected. The Source Editor contains a tab for the XML Schema file, po.xsd, which has three buttons: Schema - selected, Analysis, and Source.</result>
		</usecase>
		<usecase name="Analysis View">
			<action>In the Source Editor of po schema click on Analysis button to switch to Analysis View.</action>
			<result>First column of Analysis View contains list of 3 items: Show usages of a primitive type, Find Substitution Groups, Show derivations of a Global Complex Type.</result>
		</usecase>
	</caseblock>
	<caseblock name="Analysis View: Show usages of a primitive type Query">
		<purpose> Checking Analysis View Show usages of a primitive type feature</purpose>
		<setup> Analysis View of Purchase Order Schema Sample should be opened.</setup>
		<usecase name="Show usages of a primitive type Query">
			<action>In Analysis View of po schema select Show usages of a primitive type item in the first column.</action>
			<result>The second column with tree of primitive types should appear.</result>
		</usecase>
                <usecase name="A primitive type is not used in PO">
			<action>In the second column select a primitive type that is not used in PO schema, e.g. anyURI.</action>
                        <action>Click Show Usages button under primitive types tree.</action>
			<result>In the third column graph with 1 node should appear: anyURI query node.</result>
		</usecase>
                <usecase name="A primitive type is used in PO">
			<action>In the second column select a primitive type that is used in PO schema, e.g. date.</action>
                        <action>Click Show Usages button under primitive types tree.</action>
			<result>In the third column graph with query node; usage nodes; file node; and other nodes in the path from the usage node to its penultimate-level ancestor, which is a global component under the schema root should appear. 7 nodes: date query node, orderDate and shipDate usage nodes, item, Items, PurchaseOrderType nodes, po.xsd file node.</result>
                        <result>Usage nodes should have generalization links to the query node. orderDate and shipDate usage nodes should have generalization links to date query node.</result>
                        <result>Nodes in the path from the usage node to its penultimate-level ancestor should have composition links to their ancestor. Pair of nodes orderDate-PurchaseOrderType, shipDate-item, item-Items should have composition link.</result>
                        <result>Nodes that are penultimate-level ancestors should have composition links to file node. PurchaseOrderType and Items nodes should have composition link to po.xsd file node.</result>
                        <result>File node should have file link to the query node. po.xsd file node should have file link to date query node.</result>
		</usecase>
                <usecase name="A primitive type: double-click">
			<action>In the second column double-click a primitive type node.</action>
			<result>In the third column appropriate graph should appear.</result>
		</usecase>
	</caseblock>
        <caseblock name="Analysis View: Find Substitution Groups Query">
		<purpose> Checking Analysis View Find Substitution Groups feature</purpose>
		<setup> Analysis View of Purchase Order Schema Sample should be opened.</setup>
		<usecase name="Add Substitution Group">
			<action>Switch to Source View of the po schema.</action>
                        <action>Add the following global element: "&lt;xsd:element name="cmntSubst" substitutionGroup="comment" type="xsd:string"/&gt;".</action>
                        <action>Switch to Analysis View of the po schema.</action>
			<result>Adding cmntSubst global element should not broke schema.</result>
		</usecase>
                <usecase name="Find Substitution Groups Query">
			<action>In Analysis View of po schema select Find Substitution Groups item in the first column.</action>
                        <action>Click Find Substitution Groups button in the second column.</action>
			<result>Result of step 1: in the second column Find Substitution Groups button should appear</result>
                        <result>Result of step 2: in the third column graph with head node and all its substitutions linked by generalization edge should appear. 2 nodes should appear: comment, cmntSubs. cmntSubs node should have generalization link to comment node</result>
		</usecase>
	</caseblock>
        <caseblock name="Analysis View: Show derivations of a Global Complex Type">
		<purpose> Checking Analysis View Show derivations of a Global Complex Type query feature</purpose>
		<setup> Analysis View of Purchase Order Schema Sample should be opened.</setup>
		<usecase name="Add restriction type">
			<action>Switch to Source View of the po schema.</action>
			<action>Add restriction of USAddress type: "&lt;xsd:complexType name="CAdress"&gt;
        &lt;xsd:complexContent&gt;
            &lt;xsd:restriction base="USAddress"&gt;
                &lt;xsd:sequence&gt;
                    &lt;xsd:element name="name"   type="xsd:string"/&gt;
                    &lt;xsd:element name="street" type="xsd:string"/&gt;
                    &lt;xsd:element name="city"   type="xsd:string"/&gt;
                    &lt;xsd:element name="state"  type="xsd:string" fixed="CA"/&gt;
                    &lt;xsd:element name="zip"    type="xsd:decimal"/&gt;
                &lt;/xsd:sequence&gt;
                &lt;xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/&gt;
            &lt;/xsd:restriction&gt;
        &lt;/xsd:complexContent&gt;
    &lt;/xsd:complexType&gt;".</action>
                    <result>Adding CAdress global complex type should not broke schema.</result>
		</usecase>
                <usecase name="Add extension type">
			<action>Switch to Source View of the po schema.</action>
                        <action>Add extension of USAdress type: "&lt;xsd:complexType name="ToAddress"&gt;
        &lt;xsd:complexContent&gt;
            &lt;xsd:extension base="USAddress"&gt;
                &lt;xsd:sequence&gt;
                    &lt;xsd:element name="firstName" type="xsd:string"/&gt;
                    &lt;xsd:element name="lastName" type="xsd:string"/&gt;
                &lt;/xsd:sequence&gt;
            &lt;/xsd:extension&gt;
        &lt;/xsd:complexContent&gt;
    &lt;/xsd:complexType&gt;". </action>
                        <action>Switch to Analysis View of the po schema.</action>
                    <result>Adding ToAddress global complex type should not broke schema.</result>
		</usecase>
                <usecase name="Show derivations of a Global Complex Type Query">
			<action>In Analysis View of po schema select Show derivations of a Global Complex Type item in the first column.</action>
			<result>In the second column Complex Types tree and Show Derivations button should appear</result>
		</usecase>
                <usecase name="Global Complex Type: no derivations">
                        <action>In the second column select complex type node, that has no derivations, e.g. Items.</action>
                        <action>Click Show Derivations button in the second column.</action>
			<result>In the third column graph with 1 node should appear: Items node.</result>
		</usecase>
                <usecase name="Global Complex Type: with derivations">
                        <action>In the second column select complex type node, that has derivations, e.g. USAddress.</action>
                        <action>Click Show Derivations button in the second column.</action>
			<result>In the third column graph with base complex type node and its derivations nodes, linked by generalization edge, should appear. CAddress and ToAddress nodes should have generalization links to USAddress base complex type node.</result>
		</usecase>
                <usecase name="Global Complex Type: double-click">
                        <action>In the second column double-click a complex type node.</action>
			<result>In the third column appropriate graph should appear.</result>
		</usecase>
	</caseblock>
        <caseblock name="Find Usages query from Schema View">
            <purpose> Checking Find Usages Query from Schema View feature</purpose>
            <setup> Analysis View of Purchase Order Schema Sample should be opened.</setup>
                <usecase name="Schema View: Find Usages Query">
			<action>Switch to Schema View.</action>
			<result>In the first column all element, complex type, simple type, group, attribute, attribute group nodes should have enabled Show Usages popup menu item.</result>
		</usecase>
		<usecase name="Find Usages query: Complex Types">
			<action>In the first column under Complex Types node of components tree right-click Item subnode and select Show Usages.</action>
			<result>XML Usages window should appear. This window is a split pane: on the left side, an explorer (contains path to the usage component), on the right, a graph.</result>
                        <result>In the graph pane a graph with 4 nodes should appear: Items, items, PurchaseOrderType, po.xsd nodes.</result>
                        <result>items node should have generalization link to Items node.</result>
                        <result>items node should have composition link to PurchaseOrderType node.</result>
                        <result>PurchaseOrderType node should have composition link po.xsd file node.</result>
                        <result>po.xsd file node should have file link to Items query component node.</result>
		</usecase>
                <usecase name="Show usages of a global component: Elements">
			<action>In the first column under Elements node of components tree right-click comment subnode and select Show Usages.</action>
                        <result>XML Usages window should appear. This window is a split pane: on the left side, an explorer (contains path to the usage component), on the right, a graph.</result>
			<result>In the graph pane a graph with 7 nodes should appear: comment, 2 References "comment" nodes, Items, items, PurchaseOrderType, po.xsd nodes.</result>
                        <result>2 References "comment" nodes should have reference link to comment node.</result>
                        <result>One of References "comment" nodes should have composition link to PurchaseOrderType node.</result>
                        <result>The second References "comment" node should have composition link to item node.</result>
                        <result>item node should have composition link to Items node.</result>
                        <result>PurchaseOrderType, Items nodes should have composition link to po.xsd file node.</result>
                        <result>po.xsd file node should have file link to comment query component node.</result>
		</usecase>
                <usecase name="Show usages of a global component: Simple Types">
			<action>In the first column under Simple Types node of components tree right-click SKU subnode and select Show Usages.</action>
                        <result>XML Usages window should appear. This window is a split pane: on the left side, an explorer (contains path to the usage component), on the right, a graph.</result>
			<result>In the graph pane a graph with 5 nodes should appear: SKU, partNum, Items, items, po.xsd.</result>
                        <result>partNum node should have generalization link to SKU node.</result>
                        <result>Pair of nodes partNum-items, items-Items node should have composition links.</result>
                        <result>Items node should have composition link to po.xsd file node.</result>
                        <result>po.xsd file node should have file link to SKU query component node.</result>
		</usecase>
	</caseblock>
	
</spec>
