use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexTypeTest method parseMainType_from_maintype_with_relations.
@Test
public void parseMainType_from_maintype_with_relations() {
IndexMainType type1 = IndexType.main(Index.withRelations("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 relation_fails_with_IAE_if_index_name_is_null_or_empty.
@Test
@UseDataProvider("nullOrEmpty")
public void relation_fails_with_IAE_if_index_name_is_null_or_empty(String nullOrEmpty) {
Index index = Index.withRelations("foo");
IndexMainType mainType = IndexType.main(index, "foobar");
assertThatThrownBy(() -> IndexType.relation(mainType, nullOrEmpty)).isInstanceOf(IllegalArgumentException.class).hasMessage("type name can't be null nor empty");
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexTypeTest method IndexRelationType_equals_and_hashCode.
@Test
public void IndexRelationType_equals_and_hashCode() {
IndexMainType mainType1 = IndexType.main(Index.withRelations("foo"), "bar");
IndexMainType mainType2 = IndexType.main(Index.withRelations("foo"), "baz");
IndexRelationType type1 = IndexType.relation(mainType1, "donut");
IndexRelationType type1b = IndexType.relation(mainType1, "donut");
IndexRelationType type2 = IndexType.relation(mainType1, "donuz");
IndexRelationType type3 = IndexType.relation(mainType2, "donut");
assertThat(type1).isEqualTo(type1).isEqualTo(type1b).isNotEqualTo(type2).isNotEqualTo(type3).hasSameHashCodeAs(type1).hasSameHashCodeAs(type1b);
assertThat(type2.hashCode()).isNotEqualTo(type1.hashCode());
assertThat(type3.hashCode()).isNotEqualTo(type2.hashCode()).isNotEqualTo(type1.hashCode());
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexTypeTest method IndexMainType_equals_and_hashCode.
@Test
public void IndexMainType_equals_and_hashCode() {
IndexMainType type1 = IndexType.main(Index.simple("foo"), "bar");
IndexMainType type1b = IndexType.main(Index.simple("foo"), "bar");
IndexMainType type1c = IndexType.main(Index.withRelations("foo"), "bar");
IndexMainType type2 = IndexType.main(Index.simple("foo"), "baz");
assertThat(type1).isEqualTo(type1).isEqualTo(type1b).isNotEqualTo(type1c).isNotEqualTo(type2).hasSameHashCodeAs(type1).hasSameHashCodeAs(type1b);
assertThat(type1.hashCode()).isNotEqualTo(type1c.hashCode());
assertThat(type2.hashCode()).isNotEqualTo(type1.hashCode());
}
use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class RecoveryIndexerTest method successfully_recover_indexing_requests.
@Test
public void successfully_recover_indexing_requests() {
EsQueueDto item1a = insertItem(FOO_TYPE, "f1");
EsQueueDto item1b = insertItem(FOO_TYPE, "f2");
IndexMainType type2 = IndexType.main(Index.simple("bars"), "bar");
EsQueueDto item2 = insertItem(type2, "b1");
SuccessfulFakeIndexer indexer1 = new SuccessfulFakeIndexer(FOO_TYPE);
SuccessfulFakeIndexer indexer2 = new SuccessfulFakeIndexer(type2);
advanceInTime();
underTest = newRecoveryIndexer(indexer1, indexer2);
underTest.recover();
assertThatQueueHasSize(0);
assertThatLogsContain(INFO, "Elasticsearch recovery - 3 documents processed [0 failures]");
assertThat(indexer1.called).hasSize(1);
assertThat(indexer1.called.get(0)).extracting(EsQueueDto::getUuid).containsExactlyInAnyOrder(item1a.getUuid(), item1b.getUuid());
assertThatLogsContain(TRACE, "Elasticsearch recovery - processing 2 [foos/foo]");
assertThat(indexer2.called).hasSize(1);
assertThat(indexer2.called.get(0)).extracting(EsQueueDto::getUuid).containsExactlyInAnyOrder(item2.getUuid());
assertThatLogsContain(TRACE, "Elasticsearch recovery - processing 1 [bars/bar]");
}
Aggregations