@Rule
public EsTester es = new EsTester(new TestIndexDefinition(new MapSettings().asConfig()));
- TestIndex underTest = new TestIndex(es.client(), System2.INSTANCE);
+ private TestIndex underTest = new TestIndex(es.client(), System2.INSTANCE);
@Test
- public void coveredFiles() throws Exception {
+ public void coveredFiles() {
es.putDocuments(INDEX_TYPE_TEST,
newTestDoc("1", "TESTFILE1", newCoveredFileDoc("3"), newCoveredFileDoc("4"), newCoveredFileDoc("5")),
newTestDoc("2", "TESTFILE1", newCoveredFileDoc("5"), newCoveredFileDoc("6"), newCoveredFileDoc("7")));
}
@Test
- public void searchByTestFileUuid() throws Exception {
+ public void searchByTestFileUuid() {
es.putDocuments(INDEX_TYPE_TEST,
newTestDoc("1", "TESTFILE1", newCoveredFileDoc("3"), newCoveredFileDoc("4"), newCoveredFileDoc("5")),
newTestDoc("2", "TESTFILE1", newCoveredFileDoc("5"), newCoveredFileDoc("6"), newCoveredFileDoc("7")),
}
@Test
- public void searchBySourceFileUuidAndLineNumber() throws Exception {
+ public void searchBySourceFileUuidAndLineNumber() {
es.putDocuments(INDEX_TYPE_TEST,
newTestDoc("1", "TESTFILE1", newCoveredFileDoc("10"), newCoveredFileDoc("11"), newCoveredFileDoc("12")),
newTestDoc("2", "TESTFILE1", newCoveredFileDoc("3"), newCoveredFileDoc("4"), newCoveredFileDoc("5")),
}
@Test
- public void searchByTestUuid() throws Exception {
+ public void searchByTestUuid() {
es.putDocuments(INDEX_TYPE_TEST,
newTestDoc("1", "TESTFILE1", newCoveredFileDoc("3"), newCoveredFileDoc("4"), newCoveredFileDoc("5")),
newTestDoc("2", "TESTFILE1", newCoveredFileDoc("5"), newCoveredFileDoc("6"), newCoveredFileDoc("7")));
}
@Test
- public void getNullableByTestUuid() throws Exception {
+ public void getNullableByTestUuid() {
es.putDocuments(INDEX_TYPE_TEST,
newTestDoc("1", "TESTFILE1", newCoveredFileDoc("3"), newCoveredFileDoc("4"), newCoveredFileDoc("5")),
newTestDoc("2", "TESTFILE1", newCoveredFileDoc("5"), newCoveredFileDoc("6"), newCoveredFileDoc("7")));
}
@Test
- public void searchByTestUuid_with_SearchOptions() throws Exception {
+ public void searchByTestUuid_with_SearchOptions() {
es.putDocuments(INDEX_TYPE_TEST,
newTestDoc("1", "TESTFILE1", newCoveredFileDoc("3"), newCoveredFileDoc("4"), newCoveredFileDoc("5")),
newTestDoc("2", "TESTFILE1", newCoveredFileDoc("5"), newCoveredFileDoc("6"), newCoveredFileDoc("7")));
import java.util.List;
import java.util.Map;
import org.apache.commons.io.IOUtils;
-import org.elasticsearch.action.search.SearchRequestBuilder;
+import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.search.SearchHit;
import org.junit.Rule;
import org.junit.Test;
}
private void indexTest(String projectUuid, String fileUuid, String testName, String uuid) throws IOException {
+ String json = IOUtils.toString(getClass().getResource(format("%s/%s_%s_%s.json", getClass().getSimpleName(), projectUuid, fileUuid, testName)));
es.client().prepareIndex(INDEX_TYPE_TEST)
.setId(uuid)
.setRouting(projectUuid)
- .setSource(IOUtils.toString(getClass().getResource(format("%s/%s_%s_%s.json", getClass().getSimpleName(), projectUuid, fileUuid, testName))))
+ .setSource(json, XContentType.JSON)
.setRefreshPolicy(REFRESH_IMMEDIATE)
.get();
}
- private SearchRequestBuilder prepareSearch() {
- return es.client().prepareSearch(INDEX_TYPE_TEST);
- }
-
private List<SearchHit> getDocuments() {
return es.getDocuments(INDEX_TYPE_TEST);
}