示例#1
0
        public void Test_IgnoreTrigger_GetSet()
        {
            var loadMetadata = new LoadMetadata(CatalogueRepository);

            try
            {
                //default
                Assert.IsFalse(loadMetadata.IgnoreTrigger);
                loadMetadata.SaveToDatabase();
                Assert.IsFalse(loadMetadata.IgnoreTrigger);
                loadMetadata.SaveToDatabase();

                loadMetadata.IgnoreTrigger = true;
                Assert.IsTrue(loadMetadata.IgnoreTrigger);
                loadMetadata.RevertToDatabaseState();
                Assert.IsFalse(loadMetadata.IgnoreTrigger);


                loadMetadata.IgnoreTrigger = true;
                Assert.IsTrue(loadMetadata.IgnoreTrigger);
                loadMetadata.SaveToDatabase();
                var lmd2 = RepositoryLocator.CatalogueRepository.GetObjectByID <LoadMetadata>(loadMetadata.ID);
                Assert.IsTrue(lmd2.IgnoreTrigger);
            }
            finally
            {
                loadMetadata.DeleteInDatabase();
            }
        }
示例#2
0
            public void Dispose()
            {
                if (Catalogue != null)
                {
                    Catalogue.DeleteInDatabase();
                }

                if (LoadMetadata != null)
                {
                    LoadMetadata.DeleteInDatabase();
                }

                if (ColumnInfo != null)
                {
                    ColumnInfo.DeleteInDatabase();
                }

                if (TableInfo != null)
                {
                    TableInfo.DeleteInDatabase();
                }

                if (Credentials != null)
                {
                    Credentials.DeleteInDatabase();
                }
            }
        public void TestEncryptedPasswordHostArgumentType()
        {
            LoadMetadata        lmd = null;
            ProcessTaskArgument pta = null;

            try
            {
                pta = CreateNewProcessTaskArgumentInDatabase(out lmd);
                pta.SetType(typeof(EncryptedString));
                pta.SetValue(new EncryptedString(CatalogueRepository)
                {
                    Value = "test123"
                });
                pta.SaveToDatabase();

                var loadedPta = CatalogueRepository.GetObjectByID <ProcessTaskArgument>(pta.ID);
                var value     = loadedPta.GetValueAsSystemType() as EncryptedString;
                Assert.NotNull(value);
                Assert.AreEqual("test123", value.GetDecryptedValue());
            }
            finally
            {
                if (pta != null)
                {
                    var processTask = CatalogueRepository.GetObjectByID <ProcessTask>(pta.ProcessTask_ID);
                    processTask.DeleteInDatabase();
                }

                if (lmd != null)
                {
                    lmd.DeleteInDatabase();
                }
            }
        }
示例#4
0
        public void LoadProgress_Equals()
        {
            var loadMetadata = new LoadMetadata(CatalogueRepository);


            LoadProgress progress     = new LoadProgress(CatalogueRepository, loadMetadata);
            LoadProgress progressCopy = CatalogueRepository.GetObjectByID <LoadProgress>(progress.ID);

            progressCopy.Name       = "fish";
            progressCopy.OriginDate = new DateTime(2001, 01, 01);

            try
            {
                //values are different
                Assert.AreNotEqual(progressCopy.OriginDate, progress.OriginDate);
                Assert.AreNotEqual(progressCopy.Name, progress.Name);

                //IDs are the same
                Assert.AreEqual(progressCopy.ID, progress.ID);

                //therefore objects are the same
                Assert.IsTrue(progressCopy.Equals(progress));
            }
            finally
            {
                progress.DeleteInDatabase();
                loadMetadata.DeleteInDatabase();
            }
        }
        public void TypeOfPreLoadDiscardedColumn()
        {
            string methodName    = new StackTrace().GetFrame(0).GetMethod().Name;
            string tableInfoName = "TableInfoFor_" + methodName;
            string preLoadDiscardedColumnName = "PreLoadDiscardedColumnFor_" + methodName;

            TableInfo toCleanup = CatalogueRepository.GetAllObjects <TableInfo>().SingleOrDefault(t => t.Name.Equals(tableInfoName));
            PreLoadDiscardedColumn toCleanupCol = CatalogueRepository.GetAllObjects <PreLoadDiscardedColumn>()
                                                  .SingleOrDefault(c => c.RuntimeColumnName.Equals(preLoadDiscardedColumnName));

            //must delete pre load discarded first
            if (toCleanupCol != null)
            {
                toCleanupCol.DeleteInDatabase();
            }

            if (toCleanup != null)
            {
                toCleanup.DeleteInDatabase();
            }

            var lmd = new LoadMetadata(CatalogueRepository);

            try
            {
                var pt  = new ProcessTask(CatalogueRepository, lmd, LoadStage.AdjustStaging);
                var pta = new ProcessTaskArgument(CatalogueRepository, pt);

                pta.SetType(typeof(PreLoadDiscardedColumn));

                var tableInfo = new TableInfo(CatalogueRepository, tableInfoName);

                PreLoadDiscardedColumn preloadDiscardedColumn = new PreLoadDiscardedColumn(CatalogueRepository, tableInfo, preLoadDiscardedColumnName);
                try
                {
                    pta.SetValue(preloadDiscardedColumn);
                    pta.SaveToDatabase();

                    var newInstanceOfPTA = CatalogueRepository.GetObjectByID <ProcessTaskArgument>(pta.ID);
                    Assert.AreEqual(newInstanceOfPTA.Value, pta.Value);

                    PreLoadDiscardedColumn p1 = (PreLoadDiscardedColumn)pta.GetValueAsSystemType();
                    PreLoadDiscardedColumn p2 = (PreLoadDiscardedColumn)newInstanceOfPTA.GetValueAsSystemType();

                    Assert.AreEqual(p1.ID, p2.ID);
                }
                finally
                {
                    preloadDiscardedColumn.DeleteInDatabase();
                    tableInfo.DeleteInDatabase();
                }
            }
            finally
            {
                lmd.DeleteInDatabase();
            }
        }
示例#6
0
        public void CreateNewScheduleTest()
        {
            var loadMetadata = new LoadMetadata(CatalogueRepository);
            var loadProgress = new LoadProgress(CatalogueRepository, loadMetadata);

            Assert.AreEqual(loadProgress.LoadMetadata_ID, loadMetadata.ID);

            loadProgress.DeleteInDatabase();
            loadMetadata.DeleteInDatabase();
        }
示例#7
0
        public void DeleteTask()
        {
            _task.DeleteInDatabase();

            _lmd.GetDistinctTableInfoList(true).ForEach(t => t.DeleteInDatabase());
            _lmd.GetAllCatalogues().Cast <IDeleteable>().Single().DeleteInDatabase();

            _lmd.DeleteInDatabase();

            _dir.Delete(true);
        }
        public void TypeOfTableInfo(bool declareAsInterface)
        {
            string tableInfoName = "TableInfoFor_" + new StackTrace().GetFrame(0).GetMethod().Name;

            TableInfo toCleanup = CatalogueRepository.GetAllObjects <TableInfo>().SingleOrDefault(t => t.Name.Equals(tableInfoName));

            if (toCleanup != null)
            {
                toCleanup.DeleteInDatabase();
            }

            var loadMetadata = new LoadMetadata(CatalogueRepository);

            try
            {
                var pt  = new ProcessTask(CatalogueRepository, loadMetadata, LoadStage.AdjustStaging);
                var pta = new ProcessTaskArgument(CatalogueRepository, pt);

                if (declareAsInterface)
                {
                    pta.SetType(typeof(ITableInfo));
                }
                else
                {
                    pta.SetType(typeof(TableInfo));
                }

                var tableInfo = new TableInfo(CatalogueRepository, tableInfoName);
                try
                {
                    pta.SetValue(tableInfo);
                    pta.SaveToDatabase();

                    var newInstanceOfPTA = CatalogueRepository.GetObjectByID <ProcessTaskArgument>(pta.ID);

                    Assert.AreEqual(newInstanceOfPTA.Value, pta.Value);

                    TableInfo t1 = (TableInfo)pta.GetValueAsSystemType();
                    TableInfo t2 = (TableInfo)newInstanceOfPTA.GetValueAsSystemType();

                    Assert.AreEqual(t1.ID, t2.ID);
                }
                finally
                {
                    tableInfo.DeleteInDatabase();
                }
            }
            finally
            {
                loadMetadata.DeleteInDatabase();
            }
        }
示例#9
0
        public void DeleteDatabaseObjects()
        {
            _cata.DeleteInDatabase();

            _testPipeline.Destroy();

            if (_cp != null)
            {
                _cp.DeleteInDatabase();
            }

            _lp.DeleteInDatabase();

            _lmd.DeleteInDatabase();

            _LoadDirectory.RootPath.Delete(true);
        }
示例#10
0
        public void CreateNewAndGetBackFromDatabase()
        {
            var loadMetadata = new LoadMetadata(CatalogueRepository);

            try
            {
                loadMetadata.LocationOfFlatFiles = "C:\\temp";
                loadMetadata.SaveToDatabase();

                var loadMetadataWithIdAfterwards = CatalogueRepository.GetObjectByID <LoadMetadata>(loadMetadata.ID);
                Assert.AreEqual(loadMetadataWithIdAfterwards.LocationOfFlatFiles, "C:\\temp");
            }
            finally
            {
                loadMetadata.DeleteInDatabase();
            }
        }
        public void TableInfoType_FetchAfterDelete_ReturnsNull()
        {
            string tableInfoName = "TableInfoFor_" + new StackTrace().GetFrame(0).GetMethod().Name;

            TableInfo toCleanup = CatalogueRepository.GetAllObjects <TableInfo>().SingleOrDefault(t => t.Name.Equals(tableInfoName));

            if (toCleanup != null)
            {
                toCleanup.DeleteInDatabase();
            }

            var lmd = new LoadMetadata(CatalogueRepository);

            try
            {
                var pt  = new ProcessTask(CatalogueRepository, lmd, LoadStage.AdjustStaging);
                var pta = new ProcessTaskArgument(CatalogueRepository, pt);

                //Prepare to receive a TableInfo object
                pta.SetType(typeof(TableInfo));

                var tableInfo = new TableInfo(CatalogueRepository, tableInfoName);

                //Heres the TableInfo object
                pta.SetValue(tableInfo);
                pta.SaveToDatabase();

                //Lolz I just deleted it out of the database
                tableInfo.DeleteInDatabase();

                //give the object back now please? - returns null because it's gone (new behaviour)
                Assert.IsNull(pta.GetValueAsSystemType());

                //old behaviour

                /*var ex = Assert.Throws<KeyNotFoundException>(()=>pta.GetValueAsSystemType());
                 * StringAssert.Contains("Could not find TableInfo with ID",ex.Message);*/
            }
            finally
            {
                lmd.DeleteInDatabase();
            }
        }
示例#12
0
        public void TestConstructionFromProcessTaskUsingDatabase()
        {
            const string expectedPath = @"\\a\fake\path.exe";

            var loadMetadata = new LoadMetadata(CatalogueRepository);
            var processTask  = new ProcessTask(CatalogueRepository, loadMetadata, LoadStage.Mounting)
            {
                Name = "Test process task",
                Path = expectedPath
            };

            processTask.SaveToDatabase();

            var argument = new ProcessTaskArgument(CatalogueRepository, processTask)
            {
                Name  = "DatabaseName",
                Value = @"Foo_STAGING"
            };

            argument.SaveToDatabase();

            try
            {
                var args =
                    new RuntimeArgumentCollection(processTask.ProcessTaskArguments.Cast <IArgument>().ToArray(), null);

                var runtimeTask = new ExecutableRuntimeTask(processTask, args);
                Assert.AreEqual(expectedPath, runtimeTask.ExeFilepath);

                Assert.AreEqual(1, runtimeTask.RuntimeArguments.GetAllArgumentsOfType <string>().Count());

                var dictionaryOfStringArguments = runtimeTask.RuntimeArguments.GetAllArgumentsOfType <string>().ToDictionary(kvp => kvp.Key, kvp => kvp.Value);
                Assert.IsNotNull(dictionaryOfStringArguments["DatabaseName"]);
                Assert.AreEqual("Foo_STAGING", dictionaryOfStringArguments["DatabaseName"]);
            }
            finally
            {
                loadMetadata.DeleteInDatabase();
            }
        }
示例#13
0
        public void RuntimeTaskFactoryTest(string className)
        {
            var lmd  = new LoadMetadata(CatalogueRepository);
            var task = new ProcessTask(CatalogueRepository, lmd, LoadStage.GetFiles);

            var f = new RuntimeTaskFactory(CatalogueRepository);

            task.Path            = className;
            task.ProcessTaskType = ProcessTaskType.DataProvider;
            task.SaveToDatabase();

            try
            {
                var ex = Assert.Throws <Exception>(() => f.Create(task, new StageArgs(LoadStage.AdjustRaw, GetCleanedServer(FAnsi.DatabaseType.MicrosoftSQLServer), Mock.Of <ILoadDirectory>())));
                Assert.IsTrue(ex.InnerException.Message.Contains("marked with DemandsInitialization but no corresponding argument was provided in ArgumentCollection"));
            }
            finally
            {
                task.DeleteInDatabase();
                lmd.DeleteInDatabase();
            }
        }
        public void TestArgumentCreation()
        {
            LoadMetadata lmd = new LoadMetadata(CatalogueRepository, "TestArgumentCreation");
            var          pt  = new ProcessTask(CatalogueRepository, lmd, LoadStage.AdjustRaw);

            pt.CreateArgumentsForClassIfNotExists <TestArgumentedClass>();
            try
            {
                var arg = pt.ProcessTaskArguments.Single();

                Assert.AreEqual("MyBool", arg.Name);
                Assert.AreEqual("System.Boolean", arg.Type);
                Assert.AreEqual("Fishes", arg.Description);
                Assert.AreEqual("True", arg.Value);
                Assert.AreEqual(true, arg.GetValueAsSystemType());
            }
            finally
            {
                pt.DeleteInDatabase();
                lmd.DeleteInDatabase();
            }
        }
示例#15
0
        public void CloneProcessTask_ToSameLoadMetadataWithoutArguments()
        {
            LoadMetadata test         = new LoadMetadata(CatalogueRepository);
            ProcessTask  processTask1 = new ProcessTask(CatalogueRepository, test, LoadStage.AdjustRaw)
            {
                Name  = "Franky",
                Order = 999
            };

            try
            {
                processTask1.SaveToDatabase();

                var clone = processTask1.CloneToNewLoadMetadataStage(test, LoadStage.GetFiles);
                Assert.AreNotSame(clone.ID, processTask1.ID);
                Assert.IsFalse(clone.ID == processTask1.ID);

                //get fresh copy out of database to ensure it is still there
                ProcessTask orig = CatalogueRepository.GetObjectByID <ProcessTask>(processTask1.ID);
                clone = CatalogueRepository.GetObjectByID <ProcessTask>(clone.ID);

                Assert.IsFalse(orig.ID == clone.ID);
                Assert.AreEqual(LoadStage.AdjustRaw, orig.LoadStage);
                Assert.AreEqual(LoadStage.GetFiles, clone.LoadStage);

                Assert.AreEqual(orig.Order, clone.Order);
                Assert.AreEqual(orig.Path, clone.Path);
                Assert.AreEqual(orig.ProcessTaskType, clone.ProcessTaskType);
                Assert.AreEqual(orig.LoadMetadata_ID, clone.LoadMetadata_ID);

                clone.DeleteInDatabase();
            }
            finally
            {
                processTask1.DeleteInDatabase();
                test.DeleteInDatabase();
            }
        }
        public void LieToProcessTaskArgumentAboutWhatTypeIs_Throws()
        {
            string tableInfoName = "TableInfoFor_" + new StackTrace().GetFrame(0).GetMethod().Name;

            TableInfo toCleanup = CatalogueRepository.GetAllObjects <TableInfo>().SingleOrDefault(t => t.Name.Equals(tableInfoName));

            if (toCleanup != null)
            {
                toCleanup.DeleteInDatabase();
            }

            var lmd = new LoadMetadata(CatalogueRepository);

            try
            {
                var pt        = new ProcessTask(CatalogueRepository, lmd, LoadStage.AdjustStaging);
                var pta       = new ProcessTaskArgument(CatalogueRepository, pt);
                var tableInfo = new TableInfo(CatalogueRepository, tableInfoName);
                try
                {
                    //tell it that we are going to give it a PreLoadDiscardedColumn
                    pta.SetType(typeof(PreLoadDiscardedColumn));
                    //then surprise! heres a TableInfo!
                    var ex = Assert.Throws <Exception>(() => pta.SetValue(tableInfo));
                    StringAssert.Contains("has an incompatible Type specified (Rdmp.Core.Curation.Data.DataLoad.PreLoadDiscardedColumn)", ex.Message);
                }
                finally
                {
                    tableInfo.DeleteInDatabase();
                }
            }
            finally
            {
                lmd.DeleteInDatabase();
            }
        }
示例#17
0
 public void down()
 {
     _cp.DeleteInDatabase();
     _lp.DeleteInDatabase();
     _lmd.DeleteInDatabase();
 }
示例#18
0
        public void CloneProcessTask_ToNewLoadMetadataWithArguments()
        {
            //setup parents
            LoadMetadata parent1 = new LoadMetadata(CatalogueRepository);
            LoadMetadata parent2 = new LoadMetadata(CatalogueRepository);

            //make sure we didn't magically create the same ID somehow
            Assert.AreNotEqual(parent1.ID, parent2.ID);

            //setup things to clone in parent1
            ProcessTask         processTask1 = new ProcessTask(CatalogueRepository, parent1, LoadStage.AdjustRaw);
            ProcessTaskArgument arg          = new ProcessTaskArgument(CatalogueRepository, processTask1);

            arg.Name = "TestArg";
            arg.SetType(typeof(System.String));
            arg.SetValue("TestValue");
            arg.SaveToDatabase();

            processTask1.Name  = "Franky";
            processTask1.Order = 999;
            processTask1.SaveToDatabase();

            try
            {
                //clone to parent 2
                var clone = processTask1.CloneToNewLoadMetadataStage(parent2, LoadStage.GetFiles);
                Assert.AreNotSame(clone.ID, processTask1.ID);
                Assert.IsFalse(clone.ID == processTask1.ID);

                //////////////////////////////////////////////////////////////////CHECK CLONAGE OF PROCESS TASK ////////////////////////////////////////////////////////////
                //get fresh copy out of database to ensure it is still there
                ProcessTask orig = CatalogueRepository.GetObjectByID <ProcessTask>(processTask1.ID);
                clone = CatalogueRepository.GetObjectByID <ProcessTask>(clone.ID);

                //ids must have changed
                Assert.IsFalse(orig.ID == clone.ID);

                //load stages must be correct per what we requested
                Assert.AreEqual(LoadStage.AdjustRaw, orig.LoadStage);
                Assert.AreEqual(LoadStage.GetFiles, clone.LoadStage);

                //all regular values must have been cloned successfully
                Assert.AreEqual(orig.Order, clone.Order);
                Assert.AreEqual(orig.Path, clone.Path);
                Assert.AreEqual(orig.ProcessTaskType, clone.ProcessTaskType);

                Assert.AreEqual(parent1.ID, orig.LoadMetadata_ID);
                Assert.AreEqual(parent2.ID, clone.LoadMetadata_ID);
                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

                //////////////////////////////////////////////////////////////////CHECK CLONAGE OF ARGUMENTS ////////////////////////////////////////////////////////////

                ProcessTaskArgument clonearg = clone.ProcessTaskArguments.SingleOrDefault();
                Assert.NotNull(clonearg);

                Assert.AreNotEqual(clonearg.ID, arg.ID);
                Assert.AreEqual(clonearg.GetType(), arg.GetType());
                Assert.AreEqual(clonearg.Name, arg.Name);
                Assert.AreEqual(clonearg.Value, arg.Value);

                ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                clone.DeleteInDatabase();
            }
            finally
            {
                processTask1.DeleteInDatabase();

                parent1.DeleteInDatabase();
                parent2.DeleteInDatabase();
            }
        }
示例#19
0
 public void DestroyDle()
 {
     TestCatalogue.DeleteInDatabase();
     TestLoadMetadata.DeleteInDatabase();
     LoadDirectory.RootPath.Delete(true);
 }
示例#20
0
        public void GatherAndShare_Catalogue_Test(bool goViaJson)
        {
            //Setup some objects under Catalogue that we can share
            var cata = new Catalogue(CatalogueRepository, "Cata");

            cata.Periodicity = Catalogue.CataloguePeriodicity.BiMonthly;
            cata.SaveToDatabase();

            var catalogueItem1 = new CatalogueItem(CatalogueRepository, cata, "Ci1");
            var catalogueItem2 = new CatalogueItem(CatalogueRepository, cata, "Ci2");

            var tableInfo = new TableInfo(CatalogueRepository, "Myt");
            var colInfo   = new ColumnInfo(CatalogueRepository, "[Mt].[C1]", "varchar(10)", tableInfo);

            catalogueItem1.ColumnInfo_ID = colInfo.ID;
            catalogueItem1.SaveToDatabase();

            var ei = new ExtractionInformation(CatalogueRepository, catalogueItem1, colInfo, "UPPER(C1) as Fish");

            //the logging server has a system default so should have been populated
            Assert.IsNotNull(cata.LiveLoggingServer_ID);

            //Catalogue sharing should be allowed
            Gatherer g = new Gatherer(RepositoryLocator);

            Assert.IsTrue(g.CanGatherDependencies(cata));

            //gather the objects depending on Catalogue as a tree
            var gObj = g.GatherDependencies(cata);

            Assert.AreEqual(2, gObj.Children.Count); //both cata items

            var lmd = new LoadMetadata(CatalogueRepository);

            cata.LoadMetadata_ID = lmd.ID;
            cata.SaveToDatabase();

            //get the share definition
            var shareManager    = new ShareManager(RepositoryLocator);
            var shareDefinition = gObj.ToShareDefinitionWithChildren(shareManager);


            if (goViaJson)
            {
                var json =
                    shareDefinition.Select(s => JsonConvertExtensions.SerializeObject(s, RepositoryLocator)).ToList();
                shareDefinition =
                    json.Select(
                        j => JsonConvertExtensions.DeserializeObject(j, typeof(ShareDefinition), RepositoryLocator))
                    .Cast <ShareDefinition>()
                    .ToList();
            }

            //make a local change
            cata.Name            = "fishfish";
            cata.SubjectNumbers  = "123";
            cata.LoadMetadata_ID = null;
            cata.Periodicity     = Catalogue.CataloguePeriodicity.Unknown;
            cata.SaveToDatabase();

            lmd.DeleteInDatabase();

            //import the saved copy
            shareManager.ImportSharedObject(shareDefinition);

            //revert the memory copy and check it got overwritten with the original saved values
            cata.RevertToDatabaseState();
            Assert.AreEqual("Cata", cata.Name);

            var exports = CatalogueRepository.GetAllObjects <ObjectExport>();

            Assert.IsTrue(exports.Any());

            //now delete and report
            foreach (var d in exports)
            {
                d.DeleteInDatabase();
            }

            //make a local change including Name
            cata.Name = "fishfish";
            cata.SaveToDatabase();

            //test importing the Catalogue properties only
            shareManager.ImportPropertiesOnly(cata, shareDefinition[0]);

            //import the defined properties but not name
            Assert.AreEqual("fishfish", cata.Name);
            Assert.AreEqual(Catalogue.CataloguePeriodicity.BiMonthly, cata.Periodicity); //reset this though
            Assert.IsNull(cata.LoadMetadata_ID);
            cata.SaveToDatabase();

            cata.DeleteInDatabase();

            //none of these should now exist thanks to cascade deletes
            Assert.IsFalse(cata.Exists());
            Assert.IsFalse(catalogueItem1.Exists());
            Assert.IsFalse(catalogueItem2.Exists());

            //import the saved copy
            var newObjects = shareManager.ImportSharedObject(shareDefinition).ToArray();

            Assert.AreEqual("Cata", ((Catalogue)newObjects[0]).Name);
            Assert.AreEqual("Ci1", ((CatalogueItem)newObjects[1]).Name);
            Assert.AreEqual("Ci2", ((CatalogueItem)newObjects[2]).Name);
        }