use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method testSetPdxSerializationDetails.
@Test
public void testSetPdxSerializationDetails() {
final String diskStoreName = "testDiskStore";
final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getPdxPersistent();
will(returnValue(true));
oneOf(mockCache).getPdxDiskStore();
will(returnValue(diskStoreName));
oneOf(mockDiskStore).getName();
will(returnValue(diskStoreName));
}
});
final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(mockCache);
function.setPdxSerializationDetails(mockCache, mockDiskStore, diskStoreDetails);
assertTrue(diskStoreDetails.isPdxSerializationMetaDataStored());
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class DescribeDiskStoreFunctionJUnitTest method testSetAsyncEventQueueDetails.
@Test
public void testSetAsyncEventQueueDetails() {
final String diskStoreName = "testDiskStore";
final InternalCache mockCache = mockContext.mock(InternalCache.class, "Cache");
final AsyncEventQueue mockQueue1 = mockContext.mock(AsyncEventQueue.class, "AsyncEvenQueue1");
final AsyncEventQueue mockQueue2 = mockContext.mock(AsyncEventQueue.class, "AsyncEvenQueue2");
final AsyncEventQueue mockQueue3 = mockContext.mock(AsyncEventQueue.class, "AsyncEvenQueue3");
final DiskStore mockDiskStore = mockContext.mock(DiskStore.class, "DiskStore");
mockContext.checking(new Expectations() {
{
oneOf(mockCache).getAsyncEventQueues();
will(returnValue(CollectionUtils.asSet(mockQueue1, mockQueue2, mockQueue3)));
oneOf(mockQueue1).isPersistent();
will(returnValue(true));
oneOf(mockQueue1).getDiskStoreName();
will(returnValue(diskStoreName));
oneOf(mockQueue1).getId();
will(returnValue("q1"));
oneOf(mockQueue2).isPersistent();
will(returnValue(true));
oneOf(mockQueue2).getDiskStoreName();
will(returnValue(null));
oneOf(mockQueue3).isPersistent();
will(returnValue(false));
atLeast(1).of(mockDiskStore).getName();
will(returnValue(diskStoreName));
}
});
final Set<DiskStoreDetails.AsyncEventQueueDetails> expectedAsyncEventQueueDetails = CollectionUtils.asSet(createAsyncEventQueueDetails("q1"));
final DiskStoreDetails diskStoreDetails = new DiskStoreDetails(diskStoreName, "memberOne");
final DescribeDiskStoreFunction function = createDescribeDiskStoreFunction(mockCache);
function.setAsyncEventQueueDetails(mockCache, mockDiskStore, diskStoreDetails);
assertAsyncEventQueueDetails(expectedAsyncEventQueueDetails, diskStoreDetails);
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class DiskStoreCommandsJUnitTest method testGetDiskStoreDescription.
@Test
public void testGetDiskStoreDescription() {
final String diskStoreName = "mockDiskStore";
final String memberId = "mockMember";
final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
final DistributedMember mockMember = mockContext.mock(DistributedMember.class, "DistributedMember");
final Execution mockFunctionExecutor = mockContext.mock(Execution.class, "Function Executor");
final ResultCollector mockResultCollector = mockContext.mock(ResultCollector.class, "ResultCollector");
final DiskStoreDetails expectedDiskStoredDetails = createDiskStoreDetails(memberId, diskStoreName);
mockContext.checking(new Expectations() {
{
oneOf(mockMember).getName();
will(returnValue(null));
oneOf(mockMember).getId();
will(returnValue(memberId));
oneOf(mockFunctionExecutor).setArguments(with(equal(diskStoreName)));
will(returnValue(mockFunctionExecutor));
oneOf(mockFunctionExecutor).execute(with(aNonNull(DescribeDiskStoreFunction.class)));
will(returnValue(mockResultCollector));
oneOf(mockResultCollector).getResult();
will(returnValue(Arrays.asList(expectedDiskStoredDetails)));
}
});
final DiskStoreCommands commands = createDiskStoreCommands(mockCache, mockMember, mockFunctionExecutor);
final DiskStoreDetails actualDiskStoreDetails = commands.getDiskStoreDescription(memberId, diskStoreName);
assertNotNull(actualDiskStoreDetails);
assertEquals(expectedDiskStoredDetails, actualDiskStoreDetails);
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class DiskStoreCommandsJUnitTest method testGetDiskStoreList.
@Test
public void testGetDiskStoreList() {
final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
final DistributedMember mockDistributedMember = mockContext.mock(DistributedMember.class, "DistributedMember");
final AbstractExecution mockFunctionExecutor = mockContext.mock(AbstractExecution.class, "Function Executor");
final ResultCollector mockResultCollector = mockContext.mock(ResultCollector.class, "ResultCollector");
final DiskStoreDetails diskStoreDetails1 = createDiskStoreDetails("memberOne", "cacheServerDiskStore");
final DiskStoreDetails diskStoreDetails2 = createDiskStoreDetails("memberOne", "gatewayDiskStore");
final DiskStoreDetails diskStoreDetails3 = createDiskStoreDetails("memberTwo", "pdxDiskStore");
final DiskStoreDetails diskStoreDetails4 = createDiskStoreDetails("memberTwo", "regionDiskStore");
final List<DiskStoreDetails> expectedDiskStores = Arrays.asList(diskStoreDetails1, diskStoreDetails2, diskStoreDetails3, diskStoreDetails4);
final List<Set<DiskStoreDetails>> results = new ArrayList<Set<DiskStoreDetails>>();
results.add(CollectionUtils.asSet(diskStoreDetails4, diskStoreDetails3));
results.add(CollectionUtils.asSet(diskStoreDetails1, diskStoreDetails2));
mockContext.checking(new Expectations() {
{
oneOf(mockFunctionExecutor).setIgnoreDepartedMembers(with(equal(true)));
oneOf(mockFunctionExecutor).execute(with(aNonNull(ListDiskStoresFunction.class)));
will(returnValue(mockResultCollector));
oneOf(mockResultCollector).getResult();
will(returnValue(results));
}
});
final DiskStoreCommands commands = createDiskStoreCommands(mockCache, mockDistributedMember, mockFunctionExecutor);
final List<DiskStoreDetails> actualDiskStores = commands.getDiskStoreListing(commands.getNormalMembers(mockCache));
Assert.assertNotNull(actualDiskStores);
assertEquals(expectedDiskStores, actualDiskStores);
}
use of org.apache.geode.management.internal.cli.domain.DiskStoreDetails in project geode by apache.
the class DiskStoreCommandsJUnitTest method testGetDiskStoreListReturnsFunctionInvocationTargetExceptionInResults.
@Test
public void testGetDiskStoreListReturnsFunctionInvocationTargetExceptionInResults() {
final InternalCache mockCache = mockContext.mock(InternalCache.class, "InternalCache");
final DistributedMember mockDistributedMember = mockContext.mock(DistributedMember.class, "DistributedMember");
final AbstractExecution mockFunctionExecutor = mockContext.mock(AbstractExecution.class, "Function Executor");
final ResultCollector mockResultCollector = mockContext.mock(ResultCollector.class, "ResultCollector");
final DiskStoreDetails diskStoreDetails = createDiskStoreDetails("memberOne", "cacheServerDiskStore");
final List<DiskStoreDetails> expectedDiskStores = Arrays.asList(diskStoreDetails);
final List<Object> results = new ArrayList<Object>();
results.add(CollectionUtils.asSet(diskStoreDetails));
results.add(new FunctionInvocationTargetException("expected"));
mockContext.checking(new Expectations() {
{
oneOf(mockFunctionExecutor).setIgnoreDepartedMembers(with(equal(true)));
oneOf(mockFunctionExecutor).execute(with(aNonNull(ListDiskStoresFunction.class)));
will(returnValue(mockResultCollector));
oneOf(mockResultCollector).getResult();
will(returnValue(results));
}
});
final DiskStoreCommands commands = createDiskStoreCommands(mockCache, mockDistributedMember, mockFunctionExecutor);
final List<DiskStoreDetails> actualDiskStores = commands.getDiskStoreListing(commands.getNormalMembers(mockCache));
Assert.assertNotNull(actualDiskStores);
assertEquals(expectedDiskStores, actualDiskStores);
}
Aggregations