MutationFactory { public List<Delete> deleteIndices(long tableId, final Row row) { Verify.isValidId(tableId); final Collection<IndexSchema> indices = store.getSchema(tableId).getIndices(); return deleteIndices(tableId, row, indices); } @Inject  MutationFactory(HBaseStore store); @Inject void setColumnFamily(final @Named(ConfigConstants.COLUMN_FAMILY) String columnFamily); List<Put> insert(long tableId, final Row row); List<Put> insert(long tableId, final Row row,
                            final Collection<IndexSchema> indices); List<Put> insertIndices(long tableId, final Row row,
                                   final Collection<IndexSchema> indices); List<Delete> delete(long tableId, final Row row); List<Delete> deleteIndices(long tableId, final Row row); List<Delete> deleteIndices(long tableId, final Row row,
                                      final Collection<IndexSchema> indices);  }
@Test(expected = IllegalArgumentException.class) public void testDeleteIndicesRejectsInvalidTableId() throws Exception { factory.deleteIndices(-1, row); }
@Test(expected = TableNotFoundException.class) public void testDeleteIndicesRejectsUnknownTableId() throws Exception { factory.deleteIndices(99, row); }
@Test(expected = NullPointerException.class) public void testDeleteIndicesRejectsNullRow() throws Exception { factory.deleteIndices(1, null); }
@Test public void testDeleteIndices() throws Exception { List<Delete> deletes = factory.deleteIndices(tableId, row); byte[] rowCounts = countRowTypes(deletes); assertEquals("ascending index count", 2, rowCounts[ASC_PREFIX]); assertEquals("descending index count", 2, rowCounts[DESC_PREFIX]); assertEquals("row count", 4, deletes.size()); }
@Test(expected = IllegalArgumentException.class) public void testPartialDeleteIndicesRejectsInvalidTableId() throws Exception { factory.deleteIndices(-1, row, new ArrayList<IndexSchema>()); }
@Test(expected = TableNotFoundException.class) public void testPartialDeleteIndicesRejectsUnknownTableId() throws Exception { factory.deleteIndices(99, row, ImmutableList.of(INDICES.get(0))); }
@Test(expected = NullPointerException.class) public void testPartialDeleteIndicesRejectsNullRow() throws Exception { factory.deleteIndices(1, null, new ArrayList<IndexSchema>()); }
@Test public void testPartialDeleteIndices() throws Exception { List<Delete> deletes = factory.deleteIndices(tableId, row, ImmutableList.of(INDICES.get(0))); byte[] rowCounts = countRowTypes(deletes); assertEquals("ascending index count", 1, rowCounts[ASC_PREFIX]); assertEquals("descending index count", 1, rowCounts[DESC_PREFIX]); assertEquals("row count", 2, deletes.size()); }