Esempio n. 1
0
        public virtual void TestClassInfo()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoList classInfoList = classIntrospector
				.Introspect(user.GetType(), true);
			AssertEquals(user.GetType().FullName, classInfoList.GetMainClassInfo().GetFullClassName
				());
			AssertEquals(3, classInfoList.GetMainClassInfo().GetAttributes().Count);
			AssertEquals(2, classInfoList.GetClassInfos().Count);
		}
Esempio n. 2
0
        public virtual void TestInstanceInfo2()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			AssertEquals(instanceInfo.GetClassInfo().GetFullClassName(), user.GetType().FullName
				);
			AssertEquals(instanceInfo.GetAttributeValueFromId(ci.GetAttributeId("name")).ToString
				(), "olivier smadja");
		}
Esempio n. 3
0
        public virtual void TestCompareCollection1()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.IObjectInfoComparator comparator = new 
				NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.ObjectInfoComparator();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			// Sets attributes offsets - this is normally done by reading then from
			// disk, but in this junit,
			// we must set them manually
			long[] offsets = new long[] { 1L, 2L, 3L };
			int[] ids = new int[] { 1, 2, 3 };
			instanceInfo.GetHeader().SetAttributesIdentification(offsets);
			instanceInfo.GetHeader().SetAttributesIds(ids);
			instanceInfo.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(1
				));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)instanceInfo.GetAttributeValueFromId(2);
			nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2));
			user.SetName("Olivier Smadja");
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo3 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			instanceInfo3.GetHeader().SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(
				1));
			nnoiProfile = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo)instanceInfo3
				.GetAttributeValueFromId(2);
			nnoiProfile.SetOid(NeoDatis.Odb.Core.Oid.OIDFactory.BuildObjectOID(2));
			AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
			AssertEquals(1, comparator.GetNbChanges());
			AssertEquals(1, comparator.GetChangedAttributeActions().Count);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction cnaa = 
				(NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.ChangedNativeAttributeAction)comparator
				.GetChangedAttributeActions()[0];
			AssertEquals("Olivier Smadja", cnaa.GetNoiWithNewValue().GetObject());
		}
Esempio n. 4
0
        public virtual void TestCopy()
		{
			NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", function);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo copy = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)instanceInfo.CreateCopy(new NeoDatis.Tool.Wrappers.Map.OdbHashMap(), true);
			AssertEquals(3, copy.GetAttributeValues().Length);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo[] aois = copy.GetAttributeValues
				();
			for (int i = 0; i < aois.Length; i++)
			{
				NeoDatis.Odb.Core.Layers.Layer2.Meta.AbstractObjectInfo aoi = aois[i];
				AssertEquals(instanceInfo.GetAttributeValues()[i].GetOdbTypeId(), aoi.GetOdbTypeId
					());
			}
		}
Esempio n. 5
0
        public virtual void TestGetDependentObjects()
		{
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", new NeoDatis.Odb.Test.VO.Login.Profile("operator", new 
				NeoDatis.Odb.Test.VO.Login.Function("login")));
			NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.GetDependentObjectIntrospectingCallback
				 callback = new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.GetDependentObjectIntrospectingCallback
				();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, callback);
			AssertEquals(user.GetType().FullName, instanceInfo.GetClassInfo().GetFullClassName
				());
			AssertEquals("olivier smadja", instanceInfo.GetAttributeValueFromId(ci.GetAttributeId
				("name")).ToString());
			AssertEquals(typeof(NeoDatis.Odb.Core.Layers.Layer2.Meta.AtomicNativeObjectInfo), 
				instanceInfo.GetAttributeValueFromId(ci.GetAttributeId("name")).GetType());
			System.Collections.ICollection objects = callback.GetObjects();
			AssertEquals(2, objects.Count);
			AssertTrue(objects.Contains(user.GetProfile()));
			AssertTrue(objects.Contains(user.GetProfile().GetFunctions()[0]));
		}
Esempio n. 6
0
        public virtual void TestCompareCollection8()
		{
			NeoDatis.Odb.Test.VO.Login.Function function = new NeoDatis.Odb.Test.VO.Login.Function
				("login");
			NeoDatis.Odb.Test.VO.Login.Profile profile = new NeoDatis.Odb.Test.VO.Login.Profile
				("operator", function);
			NeoDatis.Odb.Test.VO.Login.User user = new NeoDatis.Odb.Test.VO.Login.User("olivier smadja"
				, "*****@*****.**", profile);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.IObjectInfoComparator comparator = new 
				NeoDatis.Odb.Impl.Core.Layers.Layer2.Meta.Compare.ObjectInfoComparator();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo ci = classIntrospector.Introspect(
				user.GetType(), true).GetMainClassInfo();
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			// Sets attributes offsets - this is normally done by reading then from
			// disk, but in this junit,
			// we must set them manually
			long[] offsets = new long[] { 1L, 2L, 3L };
			int[] ids = new int[] { 1, 2, 3 };
			instanceInfo.GetHeader().SetAttributesIdentification(offsets);
			instanceInfo.GetHeader().SetAttributesIds(ids);
			user.SetProfile(null);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo instanceInfo3 = (NeoDatis.Odb.Core.Layers.Layer2.Meta.NonNativeObjectInfo
				)new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.LocalObjectIntrospector(new 
				NeoDatis.Odb.Core.Mock.MockStorageEngine()).GetMetaRepresentation(user, ci, true
				, null, new NeoDatis.Odb.Impl.Core.Layers.Layer1.Introspector.DefaultInstrospectionCallbackForStore
				(null, null, false));
			AssertTrue(comparator.HasChanged(instanceInfo, instanceInfo3));
			AssertEquals(1, comparator.GetNbChanges());
			AssertEquals(1, comparator.GetAttributeToSetToNull().Count);
			NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.SetAttributeToNullAction o = (NeoDatis.Odb.Core.Layers.Layer2.Meta.Compare.SetAttributeToNullAction
				)comparator.GetAttributeToSetToNull()[0];
			AssertEquals(0, comparator.GetChangedAttributeActions().Count);
			AssertEquals(2, o.GetAttributeId());
		}