예제 #1
0
        public void TestMergingNodeGroups()
        {
            /* test the case where two node groups come from the "same" model and completely share the sparqlIDs */
            List <NodeGroup> nodeGroupsToMerge = new List <NodeGroup>();
            NodeGroup        ng_001            = new NodeGroup();
            NodeGroup        ng_002            = new NodeGroup();

            JsonObject jsonRenderedNodeGroup = (JsonObject.Parse(jsonContent)).GetNamedObject("sNodeGroup");

            ng_001.AddJsonEncodedNodeGroup(jsonRenderedNodeGroup);
            ng_002.AddJsonEncodedNodeGroup(jsonRenderedNodeGroup);

            nodeGroupsToMerge.Add(ng_001);
            nodeGroupsToMerge.Add(ng_002);

            NodeGroup ngMerged = new NodeGroup();

            ngMerged.AddJsonEncodedNodeGroup(ng_001.ToJson());
            ngMerged.AddJsonEncodedNodeGroup(ng_002.ToJson());

            Assert.IsTrue(ngMerged.GetNodeCount() == (ng_001.GetNodeCount() + ng_002.GetNodeCount()));

            // a bit of Debug outputs:

            Debug.WriteLine("Node group 1 sparqlIDs :");
            foreach (String currId in ng_001.GetSparqlNameHash().Keys)
            {
                Debug.Write(currId + " | ");
            }
            Debug.WriteLine("");

            Debug.WriteLine("Node group 2 sparqlIDs :");
            foreach (String currId in ng_002.GetSparqlNameHash().Keys)
            {
                Debug.Write(currId + " | ");
            }
            Debug.WriteLine("");

            Debug.WriteLine("Node group (merged) sparqlIDs :");
            foreach (String currId in ngMerged.GetSparqlNameHash().Keys)
            {
                Debug.Write(currId + " | ");
            }
            Debug.WriteLine("");
        }
예제 #2
0
        public void NodeGroupCreationFromJson()
        {
            // declare
            NodeGroup ng = new NodeGroup();

            // read the Json file into a local string.

            Debug.WriteLine("Json content for node group was:");
            Debug.WriteLine(jsonContent);

            ng.AddJsonEncodedNodeGroup((JsonObject.Parse(jsonContent)).GetNamedObject("sNodeGroup"));

            Debug.WriteLine("the total number of nodes was:" + ng.GetNodeCount());
            Assert.AreEqual(6, ng.GetNodeCount());
        }
예제 #3
0
        public void NodeGroupSerializationAfterReadingFromJson()
        {
            NodeGroup ngRoot = new NodeGroup();

            ngRoot.AddJsonEncodedNodeGroup((JsonObject.Parse(jsonContent)).GetNamedObject("sNodeGroup"));

            JsonObject serialized = ngRoot.ToJson();

            NodeGroup ngAlternate = new NodeGroup();

            ngAlternate.AddJsonEncodedNodeGroup(serialized);

            Assert.AreEqual(ngRoot.GetNodeCount(), ngAlternate.GetNodeCount());

            foreach (Node nd in ngRoot.GetNodeList())
            {
                int propCount = nd.GetPropertyItems().Count;
                int nodeCount = nd.GetNodeItemList().Count;

                List <Node> compareNodes = ngAlternate.GetNodeByURI(nd.GetFullUriName());

                Boolean foundIt = false;

                Debug.WriteLine("checking node: " + nd.GetFullUriName() + " with nodeItemCount: " + nodeCount + " , and propertyCount :" + propCount);

                foreach (Node comNode in compareNodes)
                {
                    int compPropCount = comNode.GetPropertyItems().Count;
                    int compNodeCount = comNode.GetNodeItemList().Count;

                    if (propCount == compPropCount && nodeCount == compNodeCount)
                    {
                        foundIt = true;
                    }
                }

                if (!foundIt)
                {
                    Assert.Fail();
                }
            }
        }
예제 #4
0
        public void NodeGroupDeleteGeneration()
        {
            String selectStatement = "";

            NodeGroup ng = new NodeGroup();

            Debug.WriteLine(jsonContent);

            ng.AddJsonEncodedNodeGroup((JsonObject.Parse(jsonContent)).GetNamedObject("sNodeGroup"));

            RestClientConfig necc            = new RestClientConfig(protocol, serverAddress, nodeGroupServicePort);
            NodeGroupClient  nodeGroupClient = new NodeGroupClient(necc);

            selectStatement = nodeGroupClient.ExecuteGetDelete(ng).Result;

            Debug.WriteLine("the returned sparql delete was: ");
            Debug.WriteLine(selectStatement);

            Assert.IsTrue(selectStatement.Length > 0);
        }