@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_IAE_if_mainType_does_not_match_defined_one() {
    Index index = Index.withRelations(SOME_INDEX_NAME);
    IndexType.IndexMainType mainType = IndexType.main(index, "foo");
    NewRegularIndex underTest = new NewRegularIndex(index, defaultSettingsConfiguration);
    underTest.createTypeMapping(mainType);

    assertThatThrownBy(() -> underTest.createTypeMapping(IndexType.relation(IndexType.main(index, "donut"), "bar")))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("main type of relation must be "+ mainType);
  }