use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class BaseDocTest method getFields_contains_join_field_and_indexType_field_when_setParent_has_been_called_on_IndexRelationType.
@Test
public void getFields_contains_join_field_and_indexType_field_when_setParent_has_been_called_on_IndexRelationType() {
Index index = Index.withRelations("foo");
IndexType.IndexRelationType relationType = IndexType.relation(IndexType.main(index, "bar"), "donut");
BaseDoc doc = new BaseDoc(relationType) {
{
setParent("miam");
}
@Override
public String getId() {
throw new UnsupportedOperationException("getId not implemented");
}
};
Map<String, Object> fields = doc.getFields();
assertThat((Map) fields.get(index.getJoinField())).isEqualTo(ImmutableMap.of("name", relationType.getName(), "parent", "miam"));
assertThat(fields).containsEntry("indexType", relationType.getName());
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewRegularIndexTest method createTypeMapping_with_IndexRelationType_fails_with_IAE_if_mainType_does_not_match_defined_one.
@Test
public void createTypeMapping_with_IndexRelationType_fails_with_IAE_if_mainType_does_not_match_defined_one() {
Index index = Index.withRelations(SOME_INDEX_NAME);
IndexType.IndexMainType mainType = IndexType.main(index, "foo");
NewRegularIndex underTest = new NewRegularIndex(index, defaultSettingsConfiguration);
underTest.createTypeMapping(mainType);
assertThatThrownBy(() -> underTest.createTypeMapping(IndexType.relation(IndexType.main(index, "donut"), "bar"))).isInstanceOf(IllegalArgumentException.class).hasMessage("main type of relation must be " + mainType);
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewRegularIndexTest method build_fails_with_ISE_if_index_accepts_relations_and_none_is_defined.
@Test
public void build_fails_with_ISE_if_index_accepts_relations_and_none_is_defined() {
Index index = Index.withRelations(SOME_INDEX_NAME);
NewRegularIndex underTest = new NewRegularIndex(index, defaultSettingsConfiguration);
underTest.createTypeMapping(IndexType.main(index, "foo"));
assertThatThrownBy(() -> underTest.build()).isInstanceOf(IllegalStateException.class).hasMessage("At least one relation must be defined when index accepts relations");
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewRegularIndexTest method build_defines_type_field_if_index_accepts_relations.
@Test
public void build_defines_type_field_if_index_accepts_relations() {
Index someIndex = Index.withRelations(SOME_INDEX_NAME);
NewRegularIndex underTest = new NewRegularIndex(someIndex, defaultSettingsConfiguration);
underTest.createTypeMapping(IndexType.main(someIndex, "foo"));
underTest.createTypeMapping(IndexType.relation(underTest.getMainType(), "bar"));
BuiltIndex<NewRegularIndex> builtIndex = underTest.build();
Map<String, Object> properties = (Map<String, Object>) builtIndex.getAttributes().get("properties");
assertThat((Map) properties.get("indexType")).isEqualTo(ImmutableMap.of(TYPE, "keyword", NORMS, false, STORE, false, "doc_values", false));
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewRegularIndexTest method build_does_not_define_type_field_if_index_does_not_accept_relations.
@Test
public void build_does_not_define_type_field_if_index_does_not_accept_relations() {
Index someIndex = Index.simple(SOME_INDEX_NAME);
NewRegularIndex underTest = new NewRegularIndex(someIndex, defaultSettingsConfiguration);
underTest.createTypeMapping(IndexType.main(someIndex, "foo"));
BuiltIndex<NewRegularIndex> builtIndex = underTest.build();
Map<String, Object> properties = (Map<String, Object>) builtIndex.getAttributes().get("properties");
assertThat(properties.get("indexType")).isNull();
}
Aggregations