SnapshotIdentifier { public String getRestoreSpaceId() { String spaceName = spaceId + "-" + DateUtil.convertToStringPlain(timestamp); if (spaceName.length() > 42) { spaceName = spaceName.substring(0, 42); } if (spaceName.endsWith("-")) { spaceName = spaceName.substring(0, spaceName.length() - 1); } return spaceName; } SnapshotIdentifier(String accountName, String storeId,
                              String spaceId, long timestamp); String getAccountName(); String getStoreId(); String getSpaceId(); long getTimestamp(); String getSnapshotId(); String getRestoreSpaceId(); static SnapshotIdentifier parseSnapshotId(String snapshotId); @Override boolean equals(Object o); @Override int hashCode(); static final String DELIM; }
@Test public void testRestoreSpaceId() { String accountName = "account-name"; String storeId = "store-id"; long timestamp = 42l; String spaceId = "space-id"; SnapshotIdentifier snapshotIdentifier = new SnapshotIdentifier(accountName, storeId, spaceId, timestamp); assertEquals(spaceId + "-" + DateUtil.convertToStringPlain(timestamp), snapshotIdentifier.getRestoreSpaceId()); spaceId = "unnecessarily-long-space-id"; snapshotIdentifier = new SnapshotIdentifier(accountName, storeId, spaceId, timestamp); assertEquals(spaceId + "-" + DateUtil.convertToStringPlain(timestamp) .substring(0, 13), snapshotIdentifier.getRestoreSpaceId()); }