public void UpdateMergeBlacklistTest() { var entryA = new MergeBlacklistEntry { Id = "A", ProjectId = ProjId, UserId = UserId, WordIds = new List <string> { "1", "2", "3" } }; var entryB = new MergeBlacklistEntry { Id = "B", ProjectId = ProjId, UserId = UserId, WordIds = new List <string> { "1", "4" } }; _ = _mergeBlacklistRepo.Create(entryA); _ = _mergeBlacklistRepo.Create(entryB); var oldBlacklist = _mergeBlacklistRepo.GetAll(ProjId).Result; Assert.That(oldBlacklist, Has.Count.EqualTo(2)); // Make sure all wordIds are in the frontier EXCEPT 1. var frontier = new List <Word> { new Word { Id = "2", ProjectId = ProjId }, new Word { Id = "3", ProjectId = ProjId }, new Word { Id = "4", ProjectId = ProjId } }; _ = _wordRepo.AddFrontier(frontier).Result; // All entries affected. var updatedEntriesCount = _mergeService.UpdateMergeBlacklist(ProjId).Result; Assert.That(updatedEntriesCount, Is.EqualTo(2)); // The only blacklistEntry with at least two ids in the frontier is A. var newBlacklist = _mergeBlacklistRepo.GetAll(ProjId).Result; Assert.That(newBlacklist, Has.Count.EqualTo(1)); Assert.AreEqual(newBlacklist.First().WordIds, new List <string> { "2", "3" }); }
public async Task <IActionResult> GetPotentialDuplicates( string projectId, int maxInList, int maxLists, string userId) { if (!await _permissionService.HasProjectPermission(HttpContext, Permission.MergeAndCharSet)) { return(Forbid()); } await _mergeService.UpdateMergeBlacklist(projectId); return(Ok( await _mergeService.GetPotentialDuplicates(projectId, maxInList, maxLists, userId))); }