replaced integration test with unit test.

Closes #16692
This commit is contained in:
Martijn van Groningen 2016-03-03 15:31:57 +01:00
parent 98c164c3f0
commit f0e80e1a7a
2 changed files with 10 additions and 15 deletions

View File

@ -73,6 +73,8 @@ public class HasParentQueryBuilderTests extends AbstractQueryTestCase<HasParentQ
DATE_FIELD_NAME, "type=date",
OBJECT_FIELD_NAME, "type=object"
).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
mapperService.merge("just_a_type", new CompressedXContent(PutMappingRequest.buildFromSimplifiedDef("just_a_type"
).string()), MapperService.MergeReason.MAPPING_UPDATE, false);
}
@Override
@ -132,20 +134,26 @@ public class HasParentQueryBuilderTests extends AbstractQueryTestCase<HasParentQ
}
}
public void testIllegalValues() {
public void testIllegalValues() throws IOException {
QueryBuilder query = RandomQueryBuilder.createQuery(random());
try {
new HasParentQueryBuilder(null, query);
fail("must not be null");
} catch (IllegalArgumentException ex) {
}
try {
new HasParentQueryBuilder("foo", null);
fail("must not be null");
} catch (IllegalArgumentException ex) {
}
QueryShardContext context = createShardContext();
HasParentQueryBuilder queryBuilder = new HasParentQueryBuilder("just_a_type", new MatchAllQueryBuilder());
try {
queryBuilder.doToQuery(context);
} catch (QueryShardException e) {
assertThat(e.getMessage(), equalTo("[has_parent] no child types found for type [just_a_type]"));
}
}

View File

@ -1922,17 +1922,4 @@ public class ChildQuerySearchIT extends ESIntegTestCase {
QueryBuilders.hasChildQuery("child-type", new IdsQueryBuilder().addIds("child-id"))).get();
assertSearchHits(searchResponse, "parent-id");
}
public void testParentWithoutChildTypes() {
assertAcked(prepareCreate("test").addMapping("parent").addMapping("child", "_parent", "type=parent"));
ensureGreen();
try {
client().prepareSearch("test").setQuery(hasParentQuery("child", matchAllQuery())).get();
fail();
} catch (SearchPhaseExecutionException e) {
assertThat(e.status(), equalTo(RestStatus.BAD_REQUEST));
assertThat(e.toString(), containsString("[has_parent] no child types found for type [child]"));
}
}
}