GetSnapshotHistoryTaskRunner extends AbstractSnapshotTaskRunner { protected String buildBridgeURL(GetSnapshotHistoryTaskParameters taskParams) { int pageNumber = taskParams.getPageNumber(); if (pageNumber < SnapshotConstants.DEFAULT_HISTORY_PAGE_NUMBER) { pageNumber = SnapshotConstants.DEFAULT_HISTORY_PAGE_NUMBER; } int pageSize = taskParams.getPageSize(); if (pageSize < SnapshotConstants.MIN_HISTORY_PAGE_SIZE || pageSize > SnapshotConstants.MAX_HISTORY_PAGE_SIZE) { pageSize = SnapshotConstants.MAX_HISTORY_PAGE_SIZE; } String snapshotId = taskParams.getSnapshotId(); return MessageFormat.format( "{0}/snapshot/{1}/history?page={2}&pageSize={3}", buildBridgeBaseURL(), snapshotId, String.valueOf(pageNumber), String.valueOf(pageSize)); } GetSnapshotHistoryTaskRunner(String bridgeAppHost,
                                        String bridgeAppPort,
                                        String bridgeAppUser,
                                        String bridgeAppPass); @Override String getName(); @Override String performTask(String taskParameters);  }
@Test public void testBuildSnapshotURL() { replayMocks(); GetSnapshotHistoryTaskParameters taskParams = new GetSnapshotHistoryTaskParameters(); taskParams.setSnapshotId(snapshotId); taskParams.setPageNumber(pageNumber); taskParams.setPageSize(pageSize); String url = taskRunner.buildBridgeURL(taskParams); String expectedUrl = "http: "/bridge/snapshot/" + snapshotId + "/history?page=" + pageNumber + "&pageSize=" + pageSize; assertEquals(expectedUrl, url); taskParams = new GetSnapshotHistoryTaskParameters(); taskParams.setSnapshotId(snapshotId); taskParams.setPageNumber(-500); taskParams.setPageSize(100000000); url = taskRunner.buildBridgeURL(taskParams); expectedUrl = "http: "/bridge/snapshot/" + snapshotId + "/history?page=0&pageSize=1000"; assertEquals(expectedUrl, url); }