public async Task stream_an_array_of_documents_with_compiled_query() { var store = theHost.Services.GetRequiredService <IDocumentStore>(); await store.Advanced.Clean.DeleteDocumentsByTypeAsync(typeof(Issue)); var issues = new Issue[100]; for (int i = 0; i < issues.Length; i++) { issues[i] = Issue.Random(); } await store.BulkInsertDocumentsAsync(issues); var result = await theHost.Scenario(s => { s.Get.Url("/issue2/open"); s.StatusCodeShouldBeOk(); s.ContentTypeShouldBe("application/json"); }); var read = result.ReadAsJson <Issue[]>(); read.Length.ShouldBe(issues.Count(x => x.Open)); }
public async Task marten_is_acidic() { // Blow away any existing data theDocumentStore.Advanced.Clean .DeleteAllDocuments(); var issues = new Issue[] { new Issue { Title = "Approved 1", Status = IssueStatus.Approved }, new Issue { Title = "Approved 2", Status = IssueStatus.Approved }, new Issue { Title = "New 1", Status = IssueStatus.New }, new Issue { Title = "Approved 3", Status = IssueStatus.Approved }, new Issue { Title = "In Progress", Status = IssueStatus.InProgress }, new Issue { Title = "Open", Status = IssueStatus.Open }, new Issue { Title = "New 2", Status = IssueStatus.New }, }; using (var session = theDocumentStore.LightweightSession()) { session.Store(issues); session.Store(new User { FirstName = "Han", LastName = "Solo" }); session.Store(new User { FirstName = "Darth", LastName = "Maul" }); session.Store(new User { FirstName = "Lando", LastName = "Calrissian" }); await session.SaveChangesAsync(); var count = await session.Query <Issue>() .CountAsync(); count.ShouldBe(issues.Count()); } }
public async Task MonitorTerminalSubmissionPlan() { AutoMapperBootstrapper.ConfigureAutoMapper(); var guidTestId = Guid.NewGuid(); var userId = AddTokens(); var googleEventUrl = ConfigurationManager.AppSettings["GoogleFormEventWebServerUrl"]; //Trigger creating Plan Debug.WriteLine("Trigger creating Plan"); var terminalAuthenticationHeader = GetFr8TerminalAuthorizationHeader("terminalGoogle", "1", userId); await RestfulServiceClient.PostAsync(new Uri(googleEventUrl), new { fr8_user_id = userId }, null, terminalAuthenticationHeader); //Reconfiguring plan activities var url = $"{GetHubApiBaseUrl()}/plans?name=MonitorSubmissionTerminalForm&visibility=2"; var response = await RestfulServiceClient.GetAsync(new Uri(url), null, terminalAuthenticationHeader); var plans = JsonConvert.DeserializeObject <IEnumerable <PlanDTO> >(response).ToArray(); var plan = plans.FirstOrDefault().SubPlans.FirstOrDefault(); // deactivate plan before editing Debug.WriteLine("deactivate plan before editing"); var deactivateUrl = GetHubApiBaseUrl() + "plans/deactivate?planId=" + plans.FirstOrDefault().Id; await RestfulServiceClient.PostAsync(new Uri(deactivateUrl), new List <CrateDTO>(), null, terminalAuthenticationHeader); Debug.WriteLine("Reconfiguring plan activities"); if (plan.Activities.FirstOrDefault(a => a.Ordering == 8) != null) { var deleteActivityUrl = GetHubApiBaseUrl() + "activities/delete/" + plan.Activities.Where(a => a.Ordering == 8).FirstOrDefault().Id; await RestfulServiceClient.DeleteAsync(new Uri(deleteActivityUrl), null, terminalAuthenticationHeader); } await ConfigureJira(plan.Activities.FirstOrDefault(a => a.Ordering == 5).Id, userId); await ConfigureMessage(plan.Activities.FirstOrDefault(a => a.Ordering == 6).Id, userId, guidTestId.ToString()); await ConfigureSlack(plan.Activities.FirstOrDefault(a => a.Ordering == 7).Id, userId); //Run plan again after reconfigure Debug.WriteLine("Run plan again after reconfigure"); var runUrl = GetHubApiBaseUrl() + "plans/run?planId=" + plans.FirstOrDefault().Id; await RestfulServiceClient.PostAsync(new Uri(runUrl), new List <CrateDTO>(), null, terminalAuthenticationHeader); await SubmitForm(googleEventUrl, guidTestId.ToString()); //Waiting 10 seconds for Plan execution Debug.WriteLine("Waiting 10 seconds for Plan execution"); await Task.Delay(PlanExecutionPeriod); Jira jira = CreateRestClient(AtlassianToken); Issue[] issues = new Issue[0]; var slackUrl = "https://slack.com/api/search.messages?token=" + SlackAuthToken + "&query=" + guidTestId.ToString(); var totalMessagesFound = 0; var stopwatch = new Stopwatch(); stopwatch.Start(); while (stopwatch.ElapsedMilliseconds <= MaxAwaitPeriod) { if (issues.Length == 0) { //Searching for created jira issue issues = jira.GetIssuesFromJql("summary ~ " + guidTestId.ToString()).ToArray(); Debug.WriteLine("found jira issues " + issues.Length + " after elapsed " + stopwatch.ElapsedMilliseconds + " milliseconds"); } if (totalMessagesFound == 0) { //Searching for slack message var result = await RestfulServiceClient.GetAsync(new Uri(slackUrl)); var searchResult = JObject.Parse(result); totalMessagesFound = (int)searchResult.SelectToken("messages.pagination.total_count"); Debug.WriteLine("found slack messages " + totalMessagesFound + " after elapsed " + stopwatch.ElapsedMilliseconds + " milliseconds"); } if (issues.Count() != 0 && totalMessagesFound != 0) { break; } await Task.Delay(SingleAwaitPeriod); } //Deleting test issues foreach (var issue in issues) { jira.DeleteIssue(issue); } Assert.IsTrue(issues.Length > 0, "Couldn't find jira issue"); Assert.IsTrue(totalMessagesFound != 0, "Couldn't find slack message"); }