@Override
  public TypeMapping createTypeMapping(IndexMainType mainType) {
    checkState(this.mainType == null, "Main type can only be defined once");
    this.mainType = mainType;
    return super.createTypeMapping(mainType);
  }
@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");
  }