@Test public void testPut() throws Exception { when(mockTable.put(any(ByteBuf.class), any(ByteBuf.class))) .thenReturn(FutureUtils.Void()); stateContext.put("test-key", ByteBuffer.wrap("test-value".getBytes(UTF_8))).get(); verify(mockTable, times(1)).put( eq(Unpooled.copiedBuffer("test-key", UTF_8)), eq(Unpooled.copiedBuffer("test-value", UTF_8)) ); }
@Override public CompletableFuture<Void> put(String key, ByteBuffer value) { if(value != null) { value.position(0); return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), Unpooled.wrappedBuffer(value)); } else { return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), null); } }
StateContextImpl implements StateContext { @Override public CompletableFuture<Void> put(String key, ByteBuffer value) { if(value != null) { value.position(0); return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), Unpooled.wrappedBuffer(value)); } else { return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), null); } } }
StateContextImpl implements StateContext { @Override public CompletableFuture<Void> put(String key, ByteBuffer value) { if(value != null) { value.position(0); return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), Unpooled.wrappedBuffer(value)); } else { return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), null); } } StateContextImpl(Table<ByteBuf, ByteBuf> table); }
StateContextImpl implements StateContext { @Override public CompletableFuture<Void> put(String key, ByteBuffer value) { if(value != null) { value.position(0); return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), Unpooled.wrappedBuffer(value)); } else { return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), null); } } StateContextImpl(Table<ByteBuf, ByteBuf> table); @Override CompletableFuture<Void> incrCounter(String key, long amount); @Override CompletableFuture<Void> put(String key, ByteBuffer value); @Override CompletableFuture<Void> delete(String key); @Override CompletableFuture<ByteBuffer> get(String key); @Override CompletableFuture<Long> getCounter(String key); }
StateContextImpl implements StateContext { @Override public CompletableFuture<Void> put(String key, ByteBuffer value) { if(value != null) { value.position(0); return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), Unpooled.wrappedBuffer(value)); } else { return table.put( Unpooled.wrappedBuffer(key.getBytes(UTF_8)), null); } } StateContextImpl(Table<ByteBuf, ByteBuf> table); @Override CompletableFuture<Void> incrCounter(String key, long amount); @Override CompletableFuture<Void> put(String key, ByteBuffer value); @Override CompletableFuture<Void> delete(String key); @Override CompletableFuture<ByteBuffer> get(String key); @Override CompletableFuture<Long> getCounter(String key);  }