Esempio n. 1
0
 private static void AssertOtherInfo(TimelineEntity entity)
 {
     NUnit.Framework.Assert.IsNotNull(entity.GetOtherInfo());
     NUnit.Framework.Assert.IsNotNull(entity.GetOtherInfoJAXB());
     NUnit.Framework.Assert.IsTrue(entity.GetOtherInfo() is Hashtable);
     NUnit.Framework.Assert.IsTrue(entity.GetOtherInfoJAXB() is Hashtable);
     NUnit.Framework.Assert.AreEqual(entity.GetOtherInfo(), entity.GetOtherInfoJAXB());
 }
Esempio n. 2
0
        public virtual void TestEntities()
        {
            TimelineEntities entities = new TimelineEntities();

            for (int j = 0; j < 2; ++j)
            {
                TimelineEntity entity = new TimelineEntity();
                entity.SetEntityId("entity id " + j);
                entity.SetEntityType("entity type " + j);
                entity.SetStartTime(Runtime.CurrentTimeMillis());
                for (int i = 0; i < 2; ++i)
                {
                    TimelineEvent @event = new TimelineEvent();
                    @event.SetTimestamp(Runtime.CurrentTimeMillis());
                    @event.SetEventType("event type " + i);
                    @event.AddEventInfo("key1", "val1");
                    @event.AddEventInfo("key2", "val2");
                    entity.AddEvent(@event);
                }
                entity.AddRelatedEntity("test ref type 1", "test ref id 1");
                entity.AddRelatedEntity("test ref type 2", "test ref id 2");
                entity.AddPrimaryFilter("pkey1", "pval1");
                entity.AddPrimaryFilter("pkey2", "pval2");
                entity.AddOtherInfo("okey1", "oval1");
                entity.AddOtherInfo("okey2", "oval2");
                entity.SetDomainId("domain id " + j);
                entities.AddEntity(entity);
            }
            Log.Info("Entities in JSON:");
            Log.Info(TimelineUtils.DumpTimelineRecordtoJSON(entities, true));
            NUnit.Framework.Assert.AreEqual(2, entities.GetEntities().Count);
            TimelineEntity entity1 = entities.GetEntities()[0];

            NUnit.Framework.Assert.AreEqual("entity id 0", entity1.GetEntityId());
            NUnit.Framework.Assert.AreEqual("entity type 0", entity1.GetEntityType());
            NUnit.Framework.Assert.AreEqual(2, entity1.GetRelatedEntities().Count);
            NUnit.Framework.Assert.AreEqual(2, entity1.GetEvents().Count);
            NUnit.Framework.Assert.AreEqual(2, entity1.GetPrimaryFilters().Count);
            NUnit.Framework.Assert.AreEqual(2, entity1.GetOtherInfo().Count);
            NUnit.Framework.Assert.AreEqual("domain id 0", entity1.GetDomainId());
            TimelineEntity entity2 = entities.GetEntities()[1];

            NUnit.Framework.Assert.AreEqual("entity id 1", entity2.GetEntityId());
            NUnit.Framework.Assert.AreEqual("entity type 1", entity2.GetEntityType());
            NUnit.Framework.Assert.AreEqual(2, entity2.GetRelatedEntities().Count);
            NUnit.Framework.Assert.AreEqual(2, entity2.GetEvents().Count);
            NUnit.Framework.Assert.AreEqual(2, entity2.GetPrimaryFilters().Count);
            NUnit.Framework.Assert.AreEqual(2, entity2.GetOtherInfo().Count);
            NUnit.Framework.Assert.AreEqual("domain id 1", entity2.GetDomainId());
        }