### Question:
HBase_1_1_2_ClientMapCacheService extends AbstractControllerService implements DistributedMapCacheClient { @Override public <K, V> V getAndPutIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer, final Deserializer<V> valueDeserializer) throws IOException { final V got = get(key, keySerializer, valueDeserializer); final boolean wasAbsent = putIfAbsent(key, value, keySerializer, valueSerializer); if (! wasAbsent) return got; else return null; }  @OnEnabled void onConfigured(final ConfigurationContext context); @Override boolean putIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer); @Override void put(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer); @Override boolean containsKey(final K key, final Serializer<K> keySerializer); @Override V getAndPutIfAbsent(final K key, final V value, final Serializer<K> keySerializer, final Serializer<V> valueSerializer, final Deserializer<V> valueDeserializer); @Override V get(final K key, final Serializer<K> keySerializer, final Deserializer<V> valueDeserializer); @Override boolean remove(final K key, final Serializer<K> keySerializer); @Override long removeByPattern(String regex); @Override void close(); static final PropertyDescriptor HBASE_CACHE_TABLE_NAME; static final PropertyDescriptor HBASE_COLUMN_FAMILY; static final PropertyDescriptor HBASE_COLUMN_QUALIFIER; }### Answer:
@Test public void testGetAndPutIfAbsent() throws InitializationException, IOException { final String row = "row1"; final String content = "content1"; final TestRunner runner = TestRunners.newTestRunner(TestProcessor.class); final Table table = Mockito.mock(Table.class); when(table.getName()).thenReturn(TableName.valueOf(tableName)); final MockHBaseClientService service = configureHBaseClientService(runner, table); runner.assertValid(service); final HBaseClientService hBaseClientService = runner.getProcessContext().getProperty(TestProcessor.HBASE_CLIENT_SERVICE) .asControllerService(HBaseClientService.class); final DistributedMapCacheClient cacheService = configureHBaseCacheService(runner, hBaseClientService); runner.assertValid(cacheService); final DistributedMapCacheClient hBaseCacheService = runner.getProcessContext().getProperty(TestProcessor.HBASE_CACHE_SERVICE) .asControllerService(DistributedMapCacheClient.class); assertNull( hBaseCacheService.getAndPutIfAbsent( row, content, stringSerializer, stringSerializer, stringDeserializer)); ArgumentCaptor<Put> capture = ArgumentCaptor.forClass(Put.class); verify(table, times(1)).put(capture.capture()); verifyPut(row, columnFamily, columnQualifier, content, capture.getValue()); final String result = hBaseCacheService.getAndPutIfAbsent( row, content, stringSerializer, stringSerializer, stringDeserializer); verify(table, times(1)).put(capture.capture()); assertEquals( result, content); }