assertEquals("index1", indexer.getName());
}
@Test
public void testFull() {
IndexerDefinition indexer = new IndexerDefinitionBuilder()
.name("index1")
.lifecycleState(LifecycleState.DELETE_REQUESTED)
.batchIndexingState(BatchIndexingState.BUILDING)
.incrementalIndexingState(IncrementalIndexingState.SUBSCRIBE_DO_NOT_CONSUME)
.indexerComponentFactory("testReader")
.configuration("config1".getBytes(Charsets.UTF_8))
.connectionType("solr")
.connectionParams(ImmutableMap.of("p1", "v1", "p2", "v2"))
.subscriptionId("my-subscription")
.subscriptionTimestamp(5L)
.defaultBatchIndexCliArguments(new String[]{"arg1", "arg2"})
.batchIndexCliArguments(new String[]{"arg3"})
.activeBatchBuildInfo(
new BatchBuildInfo(10L, null, ImmutableMap.of("job-id-1", "url-1"), new String[]{"arg1", "arg2"}))
.lastBatchBuildInfo(
new BatchBuildInfo(11L, false, ImmutableMap.of("job-id-2", "url-2"), new String[]{"arg3"}))
.occVersion(5).build();
IndexerDefinitionJsonSerDeser serdeser = new IndexerDefinitionJsonSerDeser();
byte[] json = serdeser.toJsonBytes(indexer);
IndexerDefinition indexer2 = serdeser.fromJsonBytes(json).build();
assertEquals("index1", indexer2.getName());
assertEquals(LifecycleState.DELETE_REQUESTED, indexer2.getLifecycleState());
assertEquals(BatchIndexingState.BUILDING, indexer2.getBatchIndexingState());
assertEquals(IncrementalIndexingState.SUBSCRIBE_DO_NOT_CONSUME, indexer2.getIncrementalIndexingState());
assertEquals("testReader", indexer2.getIndexerComponentFactory());
assertArrayEquals("config1".getBytes(Charsets.UTF_8), indexer2.getConfiguration());
assertEquals("solr", indexer.getConnectionType());
assertEquals("v1", indexer.getConnectionParams().get("p1"));
assertEquals("v2", indexer.getConnectionParams().get("p2"));
assertEquals("my-subscription", indexer2.getSubscriptionId());
assertEquals(5L, indexer2.getSubscriptionTimestamp());
assertArrayEquals(new String[]{"arg1", "arg2"}, indexer2.getDefaultBatchIndexCliArguments());
assertArrayEquals(new String[]{"arg3"}, indexer2.getBatchIndexCliArguments());
assertNotNull(indexer2.getActiveBatchBuildInfo());
assertEquals(10L, indexer2.getActiveBatchBuildInfo().getSubmitTime());
assertEquals(ImmutableMap.of("job-id-1", "url-1"), indexer2.getActiveBatchBuildInfo().getMapReduceJobTrackingUrls());
assertNull(indexer2.getActiveBatchBuildInfo().isFinishedSuccessful());
assertArrayEquals(new String[]{"arg1", "arg2"}, indexer2.getActiveBatchBuildInfo().getBatchIndexCliArguments());
assertNotNull(indexer2.getLastBatchBuildInfo());
assertEquals(11L, indexer2.getLastBatchBuildInfo().getSubmitTime());
assertEquals(ImmutableMap.of("job-id-2", "url-2"), indexer2.getLastBatchBuildInfo().getMapReduceJobTrackingUrls());
assertFalse(indexer2.getLastBatchBuildInfo().isFinishedSuccessful());
assertArrayEquals(new String[]{"arg3"}, indexer2.getLastBatchBuildInfo().getBatchIndexCliArguments());
assertEquals(5, indexer2.getOccVersion());
assertEquals(indexer, indexer2);
}