Format source code.
Edit Javadoc.
This commit is contained in:
@@ -13,7 +13,6 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.tests.integration;
|
||||
|
||||
import java.util.Optional;
|
||||
@@ -46,7 +45,9 @@ public abstract class SpringApplicationContextIntegrationTestsSupport extends In
|
||||
|
||||
@After
|
||||
public void closeApplicationContext() {
|
||||
Optional.ofNullable(this.applicationContext).ifPresent(ConfigurableApplicationContext::close);
|
||||
|
||||
Optional.ofNullable(this.applicationContext)
|
||||
.ifPresent(ConfigurableApplicationContext::close);
|
||||
}
|
||||
|
||||
protected ConfigurableApplicationContext newApplicationContext(Class<?>... annotatedClasses) {
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.tests.mock;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
@@ -66,9 +65,6 @@ import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.stubbing.Answer;
|
||||
|
||||
import org.apache.geode.cache.AttributesMutator;
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.CacheFactory;
|
||||
@@ -133,6 +129,8 @@ import org.apache.geode.distributed.DistributedMember;
|
||||
import org.apache.geode.distributed.DistributedSystem;
|
||||
import org.apache.geode.pdx.PdxSerializer;
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.mockito.ArgumentMatchers;
|
||||
import org.mockito.stubbing.Answer;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.data.gemfire.IndexType;
|
||||
import org.springframework.data.gemfire.server.SubscriptionEvictionPolicy;
|
||||
@@ -150,24 +148,30 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.io.File
|
||||
* @see java.net.InetAddress
|
||||
* @see java.net.InetSocketAddress
|
||||
* @see java.util.Properties
|
||||
* @see java.util.UUID
|
||||
* @see org.apache.geode.cache.AttributesMutator
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.CacheFactory
|
||||
* @see org.apache.geode.cache.CacheListener
|
||||
* @see org.apache.geode.cache.CacheLoader
|
||||
* @see org.apache.geode.cache.CacheWriter
|
||||
* @see org.apache.geode.cache.CustomExpiry
|
||||
* @see org.apache.geode.cache.DiskStore
|
||||
* @see org.apache.geode.cache.DiskStoreFactory
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.EvictionAttributes
|
||||
* @see org.apache.geode.cache.EvictionAttributesMutator
|
||||
* @see org.apache.geode.cache.ExpirationAttributes
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.PartitionAttributes
|
||||
* @see org.apache.geode.cache.Region
|
||||
* @see org.apache.geode.cache.RegionAttributes
|
||||
* @see org.apache.geode.cache.RegionFactory
|
||||
* @see org.apache.geode.cache.RegionService
|
||||
* @see org.apache.geode.cache.Scope
|
||||
* @see org.apache.geode.cache.asyncqueue.AsyncEventListener
|
||||
* @see org.apache.geode.cache.asyncqueue.AsyncEventQueue
|
||||
* @see org.apache.geode.cache.asyncqueue.AsyncEventQueueFactory
|
||||
* @see org.apache.geode.cache.client.ClientCache
|
||||
@@ -176,6 +180,7 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.apache.geode.cache.client.Pool
|
||||
* @see org.apache.geode.cache.client.PoolFactory
|
||||
* @see org.apache.geode.cache.control.ResourceManager
|
||||
* @see org.apache.geode.cache.execute.RegionFunctionContext
|
||||
* @see org.apache.geode.cache.lucene.LuceneIndex
|
||||
* @see org.apache.geode.cache.lucene.LuceneIndexFactory
|
||||
* @see org.apache.geode.cache.lucene.LuceneQuery
|
||||
@@ -192,10 +197,15 @@ import org.springframework.util.StringUtils;
|
||||
* @see org.apache.geode.cache.query.QueryStatistics
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.apache.geode.cache.server.ClientSubscriptionConfig
|
||||
* @see org.apache.geode.cache.server.ServerLoadProbe
|
||||
* @see org.apache.geode.cache.wan.GatewayEventFilter
|
||||
* @see org.apache.geode.cache.wan.GatewayEventSubstitutionFilter
|
||||
* @see org.apache.geode.cache.wan.GatewayReceiver
|
||||
* @see org.apache.geode.cache.wan.GatewayReceiverFactory
|
||||
* @see org.apache.geode.cache.wan.GatewaySender
|
||||
* @see org.apache.geode.cache.wan.GatewaySenderFactory
|
||||
* @see org.apache.geode.cache.wan.GatewayTransportFilter
|
||||
* @see org.apache.geode.compression.Compressor
|
||||
* @see org.apache.geode.distributed.DistributedMember
|
||||
* @see org.apache.geode.distributed.DistributedSystem
|
||||
* @see org.apache.geode.pdx.PdxSerializer
|
||||
@@ -271,7 +281,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
* @param gemfireObject {@link Object GemFire object} to cache.
|
||||
*/
|
||||
private static void cacheGemFireObject(Object gemfireObject) {
|
||||
Optional.ofNullable(gemfireObject).ifPresent(cachedGemFireObjects::add);
|
||||
|
||||
Optional.ofNullable(gemfireObject).
|
||||
ifPresent(cachedGemFireObjects::add);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -478,7 +490,8 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <K, V> Region<K, V> rememberMockedRegion(Region<K, V> mockRegion) {
|
||||
|
||||
String mockRegionPath = Optional.ofNullable(mockRegion).map(Region::getFullPath)
|
||||
String mockRegionPath = Optional.ofNullable(mockRegion)
|
||||
.map(Region::getFullPath)
|
||||
.orElseThrow(() -> newIllegalArgumentException("Region is required"));
|
||||
|
||||
if (regions.putIfAbsent(mockRegionPath, (Region) mockRegion) != null) {
|
||||
@@ -500,7 +513,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <T extends GemFireCache> Optional<T> resolveMockedGemFireCache(boolean useSingletonCache) {
|
||||
return Optional.ofNullable((T) singletonCache.get()).filter(it -> useSingletonCache);
|
||||
|
||||
return Optional.ofNullable((T) singletonCache.get())
|
||||
.filter(it -> useSingletonCache);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -516,8 +531,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
@SuppressWarnings("unchecked")
|
||||
private static <K, V> RegionAttributes<K, V> resolveRegionAttributes(String regionAttributesId) {
|
||||
|
||||
return (RegionAttributes<K, V>) Optional.ofNullable(regionAttributes.get(regionAttributesId)).orElseThrow(() ->
|
||||
newIllegalStateException("RegionAttributes with ID [%s] cannot be found", regionAttributesId));
|
||||
return (RegionAttributes<K, V>) Optional.ofNullable(regionAttributes.get(regionAttributesId))
|
||||
.orElseThrow(() -> newIllegalStateException("RegionAttributes with ID [%s] cannot be found",
|
||||
regionAttributesId));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -534,7 +550,9 @@ public abstract class GemFireMockObjectsSupport extends MockObjectsSupport {
|
||||
return Optional.ofNullable(regionName)
|
||||
.map(String::trim)
|
||||
.map(it -> {
|
||||
|
||||
int lastIndexOfRegionSeparator = it.lastIndexOf(Region.SEPARATOR);
|
||||
|
||||
return lastIndexOfRegionSeparator < 0 ? it : it.substring(lastIndexOfRegionSeparator);
|
||||
})
|
||||
.filter(it -> !it.isEmpty())
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.tests.mock;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -90,6 +89,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <E, C extends Collection<E>, R> Answer<R> newAdder(C collection, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
collection.add(invocation.getArgument(0));
|
||||
return returnValue;
|
||||
@@ -97,6 +97,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <R> Answer<R> newSetter(AtomicBoolean argument, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(invocation.getArgument(0));
|
||||
return returnValue;
|
||||
@@ -104,6 +105,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <R> Answer<R> newSetter(AtomicBoolean argument, Boolean value, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(value);
|
||||
return returnValue;
|
||||
@@ -111,6 +113,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <R> Answer<R> newSetter(AtomicInteger argument, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(invocation.getArgument(0));
|
||||
return returnValue;
|
||||
@@ -118,6 +121,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <R> Answer<R> newSetter(AtomicInteger argument, Integer value, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(value);
|
||||
return returnValue;
|
||||
@@ -125,6 +129,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <R> Answer<R> newSetter(AtomicLong argument, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(invocation.getArgument(0));
|
||||
return returnValue;
|
||||
@@ -132,6 +137,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <R> Answer<R> newSetter(AtomicLong argument, Long value, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(value);
|
||||
return returnValue;
|
||||
@@ -139,6 +145,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <T, R> Answer<R> newSetter(AtomicReference<T> argument, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(invocation.getArgument(0));
|
||||
return returnValue;
|
||||
@@ -146,6 +153,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <T, R> Answer<R> newSetter(AtomicReference<T> argument, T value, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(value);
|
||||
return returnValue;
|
||||
@@ -153,6 +161,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <T, R> Answer<R> newSetter(AtomicReference<T> argument, Function<?, T> converter, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.set(converter.apply(invocation.getArgument(0)));
|
||||
return returnValue;
|
||||
@@ -160,6 +169,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <K, V, R> Answer<R> newSetter(Map<K, V> argument, R returnValue) {
|
||||
|
||||
return invocation -> {
|
||||
argument.put(invocation.getArgument(0), invocation.getArgument(1));
|
||||
return returnValue;
|
||||
@@ -167,6 +177,7 @@ public abstract class MockObjectsSupport {
|
||||
}
|
||||
|
||||
protected static <T> Answer<Void> newVoidAnswer(Consumer<InvocationOnMock> methodInvocation) {
|
||||
|
||||
return invocation -> {
|
||||
methodInvocation.accept(invocation);
|
||||
return null;
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.tests.mock.config;
|
||||
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -120,7 +119,9 @@ public class GemFireMockObjectsBeanPostProcessor implements BeanPostProcessor {
|
||||
implements CacheFactoryBean.CacheFactoryInitializer<CacheFactory> {
|
||||
|
||||
protected static CacheFactoryBean spyOn(CacheFactoryBean cacheFactoryBean, boolean useSingletonCache) {
|
||||
|
||||
cacheFactoryBean.setCacheFactoryInitializer(new SpyingCacheFactoryInitializer(useSingletonCache));
|
||||
|
||||
return cacheFactoryBean;
|
||||
}
|
||||
|
||||
@@ -146,8 +147,8 @@ public class GemFireMockObjectsBeanPostProcessor implements BeanPostProcessor {
|
||||
protected static ClientCacheFactoryBean spyOn(ClientCacheFactoryBean clientCacheFactoryBean,
|
||||
boolean useSingletonCache) {
|
||||
|
||||
clientCacheFactoryBean.setCacheFactoryInitializer(
|
||||
new SpyingClientCacheFactoryInitializer(useSingletonCache));
|
||||
clientCacheFactoryBean
|
||||
.setCacheFactoryInitializer(new SpyingClientCacheFactoryInitializer(useSingletonCache));
|
||||
|
||||
return clientCacheFactoryBean;
|
||||
}
|
||||
@@ -171,7 +172,9 @@ public class GemFireMockObjectsBeanPostProcessor implements BeanPostProcessor {
|
||||
protected static class MockingPoolFactoryInitializer implements PoolFactoryBean.PoolFactoryInitializer {
|
||||
|
||||
protected static PoolFactoryBean mock(PoolFactoryBean poolFactoryBean) {
|
||||
|
||||
poolFactoryBean.setPoolFactoryInitializer(new MockingPoolFactoryInitializer());
|
||||
|
||||
return poolFactoryBean;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,6 @@
|
||||
* or implied. See the License for the specific language governing
|
||||
* permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.gemfire.tests.mock.context;
|
||||
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
|
||||
Reference in New Issue
Block a user