use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexDefinitionHashTest method hash_changes_if_fields_on_main_type_mapping_are_different.
@Test
public void hash_changes_if_fields_on_main_type_mapping_are_different() {
Index index = Index.withRelations("foo");
IndexMainType mainType = IndexMainType.main(index, "bar");
TestNewIndex indexNoField = new TestNewIndex(mainType, settingsConfiguration);
TestNewIndex indexOneField = new TestNewIndex(mainType, settingsConfiguration);
indexOneField.getMainTypeMapping().createIntegerField("field1");
TestNewIndex indexOneFieldAgain = new TestNewIndex(mainType, settingsConfiguration);
indexOneFieldAgain.getMainTypeMapping().createIntegerField("field1");
TestNewIndex indexOneOtherField = new TestNewIndex(mainType, settingsConfiguration);
indexOneOtherField.getMainTypeMapping().createIntegerField("field2");
TestNewIndex indexTwoFields = new TestNewIndex(mainType, settingsConfiguration);
indexTwoFields.getMainTypeMapping().createIntegerField("field1").createIntegerField("field2");
TestNewIndex indexTwoFieldsAgain = new TestNewIndex(mainType, settingsConfiguration);
indexTwoFieldsAgain.getMainTypeMapping().createIntegerField("field1").createIntegerField("field2");
TestNewIndex indexTwoOtherFields = new TestNewIndex(mainType, settingsConfiguration);
indexTwoOtherFields.getMainTypeMapping().createIntegerField("field1").createIntegerField("field3");
assertThat(hashOf(indexNoField)).isEqualTo(hashOf(new TestNewIndex(mainType, settingsConfiguration))).isNotEqualTo(hashOf(indexOneField)).isNotEqualTo(hashOf(indexOneOtherField)).isNotEqualTo(hashOf(indexTwoFields)).isNotEqualTo(hashOf(indexTwoOtherFields));
assertThat(hashOf(indexOneField)).isEqualTo(hashOf(indexOneFieldAgain)).isNotEqualTo(hashOf(indexOneOtherField)).isNotEqualTo(hashOf(indexTwoFields)).isNotEqualTo(hashOf(indexTwoOtherFields));
assertThat(hashOf(indexTwoFields)).isEqualTo(hashOf(indexTwoFieldsAgain)).isNotEqualTo(hashOf(indexOneField)).isNotEqualTo(hashOf(indexOneOtherField)).isNotEqualTo(hashOf(indexTwoOtherFields));
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexTypeTest method parseMainType_from_main_type_without_relations.
@Test
public void parseMainType_from_main_type_without_relations() {
IndexMainType type1 = IndexType.main(Index.simple("foo"), "bar");
assertThat(type1.format()).isEqualTo("foo/bar");
SimpleIndexMainType type2 = IndexType.parseMainType(type1.format());
assertThat(type2).extracting(SimpleIndexMainType::getIndex, SimpleIndexMainType::getType).containsExactly("foo", "bar");
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexTypeTest method parseMainType_from_relationtype.
@Test
public void parseMainType_from_relationtype() {
IndexMainType mainType = IndexType.main(Index.withRelations("foo"), "bar");
IndexRelationType type1 = IndexType.relation(mainType, "donut");
assertThat(type1.format()).isEqualTo("foo/bar/donut");
SimpleIndexMainType type2 = IndexType.parseMainType(type1.format());
assertThat(type2).extracting(SimpleIndexMainType::getIndex, SimpleIndexMainType::getType).containsExactly("foo", "bar");
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexCreatorTest method start_makes_index_read_write_if_read_only.
@Test
public void start_makes_index_read_write_if_read_only() {
FakeIndexDefinition fakeIndexDefinition = new FakeIndexDefinition();
IndexMainType fakeIndexMainType = FakeIndexDefinition.INDEX_TYPE.getMainType();
run(fakeIndexDefinition);
IndexMainType mainType = MetadataIndexDefinition.TYPE_METADATA;
makeReadOnly(mainType);
makeReadOnly(fakeIndexMainType);
run(fakeIndexDefinition);
assertThat(isNotReadOnly(mainType)).isTrue();
assertThat(isNotReadOnly(fakeIndexMainType)).isTrue();
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexCreatorTest method start_makes_metadata_index_read_write_if_read_only.
@Test
public void start_makes_metadata_index_read_write_if_read_only() {
run(new FakeIndexDefinition());
IndexMainType mainType = MetadataIndexDefinition.TYPE_METADATA;
makeReadOnly(mainType);
run(new FakeIndexDefinition());
assertThat(isNotReadOnly(mainType)).isTrue();
}
Aggregations