use of org.sonar.server.es.IndexType.IndexMainType in project sonarqube by SonarSource.
the class IndexCreatorTest method recreate_index_on_definition_changes.
@Test
public void recreate_index_on_definition_changes() {
// v1
run(new FakeIndexDefinition());
IndexMainType fakeIndexType = main(Index.simple("fakes"), "fake");
String id = "1";
es.client().index(new IndexRequest(fakeIndexType.getIndex().getName(), fakeIndexType.getType()).id(id).source(new FakeDoc().getFields()).setRefreshPolicy(WriteRequest.RefreshPolicy.IMMEDIATE));
assertThat(es.client().get(new GetRequest(fakeIndexType.getIndex().getName(), fakeIndexType.getType(), id)).isExists()).isTrue();
// v2
run(new FakeIndexDefinitionV2());
ImmutableOpenMap<String, ImmutableOpenMap<String, MappingMetadata>> mappings = mappings();
MappingMetadata mapping = mappings.get("fakes").get("fake");
assertThat(countMappingFields(mapping)).isEqualTo(3);
assertThat(field(mapping, "updatedAt")).containsEntry("type", "date");
assertThat(field(mapping, "newField")).containsEntry("type", "integer");
assertThat(es.client().get(new GetRequest(fakeIndexType.getIndex().getName(), fakeIndexType.getType(), id)).isExists()).isFalse();
}
Aggregations