@Test
public void testWithWriteOnlyIndexes() {

    final String implicitlyReadable = "Implicitly readable";
    final String explicitlyReadable = "Explicitly readable";
    final String disabled = "Disabled";
    final String writeOnly = "Write only";
    final String newWriteOnly = "New write only";
    RecordStoreState state = stateOf(
            explicitlyReadable, IndexState.READABLE,
            disabled, IndexState.DISABLED,
            writeOnly, IndexState.WRITE_ONLY);
    assertEquals(IndexState.READABLE, state.getState(implicitlyReadable));
    assertEquals(IndexState.READABLE, state.getState(explicitlyReadable));
    assertEquals(IndexState.DISABLED, state.getState(disabled));
    assertEquals(IndexState.WRITE_ONLY, state.getState(writeOnly));
    RecordStoreState newState = state.withWriteOnlyIndexes(
            Arrays.asList(implicitlyReadable, explicitlyReadable, disabled, writeOnly));
    assertEquals(IndexState.WRITE_ONLY, newState.getState(implicitlyReadable));
    assertEquals(IndexState.WRITE_ONLY, newState.getState(explicitlyReadable));
    assertEquals(IndexState.DISABLED, newState.getState(disabled));
    assertEquals(IndexState.WRITE_ONLY, newState.getState(writeOnly));
    assertEquals(IndexState.READABLE, newState.getState("other implicitly readable"));
    // no changes to original
    assertEquals(IndexState.READABLE, state.getState(implicitlyReadable));
    assertEquals(IndexState.READABLE, state.getState(explicitlyReadable));
    assertEquals(IndexState.DISABLED, state.getState(disabled));
    assertEquals(IndexState.WRITE_ONLY, state.getState(writeOnly));
    RecordStoreState newState2 = state.withWriteOnlyIndexes(Collections.singletonList(newWriteOnly));
    assertEquals(IndexState.READABLE, newState2.getState(implicitlyReadable));
    assertEquals(IndexState.READABLE, newState2.getState(explicitlyReadable));
    assertEquals(IndexState.DISABLED, newState2.getState(disabled));
    assertEquals(IndexState.WRITE_ONLY, newState2.getState(writeOnly));
    assertEquals(IndexState.WRITE_ONLY, newState2.getState(newWriteOnly));
}