### Question:
RowAndFamilyAddingSolrUpdateWriter implements SolrUpdateWriter { @Override public void add(SolrInputDocument solrDocument) { if (rowField != null) { solrDocument.addField(rowField, uniqueKeyFormatter.formatRow(CellUtil.cloneRow(keyValue))); } if (columnFamilyField != null) { solrDocument.addField(columnFamilyField, uniqueKeyFormatter.formatFamily(CellUtil.cloneFamily(keyValue))); } delegateUpdateWriter.add(solrDocument); } RowAndFamilyAddingSolrUpdateWriter(String rowField, String columnFamilyField,
            UniqueKeyFormatter uniqueKeyFormatter,
            KeyValue keyValue,SolrUpdateWriter delegateUpdateWriter); @Override void add(SolrInputDocument solrDocument); @Override void deleteById(String documentId); @Override void deleteByQuery(String query);  }### Answer:
@Test public void testAdd_NoFields() { RowAndFamilyAddingSolrUpdateWriter updateWriter = new RowAndFamilyAddingSolrUpdateWriter(null, null, uniqueKeyFormatter, keyValue, delegateWriter); updateWriter.add(solrDocument); verify(solrDocument, never()).addField(anyString(), any()); verify(delegateWriter).add(solrDocument); }
@Test public void testAdd_ColumnField() { RowAndFamilyAddingSolrUpdateWriter updateWriter = new RowAndFamilyAddingSolrUpdateWriter(null, "_col_", uniqueKeyFormatter, keyValue, delegateWriter); doReturn(new byte[0]).when(keyValue).getFamilyArray(); doReturn("_famname_").when(uniqueKeyFormatter).formatFamily(any(byte[].class)); updateWriter.add(solrDocument); verify(solrDocument).addField("_col_", "_famname_"); verify(delegateWriter).add(solrDocument); }
@Test public void testAdd_RowField() { RowAndFamilyAddingSolrUpdateWriter updateWriter = new RowAndFamilyAddingSolrUpdateWriter("_row_", null, uniqueKeyFormatter, keyValue, delegateWriter); byte[] rowBytes = Bytes.toBytes("_row_"); doReturn(rowBytes).when(keyValue).getRowArray(); doReturn("_rowkey_").when(uniqueKeyFormatter).formatRow(any(byte[].class)); updateWriter.add(solrDocument); verify(solrDocument).addField("_row_", "_rowkey_"); verify(delegateWriter).add(solrDocument); }