GenericIndexer implements Indexer { @Override public void checkId(Index.Key key) throws IOException { if (WorkspaceFamily.UTIL_CAL.equals(key.getFamily())) { if (!key.getId().equals("Calendars")) { throw new IOException("Only one calendar file is allowed"); } } } GenericIndexer(Path file, Path rootFolder); @Override void checkId(Index.Key key); @Override Index loadIndex(); @Override void storeIndex(Index index); @Override void close();  }
@Test public void testUniqueItems() throws IOException { Path sampleFile = newGenericSample(); try (Indexer indexer = new GenericIndexer(sampleFile, FileWorkspaceImpl.getRootFolder(sampleFile))) { assertThatThrownBy(() -> indexer.checkId(new Index.Key(UTIL_CAL, "Calendars2"))).isInstanceOf(IOException.class); } }