public void InsertRepeatedNodesTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            var skills = new List <Skill>
            {
                new Skill()
                {
                    Name = ".net", Category = "platforms"
                },
                new Skill()
                {
                    Name = "c#", Category = "languages"
                },
                new Skill()
                {
                    Name = "c#", Category = "languages"
                }
            };

            gremlinDB.InsertNodes(skills);

            Assert.Equal(2, gremlinDB.CountNodes());
        }
        public void InsertNodesTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            var skills = new List <Skill>
            {
                new Skill()
                {
                    Name = ".net", Category = "platforms"
                },
                new Skill()
                {
                    Name = "c#", Category = "languages"
                },
                new Skill()
                {
                    Name = "java", Category = "languages"
                },
                new Skill()
                {
                    Name = "maven", Category = "development tools"
                },
                new Skill()
                {
                    Name = "junit", Category = "development tools"
                },
                new Skill()
                {
                    Name = "jenkins", Category = "development tools"
                },
                new Skill()
                {
                    Name = "eclipse", Category = "development tools"
                }
            };

            gremlinDB.InsertNodes(skills);

            Assert.Equal(7, gremlinDB.CountNodes());

            gremlinDB.Drop();

            Assert.Equal(0, gremlinDB.CountNodes());
        }
        public void NoNodesTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            Assert.Equal(0, gremlinDB.CountNodes());
        }
        public void Run()
        {
            const string endpoint = "localhost";
            const int    port     = 8182;

            try
            {
                var skills = new List <Skill>();

                // This uses the default Neptune and Gremlin port, 8182
                var gremlinDB = new GremlinDB(endpoint, port);

                // Drop entire DB
                gremlinDB.Drop();

                // get job posts
                var jobPosts = JobPostRepo.Get();

                // load csv data for skills
                skills = LoadDataToMemory();
                // skills into DB
                Stopwatch stopWatch  = new Stopwatch();
                Stopwatch stopWatch1 = new Stopwatch();
                stopWatch.Start();
                stopWatch1.Start();
                gremlinDB.InsertNodes(skills);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND inserting NODES\n");

                // edges into DB
                IJobPostProcessor jobPostProcessor = new JobPostProcessor();
                Console.WriteLine("Start processing JOB POSTS");
                stopWatch.Restart();
                var jobPostsSkills = jobPostProcessor.ProcessJobPosts(skills, jobPosts);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND iprocessing JOB POSTS\n");

                Console.WriteLine("Start inserting EDGES");
                stopWatch.Restart();
                gremlinDB.InsertEdges(jobPostsSkills);
                Console.WriteLine(stopWatch.Elapsed);
                Console.WriteLine("\tEND inserting EDGES\n");

                // get related skills
                const string skillNameForSearch = "c#";
                const int    limit = 10;

                Console.WriteLine("Start RELATED skills");
                var relatedSkills = gremlinDB.GetRelatedSkills(skillNameForSearch, limit);
                Console.WriteLine(stopWatch1.Elapsed);

                Console.WriteLine($"Top {limit} skills related to {skillNameForSearch}:\n");
                foreach (var skill in relatedSkills)
                {
                    Console.WriteLine($"Name: {skill.Name}, Category: {skill.Category}, Weight: {skill.Weight}");
                }

                Console.WriteLine("\n\nTotal number of skills: {0}", gremlinDB.CountNodes());

                Console.WriteLine("Finished");
            }
            catch (Exception e)
            {
                Console.WriteLine("{0}", e);
            }
        }
        public void GetRelatedSkillsTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            var skills = new List <Skill>
            {
                new Skill()
                {
                    Name = "css", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "html", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "java", Category = "languages", Weight = 1
                },
                new Skill()
                {
                    Name = "javascript", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "spring", Category = "technologies", Weight = 1
                },
                new Skill()
                {
                    Name = "spring boot", Category = "technologies", Weight = 1
                }
            };

            // Insert nodes ACT
            gremlinDB.InsertNodes(skills);

            var jobPostSkills1 = new List <Skill>()
            {
                new Skill()
                {
                    Name = "css", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "html", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "javascript", Category = "languages", Weight = 10
                }
            };

            var jobPostSkills2 = new List <Skill>()
            {
                new Skill()
                {
                    Name = "java", Category = "languages", Weight = 1
                },
                new Skill()
                {
                    Name = "spring boot", Category = "technologies", Weight = 1
                }
            };

            var jobPostSkills3 = new List <Skill>()
            {
                new Skill()
                {
                    Name = "css", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "javascript", Category = "languages", Weight = 10
                }
            };

            var processedJobPostsSkills = new List <ICollection <Skill> >
            {
                jobPostSkills1,
                jobPostSkills2,
                jobPostSkills3
            };

            // Insert edges ACT
            gremlinDB.InsertEdges(processedJobPostsSkills);

            // Related skills ACT
            var relatedSkills      = gremlinDB.GetRelatedSkills("javascript", 10);
            var relatedSkillsNames = relatedSkills.Select(x => x.Name);

            Assert.Equal(2, relatedSkills.Count);
            Assert.Contains("css", relatedSkillsNames);
            Assert.Contains("html", relatedSkillsNames);
            Assert.True(relatedSkills.Find(skill => skill.Name == "css").Weight == 20);
        }
        public void InsertEdgesTest(string host, int port)
        {
            var gremlinDB = new GremlinDB(host, port, false);

            gremlinDB.Drop();

            var skills = new List <Skill>
            {
                new Skill()
                {
                    Name = "css", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "html", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "java", Category = "languages", Weight = 1
                },
                new Skill()
                {
                    Name = "javascript", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "spring", Category = "technologies", Weight = 1
                },
                new Skill()
                {
                    Name = "spring boot", Category = "technologies", Weight = 1
                }
            };

            gremlinDB.InsertNodes(skills);

            var jobPostSkills1 = new List <Skill>()
            {
                new Skill()
                {
                    Name = "css", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "html", Category = "languages", Weight = 10
                },
                new Skill()
                {
                    Name = "javascript", Category = "languages", Weight = 10
                }
            };

            var jobPostSkills2 = new List <Skill>()
            {
                new Skill()
                {
                    Name = "java", Category = "languages", Weight = 1
                },
                new Skill()
                {
                    Name = "spring boot", Category = "technologies", Weight = 1
                }
            };

            var processedJobPostsSkills = new List <ICollection <Skill> >
            {
                jobPostSkills1,
                jobPostSkills2
            };

            gremlinDB.InsertEdges(processedJobPostsSkills);

            // Total count (includes bidirectional edges)
            Assert.Equal(8, gremlinDB.CountEdges());
        }