@Test(timeout = 5000)
  public void testQuery1() {
    ClientMessage cmAdd1 =
        new ClientMessage()
            .setType(ClientMessage.Type.CREATE)
            .setAuthor("AdnanAziz1968")
            .setSubject("Hello World")
            .setBody("My first posting!");

    ClientMessage cmAdd2 =
        new ClientMessage()
            .setType(ClientMessage.Type.CREATE)
            .setAuthor("Don Bradman")
            .setSubject("29")
            .setBody("Still the greatest!");

    ClientMessage cmAdd3 =
        new ClientMessage()
            .setType(ClientMessage.Type.CREATE)
            .setAuthor("AdnanAziz1968")
            .setSubject("Random musings")
            .setBody("My second posting!");

    ClientMessage cmQuery =
        new ClientMessage().setType(ClientMessage.Type.QUERY).setAuthor("AdnanAziz1968");

    ServerMessage result = doTxRx(cmAdd1, cmAdd2, cmAdd3, cmQuery);

    assertEquals(result.getPostings().size(), 2);
    for (Posting p : result.getPostings()) {
      assert (p.getAuthor().equals(cmQuery.getAuthor()));
    }

    ClientMessage cmBodyQuery =
        new ClientMessage().setType(ClientMessage.Type.QUERY).setBody("posting My");
    assertEquals(2, result.getPostings().size());
    for (Posting p : result.getPostings()) {
      assertTrue(p.getBody().contains("My"));
      assertTrue(p.getBody().contains("posting"));
    }
    score += 15;
  }
Exemple #2
0
 private static void collectDatum(
     List<Project> projects,
     List<Posting> postings,
     List<Issue> issues,
     List<PullRequest> pullRequests,
     List<Milestone> milestones,
     int daysAgo) {
   // collect all postings, issues, pullrequests and milesotnes that are contained in the projects.
   for (Project project : projects) {
     if (AccessControl.isAllowed(UserApp.currentUser(), project.asResource(), Operation.READ)) {
       postings.addAll(Posting.findRecentlyCreatedByDaysAgo(project, daysAgo));
       issues.addAll(Issue.findRecentlyOpendIssuesByDaysAgo(project, daysAgo));
       pullRequests.addAll(PullRequest.findOpendPullRequestsByDaysAgo(project, daysAgo));
       milestones.addAll(Milestone.findOpenMilestones(project.id));
     }
   }
 }