public async Task TestIndexLifecycle(IndexType indexType) { string indexName = GetIndexName(indexType); try { // verify index doesn't exist List <Index> indexes = Client.GetAllIndexes().Result.Value; Assert.False(await DoesIndexExist(indexName)); // create index Assert.DoesNotThrowAsync(async() => { await Client.CreateIndex(indexType, indexName); }); await DelayForIndexSync(); // create index already exists SovrenException sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.CreateIndex(indexType, indexName); }); Assert.AreEqual(SovrenErrorCodes.DuplicateAsset, sovrenException.SovrenErrorCode); // verify index created Assert.True(await DoesIndexExist(indexName)); // delete the index Assert.DoesNotThrowAsync(async() => { await Client.DeleteIndex(indexName); }); await DelayForIndexSync(); // verify index doesn't exist Assert.False(await DoesIndexExist(indexName)); // try to delete an index that doesn't exist sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.DeleteIndex(indexName); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); } finally { // clean up assets in case the test failed someone before the delete calls were executed await CleanUpIndex(indexName); await DelayForIndexSync(); } }
public async Task TestDeleteMultiple() { const string documentId1 = "1"; const string documentId2 = "2"; try { // create the index await Client.CreateIndex(IndexType.Resume, resumeIndexId); await DelayForIndexSync(); // add resume to index await Client.IndexDocument(TestParsedResume, resumeIndexId, documentId1); await Client.IndexDocument(TestParsedResume, resumeIndexId, documentId2); await DelayForIndexSync(); // confirm you can now retrieve the resumes await Client.GetResume(resumeIndexId, documentId1); await Client.GetResume(resumeIndexId, documentId2); // delete the document await Client.DeleteMultipleDocuments(resumeIndexId, new List <string> { documentId1, documentId2 }); await DelayForIndexSync(); // verify can't retrieve a document that doesn't exist SovrenException sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.GetResume(resumeIndexId, documentId1); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.GetResume(resumeIndexId, documentId2); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); await Client.DeleteIndex(resumeIndexId); await DelayForIndexSync(); } catch (Exception) { throw; } finally { await CleanUpIndex(resumeIndexId); } }
public void TestLargeDocumentParse() { SovrenException e = Assert.ThrowsAsync <SovrenException>(async() => { await Client.ParseResume(new ParseRequest(new Document(new byte[20_000_000], DateTime.Now))); });
public async Task TestJobLifeCycle() { const string documentId = "1"; try { // verify can't retrieve a document that doesn't exist SovrenException sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.GetJob(jobIndexId, documentId); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); // verify can't add document to an index that doesn't exist sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.IndexDocument(TestParsedJob, jobIndexId, documentId); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); // create the index await Client.CreateIndex(IndexType.Job, jobIndexId); await DelayForIndexSync(); // verify document still doesn't exist sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.GetJob(jobIndexId, documentId); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); // add resume to index await Client.IndexDocument(TestParsedJob, jobIndexId, documentId); await DelayForIndexSync(); // confirm you can now retrieve the resume await Client.GetJob(jobIndexId, documentId); // confirm the resume shows up in searches List <string> indexesToQuery = new List <string>() { jobIndexId }; FilterCriteria filterCriteria = new FilterCriteria() { DocumentIds = new List <string>() { documentId } }; SearchResponseValue searchResponse = Client.Search(indexesToQuery, filterCriteria).Result.Value; Assert.AreEqual(1, searchResponse.TotalCount); Assert.AreEqual(1, searchResponse.CurrentCount); Assert.AreEqual(documentId, searchResponse.Matches[0].Id); // update the resume List <string> userDefinedTags = new List <string> { "userDefinedTag1" }; await Client.UpdateJobUserDefinedTags(jobIndexId, documentId, userDefinedTags, UserDefinedTagsMethod.Overwrite); await DelayForIndexSync(); // verify those updates have taken effect filterCriteria.UserDefinedTags = userDefinedTags; searchResponse = Client.Search(indexesToQuery, filterCriteria).Result.Value; Assert.AreEqual(1, searchResponse.TotalCount); Assert.AreEqual(1, searchResponse.CurrentCount); Assert.AreEqual(documentId, searchResponse.Matches[0].Id); // confirm you can retrieve the tags ParsedJob job = Client.GetJob(jobIndexId, documentId).Result.Value; Assert.AreEqual(1, job.UserDefinedTags.Count); Assert.AreEqual(userDefinedTags[0], job.UserDefinedTags[0]); // delete the document await Client.DeleteDocument(jobIndexId, documentId); await DelayForIndexSync(); // verify can't retrieve a document that doesn't exist sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.GetJob(jobIndexId, documentId); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.DeleteDocument(jobIndexId, documentId); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); await Client.DeleteIndex(jobIndexId); await DelayForIndexSync(); sovrenException = Assert.ThrowsAsync <SovrenException>(async() => { await Client.DeleteDocument(jobIndexId, documentId); }); Assert.AreEqual(SovrenErrorCodes.DataNotFound, sovrenException.SovrenErrorCode); } finally { await CleanUpIndex(jobIndexId); } }
internal BatchErrorResult(string file, string docId, SovrenException e) : base(file, docId) { Error = e; }