Example usage for org.apache.cassandra.service StorageServiceMBean getSnapshotDetails

List of usage examples for org.apache.cassandra.service StorageServiceMBean getSnapshotDetails

Introduction

In this page you can find the example usage for org.apache.cassandra.service StorageServiceMBean getSnapshotDetails.

Prototype

public Map<String, TabularData> getSnapshotDetails();

Source Link

Document

Get the details of all the snapshot

Usage

From source file:io.cassandrareaper.service.SnapshotManagerTest.java

License:Apache License

@Test
public void testListSnapshot() throws InterruptedException, ReaperException, ClassNotFoundException {

    JmxProxy proxy = (JmxProxy) mock(Class.forName("io.cassandrareaper.jmx.JmxProxyImpl"));
    when(proxy.getCassandraVersion()).thenReturn("2.1.0");
    StorageServiceMBean storageMBean = Mockito.mock(StorageServiceMBean.class);
    JmxProxyTest.mockGetStorageServiceMBean(proxy, storageMBean);
    when(storageMBean.getSnapshotDetails()).thenReturn(Collections.emptyMap());

    AppContext cxt = new AppContext();
    cxt.config = TestRepairConfiguration.defaultConfig();
    cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class);
    when(cxt.jmxConnectionFactory.connect(Mockito.any(Node.class), Mockito.anyInt())).thenReturn(proxy);

    List<Snapshot> result = SnapshotManager.create(cxt, SNAPSHOT_MANAGER_EXECUTOR)
            .listSnapshots(Node.builder().withClusterName("Test").withHostname("127.0.0.1").build());

    Assertions.assertThat(result).isEmpty();
    verify(storageMBean, times(1)).getSnapshotDetails();
}