Example #1
0
        public void GetProjects_GoogleWorkspaceSharedDrive()
        {
            string configPath = "Assets/CliConfigurationSecrets/GoogleWorkspaceSharedDriveProjectTest.json";

            if (!File.Exists(configPath))
            {
                throw new FileNotFoundException(configPath);
            }

            // Gets config file, fails if not exist
            ConfigurationService configService = new ConfigurationService();
            CliConfiguration     config        = configService.GetConfiguration(configPath);

            DataStore dataStore = config.DataStores[0];
            GoogleWorkspaceSharedDriveCrawler sut = new GoogleWorkspaceSharedDriveCrawler(
                dataStore.ClientId,
                dataStore.ClientSecret,
                dataStore.ApplicationName);

            List <Core.Models.v0_2.Project> actual = sut.GetProjects(new ProjectReader(
                                                                         new ProjectParser()));

            Assert.NotNull(actual);
            Assert.True(actual.Count() > 0);
        }
Example #2
0
        public void GetProjects_AzureDataLake()
        {
            string configPath = "Assets/CliConfigurationSecrets/AzureDataLakeProjectTest.json";

            if (!File.Exists(configPath))
            {
                throw new FileNotFoundException(configPath);
            }

            // Gets config file, fails if not exist
            ConfigurationService configService = new ConfigurationService();
            CliConfiguration     config        = configService.GetConfiguration(configPath);

            DataStore            dataStore = config.DataStores[0];
            AzureDataLakeCrawler sut       = new AzureDataLakeCrawler(
                dataStore.AccountName,
                dataStore.TenantId,
                dataStore.ClientId,
                dataStore.ClientSecret,
                dataStore.AzureFileSystemName);

            List <Core.Models.v0_2.Project> actual = sut.GetProjects(new ProjectReader(
                                                                         new ProjectParser()));

            Assert.NotNull(actual);
            Assert.Single(actual);
            Assert.Equal("TestProject", actual[0].Name);
        }
Example #3
0
        public Collate(
            string name,
            string description,
            CliConfiguration?configuration)
            : base(name, description)
        {
            // Abort if not configuration found
            if (configuration == null)
            {
                Console.WriteLine("Unable to read 'configuration.json' file. To create a configuration file, use the 'setup' action");
                return;
            }

            this.config = configuration;


            Add(new Option <List <string> >(
                    new[] { "--datastores", "-d" },
                    "List of names of data stores to crawl"));
            Add(new Option <bool?>(
                    new[] { "--silent", "-s" },
                    "Runs in silent mode without user prompt."));
            Add(new Option <string?>(
                    new[] { "--outdir", "-o" },
                    "Directory to write the catalog.json file."));


            Handler = CommandHandler
                      .Create <List <string>, bool?, string?, IConsole>(HandleCollate);
        }
Example #4
0
        public void CreateConfiguration()
        {
            CliConfiguration config = new CliConfiguration()
            {
                DataStores = new List <DataStore>()
                {
                    new DataStore()
                    {
                        Name      = "DataStoreName",
                        Type      = DataStoreTypes.LocalFileSystem,
                        LocalPath = @"C:\Path\To\Projects"
                    }
                }
            };

            File.WriteAllText(
                CONFIG_FILE,
                JsonSerializer.Serialize(config, jsonOptions));
        }
Example #5
0
        public Collate(
            string name,
            string description,
            CliConfiguration?configuration)
            : base(name, description)
        {
            this.config = configuration;

            Add(new Option <List <string> >(
                    new[] { "--datastores", "-d" },
                    "List of names of data stores to crawl"));
            Add(new Option <bool>(
                    new[] { "--silent", "-s" },
                    "Runs in silent mode without user prompt."));
            Add(new Option <string?>(
                    new[] { "--outdir", "-o" },
                    "Directory to write the catalog.json file."));

            Handler = CommandHandler
                      .Create <List <string>, bool, string?, IConsole>(HandleCollate);
        }
Example #6
0
        public void GetProjects_Local()
        {
            string configPath = "Assets/CliConfigurationSecrets/LocalFileSystemProjectTest.json";

            if (!File.Exists(configPath))
            {
                throw new FileNotFoundException(configPath);
            }

            // Gets config file, fails if not exist
            ConfigurationService configService = new ConfigurationService();
            CliConfiguration     config        = configService.GetConfiguration(configPath);

            DataStore dataStore        = config.DataStores[0];
            LocalFileSystemCrawler sut = new LocalFileSystemCrawler(
                dataStore.Path);

            List <Core.Models.v0_2.Project> actual = sut.GetProjects(new ProjectReader(
                                                                         new ProjectParser()));

            Assert.NotNull(actual);
            Assert.Single(actual);
            Assert.Equal("ProductionProject", actual[0].Name);
        }