@Rule
public UserSessionRule userSessionRule = UserSessionRule.standalone();
- IssueIndex index;
+ IssueIndex underTest;
IssueIndexer issueIndexer;
IssueAuthorizationIndexer issueAuthorizationIndexer;
when(system.getDefaultTimeZone()).thenReturn(TimeZone.getTimeZone("GMT-1:00"));
when(system.now()).thenReturn(System.currentTimeMillis());
- index = new IssueIndex(tester.client(), system, userSessionRule);
+ underTest = new IssueIndex(tester.client(), system, userSessionRule);
}
@Test
.setEffort(100L);
indexIssues(issue);
- Issue loaded = index.getByKey(issue.key());
+ Issue loaded = underTest.getByKey(issue.key());
assertThat(loaded).isNotNull();
assertThat(loaded.key()).isEqualTo("ISSUE1");
IssueDoc issue = IssueTesting.newDoc("ISSUE1", file).setAttributes((KeyValueFormat.format(ImmutableMap.of("jira-issue-key", "SONAR-1234"))));
indexIssues(issue);
- Issue result = index.getByKey(issue.key());
+ Issue result = underTest.getByKey(issue.key());
assertThat(result.attribute("jira-issue-key")).isEqualTo("SONAR-1234");
}
IssueDoc issue = IssueTesting.newDoc("ISSUE1", file);
indexIssues(issue);
- Issue result = index.getByKey(issue.key());
+ Issue result = underTest.getByKey(issue.key());
result.comments();
}
IssueDoc issue = IssueTesting.newDoc("ISSUE1", file);
indexIssues(issue);
- Issue result = index.getByKey(issue.key());
+ Issue result = underTest.getByKey(issue.key());
result.isNew();
}
@Test(expected = NotFoundException.class)
public void fail_to_get_unknown_key() {
- index.getByKey("unknown");
+ underTest.getByKey("unknown");
}
@Test
IssueTesting.newDoc("1", ComponentTesting.newFileDto(project)),
IssueTesting.newDoc("2", ComponentTesting.newFileDto(project)));
- assertThat(index.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("1", "2")).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("1")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("3", "4")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("1", "2")).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("1")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).issueKeys(newArrayList("3", "4")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE5", subModule),
IssueTesting.newDoc("ISSUE6", ComponentTesting.newFileDto(subModule)));
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs()).hasSize(6);
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs()).hasSize(6);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE2", ComponentTesting.newFileDto(project)),
IssueTesting.newDoc("ISSUE3", ComponentTesting.newFileDto(project2)));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("projectUuids")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("projectUuids")));
assertThat(result.getFacets().getNames()).containsOnly("projectUuids");
assertThat(result.getFacets().get("projectUuids")).containsOnly(entry("ABCD", 2L), entry("EFGH", 1L));
}
IssueTesting.newDoc("ISSUE2", file));
assertThat(
- index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(file.uuid())).build(), new SearchOptions()).getDocs())
+ underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(file.uuid())).build(), new SearchOptions()).getDocs())
.isEmpty();
assertThat(
- index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(module.uuid())).build(), new SearchOptions()).getDocs())
+ underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(module.uuid())).build(), new SearchOptions()).getDocs())
.hasSize(1);
assertThat(
- index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
+ underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
.getDocs())
.hasSize(2);
assertThat(
- index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs())
+ underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs())
.isEmpty();
assertThat(
- index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs())
+ underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).moduleUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs())
.isEmpty();
}
IssueTesting.newDoc("ISSUE5", subModule),
IssueTesting.newDoc("ISSUE6", file3));
- assertThat(index.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid(), file2.uuid(), file3.uuid())).build(), new SearchOptions())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid(), file2.uuid(), file3.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(3);
- assertThat(index.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid())).build(), new SearchOptions())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).moduleRootUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).moduleRootUuids(newArrayList(subModule.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).moduleRootUuids(newArrayList(module.uuid())).build(), new SearchOptions())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).moduleRootUuids(newArrayList(module.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(4);
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions())
.getDocs()).hasSize(6);
- assertThat(index.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view)).build(), new SearchOptions())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view)).build(), new SearchOptions())
.getDocs()).hasSize(6);
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList("unknown")).build(), new SearchOptions())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList("unknown")).build(), new SearchOptions())
.getDocs()).isEmpty();
}
IssueTesting.newDoc("ISSUE5", subModule),
IssueTesting.newDoc("ISSUE6", file3));
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs()).hasSize(6);
- assertThat(index.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view)).build(), new SearchOptions()).getDocs()).hasSize(6);
- assertThat(index.search(IssueQuery.builder(userSessionRule).moduleUuids(newArrayList(module.uuid())).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).moduleUuids(newArrayList(subModule.uuid())).build(), new SearchOptions()).getDocs()).hasSize(2); // XXX
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project.uuid())).build(), new SearchOptions()).getDocs()).hasSize(6);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view)).build(), new SearchOptions()).getDocs()).hasSize(6);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).moduleUuids(newArrayList(module.uuid())).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).moduleUuids(newArrayList(subModule.uuid())).build(), new SearchOptions()).getDocs()).hasSize(2); // XXX
// Misleading
// !
- assertThat(index.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid())).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid(), file2.uuid(), file3.uuid())).build(), new SearchOptions()).getDocs())
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid())).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).fileUuids(newArrayList(file1.uuid(), file2.uuid(), file3.uuid())).build(), new SearchOptions()).getDocs())
.hasSize(3);
}
IssueTesting.newDoc("ISSUE4", file2),
IssueTesting.newDoc("ISSUE5", file3));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("fileUuids")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("fileUuids")));
assertThat(result.getFacets().getNames()).containsOnly("fileUuids");
assertThat(result.getFacets().get("fileUuids"))
.containsOnly(entry("A", 1L), entry("ABCD", 1L), entry("BCDE", 2L), entry("CDEF", 1L));
IssueTesting.newDoc("ISSUE1", file1).setDirectoryPath("/src/main/xoo"),
IssueTesting.newDoc("ISSUE2", file2).setDirectoryPath("/"));
- assertThat(index.search(IssueQuery.builder(userSessionRule).directories(newArrayList("/src/main/xoo")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).directories(newArrayList("/")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).directories(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).directories(newArrayList("/src/main/xoo")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).directories(newArrayList("/")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).directories(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE1", file1).setDirectoryPath("/src/main/xoo"),
IssueTesting.newDoc("ISSUE2", file2).setDirectoryPath("/"));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("directories")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("directories")));
assertThat(result.getFacets().getNames()).containsOnly("directories");
assertThat(result.getFacets().get("directories")).containsOnly(entry("/src/main/xoo", 1L), entry("/", 1L));
}
String view2 = "CDEF";
indexView(view2, newArrayList(project2.uuid()));
- assertThat(index.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view1)).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view2)).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view1, view2)).build(), new SearchOptions()).getDocs()).hasSize(3);
- assertThat(index.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view1)).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view2)).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList(view1, view2)).build(), new SearchOptions()).getDocs()).hasSize(3);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).viewUuids(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE1", file).setSeverity(Severity.INFO),
IssueTesting.newDoc("ISSUE2", file).setSeverity(Severity.MAJOR));
- assertThat(index.search(IssueQuery.builder(userSessionRule).severities(newArrayList(Severity.INFO, Severity.MAJOR)).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).severities(newArrayList(Severity.INFO)).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).severities(newArrayList(Severity.BLOCKER)).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).severities(newArrayList(Severity.INFO, Severity.MAJOR)).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).severities(newArrayList(Severity.INFO)).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).severities(newArrayList(Severity.BLOCKER)).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE2", file).setSeverity(Severity.INFO),
IssueTesting.newDoc("ISSUE3", file).setSeverity(Severity.MAJOR));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("severities")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("severities")));
assertThat(result.getFacets().getNames()).containsOnly("severities");
assertThat(result.getFacets().get("severities")).containsOnly(entry("INFO", 2L), entry("MAJOR", 1L));
}
IssueTesting.newDoc("ISSUE1", file).setStatus(Issue.STATUS_CLOSED),
IssueTesting.newDoc("ISSUE2", file).setStatus(Issue.STATUS_OPEN));
- assertThat(index.search(IssueQuery.builder(userSessionRule).statuses(newArrayList(Issue.STATUS_CLOSED, Issue.STATUS_OPEN)).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).statuses(newArrayList(Issue.STATUS_CLOSED)).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).statuses(newArrayList(Issue.STATUS_CONFIRMED)).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).statuses(newArrayList(Issue.STATUS_CLOSED, Issue.STATUS_OPEN)).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).statuses(newArrayList(Issue.STATUS_CLOSED)).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).statuses(newArrayList(Issue.STATUS_CONFIRMED)).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE2", file).setStatus(Issue.STATUS_CLOSED),
IssueTesting.newDoc("ISSUE3", file).setStatus(Issue.STATUS_OPEN));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("statuses")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("statuses")));
assertThat(result.getFacets().getNames()).containsOnly("statuses");
assertThat(result.getFacets().get("statuses")).containsOnly(entry("CLOSED", 2L), entry("OPEN", 1L));
}
IssueTesting.newDoc("ISSUE2", file).setResolution(Issue.RESOLUTION_FIXED));
assertThat(
- index.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_FALSE_POSITIVE, Issue.RESOLUTION_FIXED)).build(), new SearchOptions()).getDocs())
+ underTest.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_FALSE_POSITIVE, Issue.RESOLUTION_FIXED)).build(), new SearchOptions()).getDocs())
.hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_FALSE_POSITIVE)).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_REMOVED)).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_FALSE_POSITIVE)).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).resolutions(newArrayList(Issue.RESOLUTION_REMOVED)).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE2", file).setResolution(Issue.RESOLUTION_FALSE_POSITIVE),
IssueTesting.newDoc("ISSUE3", file).setResolution(Issue.RESOLUTION_FIXED));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("resolutions")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("resolutions")));
assertThat(result.getFacets().getNames()).containsOnly("resolutions");
assertThat(result.getFacets().get("resolutions")).containsOnly(entry("FALSE-POSITIVE", 2L), entry("FIXED", 1L));
}
IssueTesting.newDoc("ISSUE2", file).setStatus(Issue.STATUS_OPEN).setResolution(null),
IssueTesting.newDoc("ISSUE3", file).setStatus(Issue.STATUS_OPEN).setResolution(null));
- assertThat(index.search(IssueQuery.builder(userSessionRule).resolved(true).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).resolved(false).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).resolved(null).build(), new SearchOptions()).getDocs()).hasSize(3);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).resolved(true).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).resolved(false).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).resolved(null).build(), new SearchOptions()).getDocs()).hasSize(3);
}
@Test
indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()));
- assertThat(index.search(IssueQuery.builder(userSessionRule).rules(newArrayList(ruleKey)).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).rules(newArrayList(RuleKey.of("rule", "without issue"))).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).rules(newArrayList(ruleKey)).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).rules(newArrayList(RuleKey.of("rule", "without issue"))).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo"));
- assertThat(index.search(IssueQuery.builder(userSessionRule).languages(newArrayList("xoo")).build(),
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).languages(newArrayList("xoo")).build(),
new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).languages(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).languages(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
indexIssues(IssueTesting.newDoc("ISSUE1", file).setRuleKey(ruleKey.toString()).setLanguage("xoo"));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("languages")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("languages")));
assertThat(result.getFacets().getNames()).containsOnly("languages");
assertThat(result.getFacets().get("languages")).containsOnly(entry("xoo", 1L));
}
IssueTesting.newDoc("ISSUE2", file).setAssignee("simon"),
IssueTesting.newDoc("ISSUE3", file).setAssignee(null));
- assertThat(index.search(IssueQuery.builder(userSessionRule).assignees(newArrayList("steph")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).assignees(newArrayList("steph", "simon")).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).assignees(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).assignees(newArrayList("steph")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).assignees(newArrayList("steph", "simon")).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).assignees(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE3", file).setAssignee("simon"),
IssueTesting.newDoc("ISSUE4", file).setAssignee(null));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("assignees")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("assignees")));
assertThat(result.getFacets().getNames()).containsOnly("assignees");
assertThat(result.getFacets().get("assignees")).containsOnly(entry("steph", 1L), entry("simon", 2L), entry("", 1L));
}
IssueTesting.newDoc("ISSUE3", file).setAssignee("simon"),
IssueTesting.newDoc("ISSUE4", file).setAssignee(null));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).assignees(Arrays.asList("j-b")).build(),
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).assignees(Arrays.asList("j-b")).build(),
new SearchOptions().addFacets(newArrayList("assignees")));
assertThat(result.getFacets().getNames()).containsOnly("assignees");
assertThat(result.getFacets().get("assignees")).containsOnly(entry("j-b", 1L), entry("simon", 2L), entry("", 1L));
IssueTesting.newDoc("ISSUE2", file).setAssignee(null),
IssueTesting.newDoc("ISSUE3", file).setAssignee(null));
- assertThat(index.search(IssueQuery.builder(userSessionRule).assigned(true).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).assigned(false).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).assigned(null).build(), new SearchOptions()).getDocs()).hasSize(3);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).assigned(true).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).assigned(false).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).assigned(null).build(), new SearchOptions()).getDocs()).hasSize(3);
}
@Test
IssueTesting.newDoc("ISSUE2", file).setAuthorLogin("simon"),
IssueTesting.newDoc("ISSUE3", file).setAssignee(null));
- assertThat(index.search(IssueQuery.builder(userSessionRule).authors(newArrayList("steph")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).authors(newArrayList("steph", "simon")).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).authors(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).authors(newArrayList("steph")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).authors(newArrayList("steph", "simon")).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).authors(newArrayList("unknown")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE3", file).setAuthorLogin("simon"),
IssueTesting.newDoc("ISSUE4", file).setAuthorLogin(null));
- SearchResult<IssueDoc> result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("authors")));
+ SearchResult<IssueDoc> result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().addFacets(newArrayList("authors")));
assertThat(result.getFacets().getNames()).containsOnly("authors");
assertThat(result.getFacets().get("authors")).containsOnly(entry("steph", 1L), entry("simon", 2L));
}
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")),
IssueTesting.newDoc("ISSUE2", file).setFuncCreationDate(parseDate("2014-09-23")));
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-19")).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-19")).build(), new SearchOptions()).getDocs()).hasSize(2);
// Lower bound is included
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")),
IssueTesting.newDoc("ISSUE2", file).setFuncCreationDate(parseDate("2014-09-23")));
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-19")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-19")).build(), new SearchOptions()).getDocs()).isEmpty();
// Upper bound is excluded
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).isEmpty();
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdBefore(parseDate("2014-09-25")).build(), new SearchOptions()).getDocs()).hasSize(2);
}
@Test
IssueTesting.newDoc("ISSUE2", file).setFuncCreationDate(parseDate("2014-09-23")));
// 19 < createdAt < 25
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDate("2014-09-19")).createdBefore(parseDate("2014-09-25"))
.build(), new SearchOptions()).getDocs()).hasSize(2);
// 20 < createdAt < 25: excludes first issue
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDate("2014-09-20")).createdBefore(parseDate("2014-09-25"))
.build(), new SearchOptions()).getDocs()).hasSize(2);
// 21 < createdAt < 25
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDate("2014-09-21")).createdBefore(parseDate("2014-09-25"))
.build(), new SearchOptions()).getDocs()).hasSize(1);
// 21 < createdAt < 24
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDate("2014-09-21")).createdBefore(parseDate("2014-09-24"))
.build(), new SearchOptions()).getDocs()).hasSize(1);
// 21 < createdAt < 23: excludes second issue
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDate("2014-09-21")).createdBefore(parseDate("2014-09-23"))
.build(), new SearchOptions()).getDocs()).isEmpty();
// 19 < createdAt < 21: only first issue
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDate("2014-09-19")).createdBefore(parseDate("2014-09-21"))
.build(), new SearchOptions()).getDocs()).hasSize(1);
// 20 < createdAt < 20: nothing
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDate("2014-09-20")).createdBefore(parseDate("2014-09-20"))
.build(), new SearchOptions()).getDocs()).isEmpty();
}
IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDateTime("2014-09-20T00:00:00+0100")),
IssueTesting.newDoc("ISSUE2", file).setFuncCreationDate(parseDateTime("2014-09-23T00:00:00+0100")));
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDateTime("2014-09-19T23:00:00+0000")).createdBefore(parseDateTime("2014-09-22T23:00:01+0000"))
.build(), new SearchOptions()).getDocs()).hasSize(2);
- assertThat(index.search(IssueQuery.builder(userSessionRule)
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDateTime("2014-09-19T23:00:01+0000")).createdBefore(parseDateTime("2014-09-22T23:00:00+0000"))
.build(), new SearchOptions()).getDocs()).hasSize(0);
}
@Test
public void filter_by_created_before_must_be_lower_than_after() {
try {
- index.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-20")).createdBefore(parseDate("2014-09-19")).build(),
+ underTest.search(IssueQuery.builder(userSessionRule).createdAfter(parseDate("2014-09-20")).createdBefore(parseDate("2014-09-19")).build(),
new SearchOptions());
Fail.failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (IllegalArgumentException exception) {
@Test
public void filter_by_created_after_must_not_be_in_future() {
try {
- index.search(IssueQuery.builder(userSessionRule).createdAfter(new Date(Long.MAX_VALUE)).build(), new SearchOptions());
+ underTest.search(IssueQuery.builder(userSessionRule).createdAfter(new Date(Long.MAX_VALUE)).build(), new SearchOptions());
Fail.failBecauseExceptionWasNotThrown(IllegalArgumentException.class);
} catch (IllegalArgumentException exception) {
assertThat(exception.getMessage()).isEqualTo("Start bound cannot be in the future");
indexIssues(IssueTesting.newDoc("ISSUE1", file).setFuncCreationDate(parseDate("2014-09-20")));
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdAt(parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).hasSize(1);
- assertThat(index.search(IssueQuery.builder(userSessionRule).createdAt(parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdAt(parseDate("2014-09-20")).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).createdAt(parseDate("2014-09-21")).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
.createdBefore(parseDateTime("2014-09-08T00:00:00+0100"))
.checkAuthorization(false)
.build();
- SearchResult<IssueDoc> result = index.search(query, options);
+ SearchResult<IssueDoc> result = underTest.search(query, options);
Map<String, Long> buckets = result.getFacets().get("createdAt");
assertThat(buckets).containsOnly(
entry("2014-08-31T01:00:00+0000", 0L),
SearchOptions SearchOptions = fixtureForCreatedAtFacet();
- Map<String, Long> createdAt = index.search(IssueQuery.builder(userSessionRule)
+ Map<String, Long> createdAt = underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDateTime("2014-09-01T00:00:00+0100"))
.createdBefore(parseDateTime("2014-09-21T00:00:00+0100")).build(),
SearchOptions).getFacets().get("createdAt");
SearchOptions SearchOptions = fixtureForCreatedAtFacet();
- Map<String, Long> createdAt = index.search(IssueQuery.builder(userSessionRule)
+ Map<String, Long> createdAt = underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDateTime("2014-09-01T00:00:00+0100"))
.createdBefore(parseDateTime("2015-01-19T00:00:00+0100")).build(),
SearchOptions).getFacets().get("createdAt");
public void facet_on_created_at_with_more_than_20_months() {
SearchOptions SearchOptions = fixtureForCreatedAtFacet();
- Map<String, Long> createdAt = index.search(IssueQuery.builder(userSessionRule)
+ Map<String, Long> createdAt = underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDateTime("2011-01-01T00:00:00+0100"))
.createdBefore(parseDateTime("2016-01-01T00:00:00+0100")).build(),
SearchOptions).getFacets().get("createdAt");
}
+ @Test
+ public void facet_on_created_at_with_one_day() {
+ SearchOptions SearchOptions = fixtureForCreatedAtFacet();
+
+ Map<String, Long> createdAt = underTest.search(IssueQuery.builder(userSessionRule)
+ .createdAfter(parseDateTime("2014-09-01T00:00:00-0100"))
+ .createdBefore(parseDateTime("2014-09-02T00:00:00-0100")).build(),
+ SearchOptions).getFacets().get("createdAt");
+ assertThat(createdAt).containsOnly(
+ entry("2014-09-01T01:00:00+0000", 2L));
+ }
+
@Test
public void facet_on_created_at_with_bounds_outside_of_data() {
SearchOptions options = fixtureForCreatedAtFacet();
- Map<String, Long> createdAt = index.search(IssueQuery.builder(userSessionRule)
+ Map<String, Long> createdAt = underTest.search(IssueQuery.builder(userSessionRule)
.createdAfter(parseDateTime("2009-01-01T00:00:00+0100"))
.createdBefore(parseDateTime("2016-01-01T00:00:00+0100"))
.build(), options).getFacets().get("createdAt");
public void facet_on_created_at_without_start_bound() {
SearchOptions SearchOptions = fixtureForCreatedAtFacet();
- Map<String, Long> createdAt = index.search(IssueQuery.builder(userSessionRule)
+ Map<String, Long> createdAt = underTest.search(IssueQuery.builder(userSessionRule)
.createdBefore(parseDateTime("2016-01-01T00:00:00+0100")).build(),
SearchOptions).getFacets().get("createdAt");
assertThat(createdAt).containsOnly(
public void facet_on_created_at_without_issues() {
SearchOptions SearchOptions = new SearchOptions().addFacets("createdAt");
- Map<String, Long> createdAt = index.search(IssueQuery.builder(userSessionRule).build(),
+ Map<String, Long> createdAt = underTest.search(IssueQuery.builder(userSessionRule).build(),
SearchOptions).getFacets().get("createdAt");
assertThat(createdAt).isEmpty();
}
IssueQuery.Builder query = IssueQuery.builder(userSessionRule);
// There are 12 issues in total, with 10 issues per page, the page 2 should only contain 2 elements
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions().setPage(2, 10));
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions().setPage(2, 10));
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getTotal()).isEqualTo(12);
- result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().setOffset(0).setLimit(5));
+ result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().setOffset(0).setLimit(5));
assertThat(result.getDocs()).hasSize(5);
assertThat(result.getTotal()).isEqualTo(12);
- result = index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().setOffset(2).setLimit(0));
+ result = underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions().setOffset(2).setLimit(0));
assertThat(result.getDocs()).hasSize(10);
assertThat(result.getTotal()).isEqualTo(12);
}
indexIssues(issues.toArray(new IssueDoc[] {}));
IssueQuery.Builder query = IssueQuery.builder(userSessionRule);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions().setLimit(Integer.MAX_VALUE));
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions().setLimit(Integer.MAX_VALUE));
assertThat(result.getDocs()).hasSize(SearchOptions.MAX_LIMIT);
}
IssueTesting.newDoc("ISSUE3", file).setStatus(Issue.STATUS_REOPENED));
IssueQuery.Builder query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_STATUS).asc(true);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions());
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs().get(0).status()).isEqualTo(Issue.STATUS_CLOSED);
assertThat(result.getDocs().get(1).status()).isEqualTo(Issue.STATUS_OPEN);
assertThat(result.getDocs().get(2).status()).isEqualTo(Issue.STATUS_REOPENED);
query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_STATUS).asc(false);
- result = index.search(query.build(), new SearchOptions());
+ result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs().get(0).status()).isEqualTo(Issue.STATUS_REOPENED);
assertThat(result.getDocs().get(1).status()).isEqualTo(Issue.STATUS_OPEN);
assertThat(result.getDocs().get(2).status()).isEqualTo(Issue.STATUS_CLOSED);
IssueTesting.newDoc("ISSUE5", file).setSeverity(Severity.MAJOR));
IssueQuery.Builder query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_SEVERITY).asc(true);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions());
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs().get(0).severity()).isEqualTo(Severity.INFO);
assertThat(result.getDocs().get(1).severity()).isEqualTo(Severity.MINOR);
assertThat(result.getDocs().get(2).severity()).isEqualTo(Severity.MAJOR);
assertThat(result.getDocs().get(4).severity()).isEqualTo(Severity.BLOCKER);
query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_SEVERITY).asc(false);
- result = index.search(query.build(), new SearchOptions());
+ result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs().get(0).severity()).isEqualTo(Severity.BLOCKER);
assertThat(result.getDocs().get(1).severity()).isEqualTo(Severity.CRITICAL);
assertThat(result.getDocs().get(2).severity()).isEqualTo(Severity.MAJOR);
IssueTesting.newDoc("ISSUE2", file).setAssignee("simon"));
IssueQuery.Builder query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_ASSIGNEE).asc(true);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions());
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).assignee()).isEqualTo("simon");
assertThat(result.getDocs().get(1).assignee()).isEqualTo("steph");
query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_ASSIGNEE).asc(false);
- result = index.search(query.build(), new SearchOptions());
+ result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).assignee()).isEqualTo("steph");
assertThat(result.getDocs().get(1).assignee()).isEqualTo("simon");
IssueTesting.newDoc("ISSUE2", file).setFuncCreationDate(parseDateTime("2014-09-24T00:00:00+0100")));
IssueQuery.Builder query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_CREATION_DATE).asc(true);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions());
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).creationDate()).isEqualTo(parseDateTime("2014-09-23T00:00:00+0100"));
assertThat(result.getDocs().get(1).creationDate()).isEqualTo(parseDateTime("2014-09-24T00:00:00+0100"));
query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_CREATION_DATE).asc(false);
- result = index.search(query.build(), new SearchOptions());
+ result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).creationDate()).isEqualTo(parseDateTime("2014-09-24T00:00:00+0100"));
assertThat(result.getDocs().get(1).creationDate()).isEqualTo(parseDateTime("2014-09-23T00:00:00+0100"));
IssueTesting.newDoc("ISSUE2", file).setFuncUpdateDate(parseDateTime("2014-09-24T00:00:00+0100")));
IssueQuery.Builder query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_UPDATE_DATE).asc(true);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions());
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).updateDate()).isEqualTo(parseDateTime("2014-09-23T00:00:00+0100"));
assertThat(result.getDocs().get(1).updateDate()).isEqualTo(parseDateTime("2014-09-24T00:00:00+0100"));
query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_UPDATE_DATE).asc(false);
- result = index.search(query.build(), new SearchOptions());
+ result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(2);
assertThat(result.getDocs().get(0).updateDate()).isEqualTo(parseDateTime("2014-09-24T00:00:00+0100"));
assertThat(result.getDocs().get(1).updateDate()).isEqualTo(parseDateTime("2014-09-23T00:00:00+0100"));
IssueTesting.newDoc("ISSUE3", file).setFuncCloseDate(null));
IssueQuery.Builder query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_CLOSE_DATE).asc(true);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions());
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(3);
assertThat(result.getDocs().get(0).closeDate()).isNull();
assertThat(result.getDocs().get(1).closeDate()).isEqualTo(parseDateTime("2014-09-23T00:00:00+0100"));
assertThat(result.getDocs().get(2).closeDate()).isEqualTo(parseDateTime("2014-09-24T00:00:00+0100"));
query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_CLOSE_DATE).asc(false);
- result = index.search(query.build(), new SearchOptions());
+ result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(3);
assertThat(result.getDocs().get(0).closeDate()).isEqualTo(parseDateTime("2014-09-24T00:00:00+0100"));
assertThat(result.getDocs().get(1).closeDate()).isEqualTo(parseDateTime("2014-09-23T00:00:00+0100"));
// ascending sort -> F1 then F2. Line "0" first.
IssueQuery.Builder query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_FILE_LINE).asc(true);
- SearchResult<IssueDoc> result = index.search(query.build(), new SearchOptions());
+ SearchResult<IssueDoc> result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(6);
assertThat(result.getDocs().get(0).key()).isEqualTo("F1_1");
assertThat(result.getDocs().get(1).key()).isEqualTo("F1_2");
// descending sort -> F2 then F1
query = IssueQuery.builder(userSessionRule).sort(IssueQuery.SORT_BY_FILE_LINE).asc(false);
- result = index.search(query.build(), new SearchOptions());
+ result = underTest.search(query.build(), new SearchOptions());
assertThat(result.getDocs()).hasSize(6);
assertThat(result.getDocs().get(0).key()).isEqualTo("F2_3");
assertThat(result.getDocs().get(1).key()).isEqualTo("F2_2");
indexIssue(IssueTesting.newDoc("ISSUE3", file3), null, null);
userSessionRule.login().setUserGroups("sonar-users");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
userSessionRule.login().setUserGroups("sonar-admins");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
userSessionRule.login().setUserGroups("sonar-users", "sonar-admins");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(2);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(2);
userSessionRule.login().setUserGroups("another group");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).isEmpty();
userSessionRule.login().setUserGroups("sonar-users", "sonar-admins");
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project3.uuid())).build(), new SearchOptions()).getDocs()).isEmpty();
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project3.uuid())).build(), new SearchOptions()).getDocs()).isEmpty();
}
@Test
userSessionRule.login("john");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
userSessionRule.login("max");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
userSessionRule.login("another guy");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(0);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(0);
userSessionRule.login("john");
- assertThat(index.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project3.key())).build(), new SearchOptions()).getDocs()).hasSize(0);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).projectUuids(newArrayList(project3.key())).build(), new SearchOptions()).getDocs()).hasSize(0);
}
@Test
indexIssue(IssueTesting.newDoc("ISSUE2", file2), null, "max");
userSessionRule.login("john").setUserGroups("sonar-users");
- assertThat(index.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
+ assertThat(underTest.search(IssueQuery.builder(userSessionRule).build(), new SearchOptions()).getDocs()).hasSize(1);
}
@Test
.setFuncCreationDate(new Date());
indexIssues(issue);
- List<IssueDoc> issues = Lists.newArrayList(index.selectIssuesForBatch(file));
+ List<IssueDoc> issues = Lists.newArrayList(underTest.selectIssuesForBatch(file));
assertThat(issues).hasSize(1);
IssueDoc result = issues.get(0);
assertThat(result.key()).isEqualTo("ISSUE");
// Close Issue, should never be returned
IssueTesting.newDoc("CLOSE_ISSUE", file).setStatus(Issue.STATUS_CLOSED).setResolution(Issue.RESOLUTION_FIXED));
- assertThat(Lists.newArrayList(index.selectIssuesForBatch(project))).hasSize(3);
- assertThat(Lists.newArrayList(index.selectIssuesForBatch(module))).hasSize(3);
- assertThat(Lists.newArrayList(index.selectIssuesForBatch(subModule))).hasSize(2);
- assertThat(Lists.newArrayList(index.selectIssuesForBatch(file))).hasSize(1);
- assertThat(Lists.newArrayList(index.selectIssuesForBatch(ComponentTesting.newProjectDto()))).isEmpty();
+ assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(project))).hasSize(3);
+ assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(module))).hasSize(3);
+ assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(subModule))).hasSize(2);
+ assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(file))).hasSize(1);
+ assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(ComponentTesting.newProjectDto()))).isEmpty();
}
@Test
public void fail_to_search_issues_for_batch_on_not_allowed_scope() {
try {
- index.selectIssuesForBatch(new ComponentDto().setScope(Scopes.DIRECTORY));
+ underTest.selectIssuesForBatch(new ComponentDto().setScope(Scopes.DIRECTORY));
failBecauseExceptionWasNotThrown(IllegalStateException.class);
} catch (IllegalStateException e) {
assertThat(e).hasMessage("Component of scope 'DIR' is not allowed");
indexIssue(IssueTesting.newDoc("ISSUE3", file2), null, null);
userSessionRule.setUserGroups("sonar-users");
- assertThat(Lists.newArrayList(index.selectIssuesForBatch(project1))).hasSize(1);
+ assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(project1))).hasSize(1);
userSessionRule.setUserGroups("another group");
- assertThat(Lists.newArrayList(index.selectIssuesForBatch(project2))).isEmpty();
+ assertThat(Lists.newArrayList(underTest.selectIssuesForBatch(project2))).isEmpty();
}
private void indexIssues(IssueDoc... issues) {