@Test(expected = NullPointerException.class) public void testDeserializeNullSerializedSchema() { IndexSchema.deserialize(null, INDEX_A); }
/** * Add the provided index information to the table. The table must be open * before this operation can be performed. * * @param indexName The name of the index to add, not null or empty * @param serializedSchema The byte representation of the {@link IndexSchema} for this index, not null */ public void addIndex(String indexName, byte[] serializedSchema) { Verify.isNotNullOrEmpty(indexName, "The index name is invalid"); checkNotNull(serializedSchema, "Schema cannot be null"); checkTableOpen(); IndexSchema schema = IndexSchema.deserialize(serializedSchema, indexName); checkArgument(!schema.getIsUnique(), "Honeycomb does not support adding unique indices without a table rebuild."); store.addIndex(tableName, schema); table.insertTableIndex(schema); table.flush(); }
@Test(expected = NullPointerException.class) public void testDeserializeInvalidIndexName() { IndexSchema.deserialize(TEST_INDEX_SCHEMA.serialize(), null); }
@Test(expected = IllegalArgumentException.class) public void testDeserializeEmptyIndexName() { IndexSchema.deserialize(TEST_INDEX_SCHEMA.serialize(), ""); }
@Test public void testDeserializeValidSerializedSchemaAndIndexName() { final IndexSchema actualSchema = IndexSchema.deserialize(TEST_INDEX_SCHEMA.serialize(), TEST_INDEX_SCHEMA.getIndexName()); assertEquals(TEST_INDEX_SCHEMA.getIndexName(), actualSchema.getIndexName()); assertEquals(TEST_INDEX_SCHEMA, actualSchema); }