use of org.infinispan.util.function.SerializableBiFunction in project infinispan by infinispan.
the class BaseClusteredExtendedStatisticTest method testComputeIfPresent.
public void testComputeIfPresent(Method method) throws InterruptedException {
final String key1 = k(method, 1);
final String key2 = k(method, 2);
assertEmpty(key1);
assertEmpty(key2);
put(1, key1, VALUE_1);
assertCacheValue(key1, VALUE_1);
SerializableBiFunction computeFunction = (k, v) -> VALUE_2 + k + v;
computeIfPresent(0, key1, computeFunction);
assertCacheValue(key1, VALUE_2 + key1 + VALUE_1);
// failed operation is not added to the transaction
cache(1).computeIfPresent(key2, computeFunction);
assertEmpty(key2);
assertNoTransactions();
assertNoTxStats();
}
use of org.infinispan.util.function.SerializableBiFunction in project infinispan by infinispan.
the class BaseClusteredExtendedStatisticTest method testCompute.
public void testCompute(Method method) throws InterruptedException {
final String key1 = k(method, 1);
final String key2 = k(method, 2);
assertEmpty(key1);
put(1, key1, VALUE_1);
assertCacheValue(key1, VALUE_1);
SerializableBiFunction computeFunction = (k, v) -> VALUE_2 + k + v;
compute(0, key1, computeFunction);
assertCacheValue(key1, VALUE_2 + key1 + VALUE_1);
compute(1, key2, computeFunction);
assertCacheValue(key2, VALUE_2 + key2 + "null");
SerializableBiFunction computeFunctionToNull = (k, v) -> null;
compute(0, key1, computeFunctionToNull);
assertEmpty(key1);
assertNoTransactions();
assertNoTxStats();
}
Aggregations