Polish.
This commit is contained in:
@@ -36,6 +36,7 @@ import org.springframework.geode.boot.actuate.health.AbstractGeodeHealthIndicato
|
||||
* and the {@link ResourceManager}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see java.net.URL
|
||||
* @see java.util.Optional
|
||||
* @see java.util.function.Function
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
|
||||
@@ -104,7 +104,7 @@ public class GeodeDiskStoresHealthIndicator extends AbstractGeodeHealthIndicator
|
||||
builder.withDetail(diskStoreKey(diskStoreName, "allow-force-compaction"), toYesNoString(diskStore.getAllowForceCompaction()))
|
||||
.withDetail(diskStoreKey(diskStoreName, "auto-compact"), toYesNoString(diskStore.getAutoCompact()))
|
||||
.withDetail(diskStoreKey(diskStoreName, "compaction-threshold"), diskStore.getCompactionThreshold())
|
||||
.withDetail(diskStoreKey(diskStoreName, "disk-directories"), toFilePathnamesString(diskStore.getDiskDirs()))
|
||||
.withDetail(diskStoreKey(diskStoreName, "disk-directories"), toFileAbsolutePathStrings(diskStore.getDiskDirs()))
|
||||
.withDetail(diskStoreKey(diskStoreName, "disk-directory-sizes"), Arrays.toString(nullSafeArray(diskStore.getDiskDirSizes())))
|
||||
.withDetail(diskStoreKey(diskStoreName, "disk-usage-critical-percentage"), diskStore.getDiskUsageCriticalPercentage())
|
||||
.withDetail(diskStoreKey(diskStoreName, "disk-usage-warning-percentage"), diskStore.getDiskUsageWarningPercentage())
|
||||
@@ -131,7 +131,7 @@ public class GeodeDiskStoresHealthIndicator extends AbstractGeodeHealthIndicator
|
||||
return array != null ? array : new int[0];
|
||||
}
|
||||
|
||||
private String toFilePathnamesString(File... files) {
|
||||
private String toFileAbsolutePathStrings(File... files) {
|
||||
|
||||
return Arrays.toString(Arrays.stream(ArrayUtils.nullSafeArray(files, File.class))
|
||||
.filter(Objects::nonNull)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.geode.boot.actuate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.when;
|
||||
@@ -26,7 +27,9 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.asyncqueue.AsyncEventQueue;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.wan.GatewaySender;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -48,6 +51,8 @@ import org.springframework.data.gemfire.tests.mock.AsyncEventQueueMockObjects;
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.asyncqueue.AsyncEventQueue
|
||||
* @see org.springframework.boot.actuate.health.Health
|
||||
* @see org.springframework.boot.actuate.health.HealthIndicator
|
||||
* @see org.springframework.data.gemfire.tests.mock.AsyncEventQueueMockObjects
|
||||
* @see org.springframework.geode.boot.actuate.GeodeAsyncEventQueuesHealthIndicator
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@@ -90,46 +95,46 @@ public class GeodeAsyncEventQueuesHealthIndicatorUnitTests {
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UP);
|
||||
|
||||
Map<String, Object> details = health.getDetails();
|
||||
Map<String, Object> healthDetails = health.getDetails();
|
||||
|
||||
assertThat(details).isNotNull();
|
||||
assertThat(details).isNotEmpty();
|
||||
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.batch-conflation-enabled", "Yes");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.batch-size", 250);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.batch-time-interval", 10000);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.disk-store-name", "testDiskStoreOne");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.disk-synchronous", "Yes");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.dispatcher-threads", 16);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.forward-expiration-destroy", "Yes");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.max-queue-memory", 65536);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.order-policy", GatewaySender.OrderPolicy.THREAD);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.parallel", "Yes");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.persistent", "Yes");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.primary", "Yes");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqOne.size", 1024);
|
||||
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.batch-conflation-enabled", "No");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.batch-size", 100);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.batch-time-interval", 1000);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.disk-store-name", "testDiskStoreTwo");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.disk-synchronous", "No");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.dispatcher-threads", 8);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.forward-expiration-destroy", "No");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.max-queue-memory", 32768);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.order-policy", GatewaySender.OrderPolicy.KEY);
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.parallel", "No");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.persistent", "Yes");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.primary", "No");
|
||||
assertThat(details).containsEntry("geode.async-event-queue.aeqTwo.size", 8192);
|
||||
assertThat(healthDetails).isNotNull();
|
||||
assertThat(healthDetails).isNotEmpty();
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.count", mockAsyncEventQueues.size());
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.batch-conflation-enabled", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.batch-size", 250);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.batch-time-interval", 10000);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.disk-store-name", "testDiskStoreOne");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.disk-synchronous", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.dispatcher-threads", 16);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.forward-expiration-destroy", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.max-queue-memory", 65536);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.order-policy", GatewaySender.OrderPolicy.THREAD);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.parallel", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.persistent", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.primary", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqOne.size", 1024);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.batch-conflation-enabled", "No");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.batch-size", 100);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.batch-time-interval", 1000);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.disk-store-name", "testDiskStoreTwo");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.disk-synchronous", "No");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.dispatcher-threads", 8);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.forward-expiration-destroy", "No");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.max-queue-memory", 32768);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.order-policy", GatewaySender.OrderPolicy.KEY);
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.parallel", "No");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.persistent", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.primary", "No");
|
||||
assertThat(healthDetails).containsEntry("geode.async-event-queue.aeqTwo.size", 8192);
|
||||
|
||||
verify(this.mockCache, times(1)).getAsyncEventQueues();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenNoGemFireCacheIsPresent() throws Exception {
|
||||
public void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception {
|
||||
|
||||
GeodeAsyncEventQueuesHealthIndicator healthIndicator = new GeodeAsyncEventQueuesHealthIndicator();
|
||||
GeodeAsyncEventQueuesHealthIndicator healthIndicator = gemfireCache != null
|
||||
? new GeodeAsyncEventQueuesHealthIndicator(gemfireCache)
|
||||
: new GeodeAsyncEventQueuesHealthIndicator();
|
||||
|
||||
Health.Builder builder = new Health.Builder();
|
||||
|
||||
@@ -138,6 +143,17 @@ public class GeodeAsyncEventQueuesHealthIndicatorUnitTests {
|
||||
Health health = builder.build();
|
||||
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPeerCache() throws Exception {
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(mock(ClientCache.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception {
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.data.gemfire.tests.mock.CacheMockObjects;
|
||||
* @see org.apache.geode.distributed.DistributedMember
|
||||
* @see org.apache.geode.distributed.DistributedSystem
|
||||
* @see org.springframework.boot.actuate.health.Health
|
||||
* @see org.springframework.boot.actuate.health.HealthIndicator
|
||||
* @see org.springframework.data.gemfire.tests.mock.CacheMockObjects
|
||||
* @see org.springframework.geode.boot.actuate.GeodeCacheHealthIndicator
|
||||
* @since 1.0.0
|
||||
@@ -133,7 +134,7 @@ public class GeodeCacheHealthIndicatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenNoGemFireCacheIsPresent() throws Exception {
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception {
|
||||
|
||||
GeodeCacheHealthIndicator healthIndicator = new GeodeCacheHealthIndicator();
|
||||
|
||||
@@ -144,6 +145,7 @@ public class GeodeCacheHealthIndicatorUnitTests {
|
||||
Health health = builder.build();
|
||||
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.geode.cache.Cache;
|
||||
import org.apache.geode.cache.GemFireCache;
|
||||
import org.apache.geode.cache.client.ClientCache;
|
||||
import org.apache.geode.cache.server.CacheServer;
|
||||
import org.apache.geode.cache.server.ServerLoadProbe;
|
||||
import org.junit.Before;
|
||||
@@ -39,9 +41,21 @@ import org.springframework.boot.actuate.health.Status;
|
||||
import org.springframework.data.gemfire.tests.mock.CacheServerMockObjects;
|
||||
|
||||
/**
|
||||
* The GeodeCacheServersHealthIndicatorUnitTests class...
|
||||
* Unit tests for {@link GeodeCacheServersHealthIndicator}.
|
||||
*
|
||||
* @author John Blum
|
||||
* @see org.junit.Test
|
||||
* @see org.mockito.Mock
|
||||
* @see org.mockito.Mockito
|
||||
* @see org.mockito.junit.MockitoJUnitRunner
|
||||
* @see org.apache.geode.cache.Cache
|
||||
* @see org.apache.geode.cache.GemFireCache
|
||||
* @see org.apache.geode.cache.server.CacheServer
|
||||
* @see org.apache.geode.cache.server.ServerLoadProbe
|
||||
* @see org.springframework.boot.actuate.health.Health
|
||||
* @see org.springframework.boot.actuate.health.HealthIndicator
|
||||
* @see org.springframework.data.gemfire.tests.mock.CacheServerMockObjects
|
||||
* @see org.springframework.geode.boot.actuate.GeodeCacheServersHealthIndicator
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
@@ -122,10 +136,11 @@ public class GeodeCacheServersHealthIndicatorUnitTests {
|
||||
verify(this.mockCache, times(1)).getCacheServers();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenNoGemFireCacheIsPresent() throws Exception {
|
||||
private void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception {
|
||||
|
||||
GeodeCacheServersHealthIndicator healthIndicator = new GeodeCacheServersHealthIndicator();
|
||||
GeodeCacheServersHealthIndicator healthIndicator = gemfireCache != null
|
||||
? new GeodeCacheServersHealthIndicator(gemfireCache)
|
||||
: new GeodeCacheServersHealthIndicator();
|
||||
|
||||
Health.Builder builder = new Health.Builder();
|
||||
|
||||
@@ -134,6 +149,17 @@ public class GeodeCacheServersHealthIndicatorUnitTests {
|
||||
Health health = builder.build();
|
||||
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPeerCache() throws Exception {
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(mock(ClientCache.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception {
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,8 @@ import org.springframework.data.gemfire.listener.ContinuousQueryListenerContaine
|
||||
* @see org.apache.geode.cache.query.CqQuery
|
||||
* @see org.apache.geode.cache.query.Query
|
||||
* @see org.apache.geode.cache.query.QueryService
|
||||
* @see org.springframework.boot.actuate.health.Health
|
||||
* @see org.springframework.boot.actuate.health.HealthIndicator
|
||||
* @see org.springframework.data.gemfire.listener.ContinuousQueryListenerContainer
|
||||
* @see org.springframework.geode.boot.actuate.GeodeContinuousQueriesHealthIndicator
|
||||
* @since 1.0.0
|
||||
@@ -123,7 +125,7 @@ public class GeodeContinuousQueriesHealthIndicatorUnitTests {
|
||||
|
||||
assertThat(healthDetails).isNotNull();
|
||||
assertThat(healthDetails).isNotEmpty();
|
||||
assertThat(healthDetails).containsEntry("geode.continuous-query.count", 1);
|
||||
assertThat(healthDetails).containsEntry("geode.continuous-query.count", mockContinuousQueries.length);
|
||||
assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.oql-query-string", "SELECT * FROM /Example WHERE status = 'RUNNING'");
|
||||
assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.closed", "No");
|
||||
assertThat(healthDetails).containsEntry("geode.continuous-query.MockContinuousQuery.closing", "No");
|
||||
@@ -141,7 +143,7 @@ public class GeodeContinuousQueriesHealthIndicatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenContinuousQueryListenerContainerNotPresent() throws Exception {
|
||||
public void healthCheckFailsWhenContinuousQueryListenerContainerIsNotPresent() throws Exception {
|
||||
|
||||
GeodeContinuousQueriesHealthIndicator healthIndicator = new GeodeContinuousQueriesHealthIndicator();
|
||||
|
||||
@@ -152,6 +154,7 @@ public class GeodeContinuousQueriesHealthIndicatorUnitTests {
|
||||
Health health = builder.build();
|
||||
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.data.gemfire.util.ArrayUtils;
|
||||
* @see org.springframework.boot.actuate.health.Health
|
||||
* @see org.springframework.boot.actuate.health.HealthIndicator
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.data.gemfire.tests.mock.DiskStoreMockObjects
|
||||
* @see org.springframework.geode.boot.actuate.GeodeDiskStoresHealthIndicator
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@@ -78,19 +79,19 @@ public class GeodeDiskStoresHealthIndicatorUnitTests {
|
||||
|
||||
int[] diskDirectorySizes = { 1024, 8192 };
|
||||
|
||||
Map<String, DiskStore> diskStoreBeans = new HashMap<>();
|
||||
Map<String, DiskStore> mockDiskStores = new HashMap<>();
|
||||
|
||||
diskStoreBeans.put("MockDiskStoreOne", DiskStoreMockObjects.mockDiskStore("MockDiskStoreOne",
|
||||
mockDiskStores.put("MockDiskStoreOne", DiskStoreMockObjects.mockDiskStore("MockDiskStoreOne",
|
||||
true, true, 90,
|
||||
ArrayUtils.asArray(mockDirectoryOne, mockDirectoryTwo), diskDirectorySizes, 0.95f,
|
||||
0.90f, 1024000L, 16384, 5000L, 32768));
|
||||
|
||||
diskStoreBeans.put("MockDiskStoreTwo", DiskStoreMockObjects.mockDiskStore("MockDiskStoreTwo",
|
||||
mockDiskStores.put("MockDiskStoreTwo", DiskStoreMockObjects.mockDiskStore("MockDiskStoreTwo",
|
||||
false, true, 50,null, null,
|
||||
0.90f,0.80f, 2048000L, 4096,
|
||||
15000L, 8192));
|
||||
|
||||
when(this.mockApplicationContext.getBeansOfType(DiskStore.class)).thenReturn(diskStoreBeans);
|
||||
when(this.mockApplicationContext.getBeansOfType(DiskStore.class)).thenReturn(mockDiskStores);
|
||||
|
||||
Health.Builder builder = new Health.Builder();
|
||||
|
||||
@@ -105,7 +106,7 @@ public class GeodeDiskStoresHealthIndicatorUnitTests {
|
||||
|
||||
assertThat(healthDetails).isNotNull();
|
||||
assertThat(healthDetails).isNotEmpty();
|
||||
assertThat(healthDetails).containsEntry("geode.disk-store.count", diskStoreBeans.size());
|
||||
assertThat(healthDetails).containsEntry("geode.disk-store.count", mockDiskStores.size());
|
||||
assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.allow-force-compaction", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.auto-compact", "Yes");
|
||||
assertThat(healthDetails).containsEntry("geode.disk-store.MockDiskStoreOne.compaction-threshold", 90);
|
||||
@@ -135,7 +136,7 @@ public class GeodeDiskStoresHealthIndicatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenNoApplcationContextIsPresent() throws Exception {
|
||||
public void healthCheckFailsWhenApplicationContextIsNotPresent() throws Exception {
|
||||
|
||||
GeodeDiskStoresHealthIndicator healthIndicator = new GeodeDiskStoresHealthIndicator();
|
||||
|
||||
@@ -146,6 +147,7 @@ public class GeodeDiskStoresHealthIndicatorUnitTests {
|
||||
Health health = builder.build();
|
||||
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ public class GeodeGatewayReceiversHealthIndicatorUnitTests {
|
||||
verify(this.mockCache, times(1)).getGatewayReceivers();
|
||||
}
|
||||
|
||||
private void testHealthCheckFailsWithInvalidGemFireCache(GemFireCache gemfireCache) throws Exception {
|
||||
private void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception {
|
||||
|
||||
GeodeGatewayReceiversHealthIndicator healthIndicator = gemfireCache != null
|
||||
? new GeodeGatewayReceiversHealthIndicator(gemfireCache)
|
||||
@@ -137,17 +137,17 @@ public class GeodeGatewayReceiversHealthIndicatorUnitTests {
|
||||
Health health = builder.build();
|
||||
|
||||
assertThat(health).isNotNull();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
assertThat(health.getDetails()).isEmpty();
|
||||
assertThat(health.getStatus()).isEqualTo(Status.UNKNOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenNoGemFireCacheIsPresent() throws Exception {
|
||||
testHealthCheckFailsWithInvalidGemFireCache(null);
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPeerCache() throws Exception {
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(mock(ClientCache.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsAClientCache() throws Exception {
|
||||
testHealthCheckFailsWithInvalidGemFireCache(mock(ClientCache.class));
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception {
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +87,8 @@ public class GeodeGatewaySendersHealthIndicatorUnitTests {
|
||||
GatewaySender.OrderPolicy.KEY, false, false, 789,
|
||||
false, 65536, 20000);
|
||||
|
||||
Set<GatewaySender> mockGatewaySenders = new TreeSet<>(Comparator.comparing(GatewaySender::getId));
|
||||
Set<GatewaySender> mockGatewaySenders =
|
||||
new TreeSet<>(Comparator.comparing(GatewaySender::getId));
|
||||
|
||||
mockGatewaySenders.addAll(asSet(mockGatewaySenderOne, mockGatewaySenderTwo));
|
||||
|
||||
@@ -161,12 +162,12 @@ public class GeodeGatewaySendersHealthIndicatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenNoGemFireCacheIsPresent() throws Exception {
|
||||
testHealthCheckFailsWithInvalidGemFireCache(null);
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPeerCache() throws Exception {
|
||||
testHealthCheckFailsWithInvalidGemFireCache(mock(ClientCache.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsAClientCache() throws Exception {
|
||||
testHealthCheckFailsWithInvalidGemFireCache(mock(ClientCache.class));
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception {
|
||||
testHealthCheckFailsWithInvalidGemFireCache(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.springframework.data.gemfire.tests.mock.IndexMockObjects;
|
||||
* @see org.apache.geode.cache.query.IndexStatistics
|
||||
* @see org.springframework.boot.actuate.health.Health
|
||||
* @see org.springframework.boot.actuate.health.HealthIndicator
|
||||
* @see org.springframework.context.ApplicationContext
|
||||
* @see org.springframework.data.gemfire.tests.mock.CacheMockObjects
|
||||
* @see org.springframework.data.gemfire.tests.mock.IndexMockObjects
|
||||
* @see org.springframework.geode.boot.actuate.GeodeIndexesHealthIndicator
|
||||
@@ -86,9 +87,9 @@ public class GeodeIndexesHealthIndicatorUnitTests {
|
||||
"id", "one, two", mockRegion, mockIndexStatistics,
|
||||
IndexType.PRIMARY_KEY.getGemfireIndexType());
|
||||
|
||||
Map<String, Index> mockIndexBeans = Collections.singletonMap("MockIndex", mockIndex);
|
||||
Map<String, Index> mockIndexes = Collections.singletonMap("MockIndex", mockIndex);
|
||||
|
||||
when(this.applicationContext.getBeansOfType(eq(Index.class))).thenReturn(mockIndexBeans);
|
||||
when(this.applicationContext.getBeansOfType(eq(Index.class))).thenReturn(mockIndexes);
|
||||
|
||||
Health.Builder builder = new Health.Builder();
|
||||
|
||||
@@ -103,7 +104,7 @@ public class GeodeIndexesHealthIndicatorUnitTests {
|
||||
|
||||
assertThat(healthDetails).isNotNull();
|
||||
assertThat(healthDetails).isNotEmpty();
|
||||
assertThat(healthDetails).containsEntry("geode.index.count", mockIndexBeans.size());
|
||||
assertThat(healthDetails).containsEntry("geode.index.count", mockIndexes.size());
|
||||
assertThat(healthDetails).containsEntry("geode.index.MockIndex.from-clause", "/Example");
|
||||
assertThat(healthDetails).containsEntry("geode.index.MockIndex.indexed-expression", "id");
|
||||
assertThat(healthDetails).containsEntry("geode.index.MockIndex.projection-attributes", "one, two");
|
||||
@@ -123,7 +124,7 @@ public class GeodeIndexesHealthIndicatorUnitTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenApplicationContextContainsNoIndexBeans() throws Exception {
|
||||
public void healthCheckFailsWhenApplicationContextContainsIsNotPresent() throws Exception {
|
||||
|
||||
GeodeIndexesHealthIndicator healthIndicator = new GeodeIndexesHealthIndicator();
|
||||
|
||||
|
||||
@@ -135,7 +135,7 @@ public class GeodePoolsHealthIndicatorUnitTests {
|
||||
verify(this.poolsHealthIndicator, times(1)).findAllPools();
|
||||
}
|
||||
|
||||
public void testHealthCheckFailsWithIvalidGemFireCache(GemFireCache gemfireCache) throws Exception {
|
||||
public void testHealthCheckFailsWhenGemFireCacheIsInvalid(GemFireCache gemfireCache) throws Exception {
|
||||
|
||||
GeodePoolsHealthIndicator healthIndicator = gemfireCache != null
|
||||
? new GeodePoolsHealthIndicator(gemfireCache)
|
||||
@@ -154,11 +154,11 @@ public class GeodePoolsHealthIndicatorUnitTests {
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotClientCache() throws Exception {
|
||||
testHealthCheckFailsWithIvalidGemFireCache(mock(Cache.class));
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(mock(Cache.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void healthCheckFailsWhenGemFireCacheIsNotPresent() throws Exception {
|
||||
testHealthCheckFailsWithIvalidGemFireCache(null);
|
||||
testHealthCheckFailsWhenGemFireCacheIsInvalid(null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,14 +87,14 @@ public class GeodeRegionsHealthIndicatorUnitTests {
|
||||
when(mockRegionOne.getAttributes().getScope()).thenReturn(Scope.DISTRIBUTED_ACK);
|
||||
when(mockRegionOne.getAttributes().getValueConstraint()).thenReturn((Class) Currency.class);
|
||||
|
||||
PartitionAttributes<?, ?> mockRegionOnePartitionAttributes = mock(PartitionAttributes.class);
|
||||
PartitionAttributes<?, ?> mockPartitionAttributes = mock(PartitionAttributes.class);
|
||||
|
||||
when(mockRegionOnePartitionAttributes.getColocatedWith()).thenReturn("CollocatedRegion");
|
||||
when(mockRegionOnePartitionAttributes.getLocalMaxMemory()).thenReturn(10240);
|
||||
when(mockRegionOnePartitionAttributes.getRedundantCopies()).thenReturn(2);
|
||||
when(mockRegionOnePartitionAttributes.getTotalMaxMemory()).thenReturn(4096000L);
|
||||
when(mockRegionOnePartitionAttributes.getTotalNumBuckets()).thenReturn(226);
|
||||
when(mockRegionOne.getAttributes().getPartitionAttributes()).thenReturn(mockRegionOnePartitionAttributes);
|
||||
when(mockPartitionAttributes.getColocatedWith()).thenReturn("CollocatedRegion");
|
||||
when(mockPartitionAttributes.getLocalMaxMemory()).thenReturn(10240);
|
||||
when(mockPartitionAttributes.getRedundantCopies()).thenReturn(2);
|
||||
when(mockPartitionAttributes.getTotalMaxMemory()).thenReturn(4096000L);
|
||||
when(mockPartitionAttributes.getTotalNumBuckets()).thenReturn(226);
|
||||
when(mockRegionOne.getAttributes().getPartitionAttributes()).thenReturn(mockPartitionAttributes);
|
||||
|
||||
Region<?, ?> mockRegionTwo = CacheMockObjects.mockRegion("MockRegionTwo", DataPolicy.EMPTY);
|
||||
|
||||
@@ -119,7 +119,7 @@ public class GeodeRegionsHealthIndicatorUnitTests {
|
||||
|
||||
Set<Region<?, ?>> mockRegions = asSet(mockRegionOne, mockRegionTwo);
|
||||
|
||||
when(mockGemFireCache.rootRegions()).thenReturn(mockRegions);
|
||||
when(this.mockGemFireCache.rootRegions()).thenReturn(mockRegions);
|
||||
|
||||
Health.Builder builder = new Health.Builder();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user