### Question:
DynamoSchema { public DynamoIndex getTableIndex() { return getIndexes().stream() .filter(index -> index.getIndexType().equals(IndexType.TABLE)) .findFirst().orElseThrow(() -> new IllegalStateException("expected there to always be a table 'index'")); }  TypeElement getDocumentElement(); DynamoIndex getTableIndex(); Set<DynamoIndex> getLocalSecondaryIndexes(); boolean hasLocalSecondaryIndexes(); Set<DynamoIndex> getGlobalSecondaryIndexes(); boolean hasGlobalSecondaryIndexes();  }### Answer:
@Test void getTableIndex_noIndexes_throwsIllegalStageException() { assertThatThrownBy(() -> schema().build().getTableIndex()).isInstanceOf(IllegalStateException.class); }
@Test void getTableIndex_noTableIndex_throwsIllegalStageException() { assertThatThrownBy(() -> schema() .indexes(singleton(index().indexType(IndexType.LOCAL_SECONDARY_INDEX).build())) .build().getTableIndex()).isInstanceOf(IllegalStateException.class); }
@Test void getTableIndex_tableExists_returnsTable() { DynamoIndex table = index().build(); DynamoSchema schema = schema() .indexes(singleton(table)) .build(); assertThat(schema.getTableIndex()).isEqualTo(table); }