@Test
    void addUpdateDeleteFields() {
        List<IndexField> fields = getFields(DOC_REF_1);
        assertThat(fields.size())
                .isEqualTo(0);

        indexFieldDao.addField(new AddField(DOC_REF_1, FIELD_1));
        assertThat(indexFieldDao.getFieldCount(DOC_REF_1)).isEqualTo(1);
        assertThatThrownBy(() -> indexFieldDao.addField(new AddField(DOC_REF_1, FIELD_1)))
                .isInstanceOf(RuntimeException.class);
        assertThat(indexFieldDao.getFieldCount(DOC_REF_1)).isEqualTo(1);
        indexFieldDao.addField(new AddField(DOC_REF_1, FIELD_2));
        assertThat(indexFieldDao.getFieldCount(DOC_REF_1)).isEqualTo(2);
        indexFieldDao.updateField(new UpdateField(DOC_REF_1, FIELD_1.getFldName(), FIELD_3));
        assertThat(indexFieldDao.getFieldCount(DOC_REF_1)).isEqualTo(2);
        assertThatThrownBy(() -> indexFieldDao.updateField(new UpdateField(DOC_REF_1, FIELD_3.getFldName(), FIELD_2)))
                .isInstanceOf(RuntimeException.class);
        assertThat(indexFieldDao.getFieldCount(DOC_REF_1)).isEqualTo(2);
        indexFieldDao.deleteField(new DeleteField(DOC_REF_1, FIELD_3.getFldName()));
        assertThat(indexFieldDao.getFieldCount(DOC_REF_1)).isEqualTo(1);
        indexFieldDao.deleteField(new DeleteField(DOC_REF_1, FIELD_1.getFldName()));
        assertThat(indexFieldDao.getFieldCount(DOC_REF_1)).isEqualTo(1);
    }
Make sure multiple threads can concurrently add different lists of fields
stroom-index/stroom-index-impl-db/src/test/java/stroom/index/impl/db/TestIndexFieldDaoImpl.java