MutationFactory { public List<Put> insert(long tableId, final Row row) { return insert(tableId, row, store.getSchema(tableId).getIndices()); } @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 testInsertRejectsInvalidTableId() throws Exception { factory.insert(-1, row); }
@Test(expected = TableNotFoundException.class) public void testInsertRejectsUnknownTableId() throws Exception { factory.insert(99, row); }
@Test(expected = NullPointerException.class) public void testInsertRejectsNullRow() throws Exception { factory.insert(1, null); }
@Test public void testInsert() throws Exception { List<Put> puts = factory.insert(tableId, row); byte[] rowCounts = countRowTypes(puts); assertEquals("data row count", 1, rowCounts[DATA_PREFIX]); assertEquals("ascending index count", 2, rowCounts[ASC_PREFIX]); assertEquals("descending index count", 2, rowCounts[DESC_PREFIX]); assertEquals("row count", 5, puts.size()); }
@Test(expected = IllegalArgumentException.class) public void testPartialInsertRejectsInvalidTableId() throws Exception { factory.insert(-1, row, new ArrayList<IndexSchema>()); }
@Test(expected = TableNotFoundException.class) public void testPartialInsertRejectsUnknownTableId() throws Exception { factory.insert(99, row, ImmutableList.of(INDICES.get(0))); }
@Test(expected = NullPointerException.class) public void testPartialInsertRejectsNullRow() throws Exception { factory.insert(1, null, new ArrayList<IndexSchema>()); }
@Test public void testPartialInsert() throws Exception { List<Put> puts = factory.insert(tableId, row, ImmutableList.of(INDICES.get(0))); byte[] rowCounts = countRowTypes(puts); assertEquals("data row count", 1, rowCounts[DATA_PREFIX]); assertEquals("ascending index count", 1, rowCounts[ASC_PREFIX]); assertEquals("descending index count", 1, rowCounts[DESC_PREFIX]); assertEquals("row count", 3, puts.size()); }