use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewRegularIndexTest method build_does_not_enforce_routing_if_mainType_does_not_accepts_relations.
@Test
public void build_does_not_enforce_routing_if_mainType_does_not_accepts_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();
assertThat(builtIndex.getAttributes().get("_routing")).isNull();
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewRegularIndexTest method createTypeMapping_with_IndexRelationType_fails_with_ISE_if_called_before_createType_with_IndexMainType.
@Test
public void createTypeMapping_with_IndexRelationType_fails_with_ISE_if_called_before_createType_with_IndexMainType() {
Index index = Index.withRelations(SOME_INDEX_NAME);
NewRegularIndex underTest = new NewRegularIndex(index, defaultSettingsConfiguration);
assertThatThrownBy(() -> underTest.createTypeMapping(IndexType.relation(IndexType.main(index, "foo"), "bar"))).isInstanceOf(IllegalStateException.class).hasMessage("Mapping for main type must be created first");
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewIndexTest method createTypeMapping_with_IndexRelationType_fails_with_ISE_if_index_does_not_allow_relations.
@Test
public void createTypeMapping_with_IndexRelationType_fails_with_ISE_if_index_does_not_allow_relations() {
IndexType.IndexRelationType indexRelationType = IndexType.relation(IndexType.main(Index.withRelations(someIndexName), "bar"), "bar");
Index index = Index.simple(someIndexName);
IndexMainType mainType = IndexType.main(index, "foo");
NewIndex underTest = new NewIndex(index, defaultSettingsConfiguration) {
@Override
public IndexMainType getMainType() {
return mainType;
}
@Override
public BuiltIndex build() {
throw new UnsupportedOperationException("build not implemented");
}
};
assertThatThrownBy(() -> underTest.createTypeMapping(indexRelationType)).isInstanceOf(IllegalStateException.class).hasMessage("Index is not configured to accept relations. Update IndexDefinition.Descriptor instance for this index");
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewIndexTest method indexAndTypeMappings.
@DataProvider
public static Object[][] indexAndTypeMappings() {
String indexName = randomAlphabetic(5).toLowerCase();
MapSettings settings = new MapSettings();
SettingsConfiguration defaultSettingsConfiguration = newBuilder(settings.asConfig()).build();
Index index = Index.withRelations(indexName);
IndexMainType mainType = IndexType.main(index, "foo");
SimplestNewIndex newIndex = new SimplestNewIndex(mainType, defaultSettingsConfiguration);
TypeMapping mainMapping = newIndex.createTypeMapping(mainType);
TypeMapping relationMapping = newIndex.createTypeMapping(IndexType.relation(mainType, "bar"));
return new Object[][] { { newIndex, mainMapping }, { newIndex, relationMapping } };
}
use of org.sonar.server.es.Index in project sonarqube by SonarSource.
the class NewAuthorizedIndexTest method constructor_fails_with_IAE_if_index_does_not_support_relations.
@Test
public void constructor_fails_with_IAE_if_index_does_not_support_relations() {
Index simpleIndex = Index.simple(someIndexName);
assertThatThrownBy(() -> new NewAuthorizedIndex(simpleIndex, defaultSettingsConfiguration)).isInstanceOf(IllegalArgumentException.class).hasMessage("Index must accept relations");
}
Aggregations