WriteableIndexerModel model1 = null;
WriteableIndexerModel model2 = null;
try {
TestListener listener = new TestListener();
model1 = new IndexerModelImpl(zk1, "/test");
model1.registerListener(listener);
// Create an indexer -- verify INDEXER_ADDED event
IndexerDefinition indexer1 = new IndexerDefinitionBuilder()
.name("indexer1")
.configuration("my-conf".getBytes("UTF-8"))
.build();
model1.addIndexer(indexer1);
listener.waitForEvents(1);
listener.verifyEvents(new IndexerModelEvent(IndexerModelEventType.INDEXER_ADDED, "indexer1"));
// Verify that a fresh indexer model has the index
model2 = new IndexerModelImpl(zk2, "/test");
Collection<IndexerDefinition> indexers = model2.getIndexers();
assertEquals("Expected indexer1, got " + indexers, 1, indexers.size());
assertTrue(model2.hasIndexer("indexer1"));
// Update the indexer -- verify INDEXER_UPDATED event