### Question:
ColumnFamilyTemplate extends AbstractColumnFamilyTemplate<K,N,V> implements ColumnFamilyOperations<K,N,V> { @Override public Map<N,V> readColumnsAsMap(K rowKey) { return readColumnsAsMap(rowKey, null, null, ALL, false); } ColumnFamilyTemplate(Keyspace keyspace,
                                Serializer<K> keySerializer,
                                Serializer<N> columnNameSerializer,
                                Serializer<V> valueSerializer);  ColumnFamilyTemplate(Keyspace keyspace,
                                @Nullable String defaultColumnFamily,
                                Serializer<K> keySerializer,
                                Serializer<N> columnNameSerializer,
                                Serializer<V> valueSerializer); @Override V readColumnValue(K rowKey, N columnName); @Override Map<N,V> readColumnsAsMap(K rowKey); @Override Map<N,V> readColumnsAsMap(K rowKey, N start, N finish, int count, boolean reversed); @Override List<T> readColumns(K rowKey, ColumnMapper <T,N,V> columnMapper); @Override List<T> readColumns(K rowKey,
                                   N start,
                                   N finish,
                                   int count,
                                   boolean reversed,
                                   ColumnMapper<T,N,V> columnMapper); @Override Map<K,Map<N,V>> multiGetAsMap(Iterable<K> rowKeys); @Override Map<K,Map<N,V>> multiGetColumnsAsMap(Iterable<K> rowKeys, N... columnNames); @Override Map<K,Map<N,V>> readRowsAsMap(); @Override List<T> multiGet(Iterable<K> rowKeys, ColumnFamilyRowMapper<T,K,N,V> rowMapper); @Override List<T> multiGetColumns(Iterable<K> rowKeys, ColumnFamilyRowMapper<T,K,N,V> rowMapper,
                                       N... columnNames); @Override void writeColumn(K rowKey, N columnName, V columnValue); @Override void writeColumn(K rowKey, N columnName, V columnValue, long timeToLive, TimeUnit timeToLiveTimeUnit); @Override void writeColumn(K rowKey, N columnName, V columnValue, @Nonnull BatchContext batchContext); @Override void writeColumn(K rowKey,
                            N columnName,
                            V columnValue,
                            int timeToLive,
                            TimeUnit timeToLiveTimeUnit,
                            @Nonnull BatchContext batchContext); @Override void writeColumns(K rowKey, Map<N,V> map); @Override void writeColumns(K rowKey, Map<N,V> map, @Nonnull BatchContext batchContext); @Override void deleteColumns(K rowKey, N... columnNames); @Override void deleteColumns(K rowKey, N start, N finish); @Override void deleteColumns(K rowKey, N start, N finish, @Nullable BatchContext batchContext);  }### Answer:
@Test(groups = {"unit"}) public void testReadColumnsAsMap() throws Exception { Map<String, String> testResultMap = new HashMap<String,String>(); testResultMap.put(columnNames.get(0), columnValues.get(0)); testResultMap.put(columnNames.get(1), columnValues.get(1)); ColumnSlice columnSlice = mock(ColumnSlice.class); HColumn column1 = mock(HColumn.class); HColumn column2 = mock(HColumn.class); when(column1.getName()).thenReturn(columnNames.get(0)); when(column1.getValue()).thenReturn(columnValues.get(0)); when(column2.getName()).thenReturn(columnNames.get(1)); when(column2.getValue()).thenReturn(columnValues.get(1)); when(columnSlice.getColumns()).thenReturn(Arrays.asList(column1, column2)); when(executionResult.get()).thenReturn(columnSlice); Map actualResult = columnFamilyTestDao.readColumnsAsMap(rowKey); assertEquals(actualResult, testResultMap); }
@Test(groups = {"unit"}, expectedExceptions = HectorTransportException.class) public void testReadColumnsAsMapTranslateHectorException() throws Exception { when(executionResult.get()).thenThrow(new HectorTransportException("test hector exception")); columnFamilyTestDao.readColumnsAsMap(rowKey); }