SnapshotService { public Pair<Node, String> takeSnapshot(String snapshotName, Node host, String... keyspaces) throws ReaperException { return clusterFacade.takeSnapshot(snapshotName, host, keyspaces); } private  SnapshotService(AppContext context, ExecutorService executor, Supplier<ClusterFacade> clusterFacadeSupplier); static SnapshotService create(AppContext context, ExecutorService executor); Pair<Node, String> takeSnapshot(String snapshotName, Node host, String... keyspaces); List<Pair<Node, String>> takeSnapshotClusterWide(
      String snapshotName,
      String clusterName,
      String owner,
      String cause,
      String... keyspace); Map<String, List<Snapshot>> listSnapshotsGroupedByName(Node host); List<Snapshot> listSnapshots(Node host); Map<String, Map<String, List<Snapshot>>> listSnapshotsClusterWide(String clusterName); void clearSnapshot(String snapshotName, Node host); void clearSnapshotClusterWide(String snapshotName, String clusterName); String formatSnapshotName(String snapshotName); static final String SNAPSHOT_PREFIX; }
@Test public void testTakeSnapshot() throws InterruptedException, ReaperException, ClassNotFoundException, IOException { JmxProxy proxy = (JmxProxy) mock(Class.forName("io.cassandrareaper.jmx.JmxProxyImpl")); StorageServiceMBean storageMBean = Mockito.mock(StorageServiceMBean.class); JmxProxyTest.mockGetStorageServiceMBean(proxy, storageMBean); AppContext cxt = new AppContext(); cxt.config = TestRepairConfiguration.defaultConfig(); cxt.jmxConnectionFactory = mock(JmxConnectionFactory.class); when(cxt.jmxConnectionFactory.connectAny(any(Collection.class))).thenReturn(proxy); Pair<Node,String> result = SnapshotService .create(cxt, SNAPSHOT_MANAGER_EXECUTOR) .takeSnapshot("Test", Node.builder().withHostname("127.0.0.1").build()); Assertions.assertThat(result.getLeft().getHostname()).isEqualTo("127.0.0.1"); Assertions.assertThat(result.getRight()).isEqualTo("Test"); verify(storageMBean, times(1)).takeSnapshot("Test"); }