For IntelliJ IDEA and
Android Studio


private void myMethod () {CounterConfiguration$Builder c =
CounterType type;CounterConfiguration.builder(type)
- AI code suggestions by Codota
}
@Override protected List<CounterConfiguration> configurationToTest() { return Arrays.asList( CounterConfiguration.builder(CounterType.WEAK).initialValue(10).concurrencyLevel(10).build(), CounterConfiguration.builder(CounterType.WEAK).initialValue(20).concurrencyLevel(20).build(), CounterConfiguration.builder(CounterType.WEAK).build() ); }
private void setStorage(byte flags) { Storage storage = decodeStorage(flags); builder.storage(storage); logDecoded("storage", storage); }
private void doCreationTest(String name, CounterConfiguration config) { List<CounterManager> remoteCounterManagers = allRemoteCounterManagerSupplier.get(); assertTrue(remoteCounterManagers.get(0).defineCounter(name, config)); remoteCounterManagers.forEach(cm -> assertFalse(cm.defineCounter(name, builder(CounterType.WEAK).build()))); remoteCounterManagers.forEach(cm -> assertTrue(cm.isDefined(name))); remoteCounterManagers.forEach(cm -> assertEquals(config, cm.getConfiguration(name))); //test single embedded counter manager to check if everything is correctly stored EmbeddedCacheManager cacheManager = cacheManagerSupplier.get(); CounterManager counterManager = EmbeddedCounterManagerFactory.asCounterManager(cacheManager); assertTrue(counterManager.isDefined(name)); assertEquals(config, counterManager.getConfiguration(name)); }
public void testRemove() { checkRemove("A", builder(CounterType.WEAK).initialValue(10).build(), 121, 20, s -> addToWeakCounter(s, 111), s -> addToWeakCounter(s, 10), this::getWeakCounterValue); checkRemove("B", builder(CounterType.UNBOUNDED_STRONG).initialValue(-10).build(), -11, -9, s -> addToStrongCounter(s, -1, false), s -> addToStrongCounter(s, 1, false), this::getStrongCounterValue); }
@Override protected TestCounter createCounter(CounterManager counterManager, String counterName) { counterManager.defineCounter(counterName, CounterConfiguration.builder(CounterType.UNBOUNDED_STRONG).build()); return new StrongTestCounter(counterManager.getStrongCounter(counterName)); } }
@Override public void testUpperBoundedStrongCounter(Method method) { final Random random = generateRandom(); final String counterName = method.getName(); CounterConfiguration config = builder(CounterType.BOUNDED_STRONG) .initialValue(5) .upperBound(15) .storage(random.nextBoolean() ? Storage.VOLATILE : Storage.PERSISTENT) .build(); doCreationTest(counterName, config); }
private void setUpperBound(long value) { builder.upperBound(value); decodeState = DecodeState.DECODE_INITIAL_VALUE; logDecoded("upper-bound", value); }
public void testGetConfiguration() { assertConfiguration("A", createWeakCounterProperties(), builder(CounterType.WEAK).initialValue(10).concurrencyLevel(1).build()); assertConfiguration("B", createUnboundedCounterProperties(), builder(CounterType.UNBOUNDED_STRONG).initialValue(5).build()); assertConfiguration("C", createBoundedCounterProperties(), builder(CounterType.BOUNDED_STRONG).initialValue(5).lowerBound(0).upperBound(10).build()); }
@Override protected StrongTestCounter createCounter(CounterManager counterManager, String counterName, long initialValue) { counterManager.defineCounter(counterName, CounterConfiguration.builder(CounterType.UNBOUNDED_STRONG).initialValue(initialValue).build()); return new StrongTestCounter(counterManager.getStrongCounter(counterName)); }
public void testGetValueAndReset() throws Exception { checkValueAndReset("A", builder(CounterType.WEAK).initialValue(10).build(), 20, s -> addToWeakCounter(s, 10), this::resetWeakCounter); checkValueAndReset("B", builder(CounterType.UNBOUNDED_STRONG).initialValue(-10).build(), 5, s -> addToStrongCounter(s, 15, false), this::resetStrongCounter); checkValueAndReset("C", builder(CounterType.BOUNDED_STRONG).initialValue(1).lowerBound(0).upperBound(2).build(), 2, s -> addToStrongCounter(s, 3, true), this::resetStrongCounter); }
@Override protected WeakTestCounter createCounter(CounterManager counterManager, String counterName, long initialValue) { counterManager.defineCounter(counterName, CounterConfiguration.builder(CounterType.WEAK).initialValue(initialValue).concurrencyLevel(4).build()); return new WeakTestCounter(counterManager.getWeakCounter(counterName)); } }
@Override List<CounterConfiguration> configurationsToTest() { return asList( builder(UNBOUNDED_STRONG).initialValue(5).build(), builder(BOUNDED_STRONG).initialValue(0).lowerBound(-1).upperBound(1).build() ); }
private static WeakCounterImpl getCounter(EmbeddedCacheManager manager, String counterName) { CounterManager counterManager = asCounterManager(manager); counterManager .defineCounter(counterName, CounterConfiguration.builder(CounterType.WEAK).concurrencyLevel(128).build()); return (WeakCounterImpl) counterManager.getWeakCounter(counterName); }
@Override public void testUnboundedStrongCounter(Method method) { final Random random = generateRandom(); final String counterName = method.getName(); CounterConfiguration config = builder(CounterType.UNBOUNDED_STRONG) .initialValue(random.nextInt()) .storage(random.nextBoolean() ? Storage.VOLATILE : Storage.PERSISTENT) .build(); doCreationTest(counterName, config); }
@Override void define(CounterManager manager, String name) { manager.defineCounter(name, builder(CounterType.BOUNDED_STRONG).initialValue(10).lowerBound(0).upperBound(20).build()); }