use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class AuthorizationScope method getAuthorizationIndexType.
/**
* @return the identifier of the ElasticSearch type (including it's index name), that corresponds to a certain document type
*/
private static IndexMainType getAuthorizationIndexType(IndexRelationType functionalType) {
requireNonNull(functionalType);
IndexMainType mainType = functionalType.getMainType();
checkArgument(TYPE_AUTHORIZATION.equals(mainType.getType()), "Index %s doesn't seem to be an authorized index as main type is not %s (got %s)", mainType.getIndex(), TYPE_AUTHORIZATION, mainType.getType());
return mainType;
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_is_the_same_if_only_order_of_textFieldBuilder_options_change.
@Test
public void hash_is_the_same_if_only_order_of_textFieldBuilder_options_change() {
Index index = Index.withRelations("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
String fieldName = "field1";
computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.textFieldBuilder(fieldName).disableSearch().disableNorms().build(), (mapping) -> mapping.textFieldBuilder(fieldName).disableNorms().disableSearch().build());
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_changes_if_refreshInterval_changes.
@Test
public void hash_changes_if_refreshInterval_changes() {
Index index = Index.simple("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
Configuration emptySettings = new MapSettings().asConfig();
SettingsConfiguration defaultRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).build();
SettingsConfiguration noRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(-1).build();
SettingsConfiguration refreshInterval30 = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(30).build();
SettingsConfiguration someRefreshInterval = SettingsConfiguration.newBuilder(emptySettings).setRefreshInterval(56).build();
assertThat(hashOf(new TestNewIndex(mainType, defaultRefreshInterval))).isEqualTo(hashOf(new TestNewIndex(mainType, defaultRefreshInterval))).isEqualTo(hashOf(new TestNewIndex(mainType, refreshInterval30))).isNotEqualTo(hashOf(new TestNewIndex(mainType, noRefreshInterval))).isNotEqualTo(hashOf(new TestNewIndex(mainType, someRefreshInterval)));
assertThat(hashOf(new TestNewIndex(mainType, noRefreshInterval))).isNotEqualTo(hashOf(new TestNewIndex(mainType, someRefreshInterval)));
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_is_the_same_if_only_relations_order_changes.
@Test
public void hash_is_the_same_if_only_relations_order_changes() {
Index index = Index.withRelations("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
TestNewIndex indexTwoRelations = new TestNewIndex(mainType, settingsConfiguration).addRelation("donut1").addRelation("donut2").addRelation("donut3");
TestNewIndex indexTwoRelationsOtherOrder = new TestNewIndex(mainType, settingsConfiguration).addRelation("donut2").addRelation("donut1").addRelation("donut3");
TestNewIndex indexTwoRelationsOtherOrder2 = new TestNewIndex(mainType, settingsConfiguration).addRelation("donut2").addRelation("donut3").addRelation("donut1");
assertThat(hashOf(indexTwoRelations)).isEqualTo(hashOf(indexTwoRelationsOtherOrder)).isEqualTo(hashOf(indexTwoRelationsOtherOrder2));
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_is_the_same_if_only_order_of_keyword_options_change.
@Test
public void hash_is_the_same_if_only_order_of_keyword_options_change() {
Index index = Index.withRelations("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
String fieldName = "field1";
computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSortingAndAggregating().disableNorms().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSortingAndAggregating().build());
computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSortingAndAggregating().disableSearch().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableSortingAndAggregating().build());
computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableNorms().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSearch().build());
computeAndVerifyAllSameHashesOnMapping(mainType, (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSortingAndAggregating().disableSearch().disableNorms().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableNorms().disableSortingAndAggregating().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSearch().disableSortingAndAggregating().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableNorms().disableSortingAndAggregating().disableSearch().build(), (mapping) -> mapping.keywordFieldBuilder(fieldName).disableSearch().disableSortingAndAggregating().disableNorms().build());
}
Aggregations