@Test public void shouldDownloadBundle() { client.downloadBundle(ANY_RESOURCE_ID); String expectedUri = ARTIFACTS_BUNDLE_URI + ARTIFACTS_BUNDLE_DOWNLOAD_URI + "/" + ANY_RESOURCE_ID; Request expectedRequest = new Request(HttpMethod.GET, expectedUri); then(baseClient).should().executeRequest(expectedRequest, TypeToken.of(String.class).getType()); }
@Test public void shouldGetArtifactsBundle() { client.getById(ANY_RESOURCE_ID); String expectedUri = ARTIFACTS_BUNDLE_URI + "/" + ANY_RESOURCE_ID; Request expectedRequest = new Request(HttpMethod.GET, expectedUri); then(baseClient) .should() .executeRequest(expectedRequest, TypeToken.of(ArtifactsBundle.class).getType()); }
@Test public void shouldExtractBundle() { client.extractBundle(ANY_RESOURCE_ID, TaskTimeout.of(123)); String expectedUri = ARTIFACTS_BUNDLE_URI + "/" + ANY_RESOURCE_ID; Request expectedRequest = new Request(HttpMethod.PUT, expectedUri, ""); expectedRequest.setContentType(ContentType.TEXT_PLAIN); expectedRequest.setTimeout(123); then(baseClient).should().executeMonitorableRequest(expectedRequest); }
@Test public void shouldCreateBackupBundle() { UserBackupParams userBackupParams = new UserBackupParams(); client.createBackupBundle(userBackupParams, TaskTimeout.of(123)); String expectedUri = ARTIFACTS_BUNDLE_URI + ARTIFACTS_BUNDLE_BACKUPS_URI; Request expectedRequest = new Request(HttpMethod.POST, expectedUri, userBackupParams); expectedRequest.setTimeout(123); then(baseClient).should().executeMonitorableRequest(expectedRequest); }
@Test public void shouldCreateArtifactsBundle() { CreateArtifactsBundle artifactsBundle = new CreateArtifactsBundle(); client.create(artifactsBundle, TaskTimeout.of(123)); Request expectedRequest = new Request(HttpMethod.POST, ARTIFACTS_BUNDLE_URI, artifactsBundle); expectedRequest.setTimeout(123); then(baseClient).should().executeMonitorableRequest(expectedRequest); }
@Test public void shouldGetArtifactsBundleCollectionByName() { client.getByName(ANY_RESOURCE_NAME); Request expectedRequest = new Request(HttpMethod.GET, ARTIFACTS_BUNDLE_URI); expectedRequest.addQuery(UrlParameter.getFilterByNameParameter(ANY_RESOURCE_NAME)); then(baseClient) .should() .executeRequest( expectedRequest, new TypeToken<ResourceCollection<ArtifactsBundle>>() {}.getType()); }
@Test public void shouldExtractBackupBundle() { UserBackupParams userBackupParams = new UserBackupParams(); client.extractBackupBundle(ANY_RESOURCE_ID, userBackupParams, TaskTimeout.of(123)); String expectedUri = ARTIFACTS_BUNDLE_URI + ARTIFACTS_BUNDLE_BACKUPS_URI + "/" + ANY_RESOURCE_ID; Request expectedRequest = new Request(HttpMethod.PUT, expectedUri, userBackupParams); expectedRequest.setTimeout(123); then(baseClient).should().executeMonitorableRequest(expectedRequest); }
@Test public void shouldGetBackupBundles() { client.getBackupBundles(); String expectedUri = ARTIFACTS_BUNDLE_URI + ARTIFACTS_BUNDLE_BACKUPS_URI; Request expectedRequest = new Request(HttpMethod.GET, expectedUri); then(baseClient) .should() .executeRequest( expectedRequest, new TypeToken<ResourceCollection<ArtifactsBundle>>() {}.getType()); }
@Test public void shouldCreateArtifactsBundleFromFile() { File file = new File(ANY_FILE_PATH); client.create(file, DownloadPath.at(ANY_FILE_PATH)); Request expectedRequest = new Request(HttpMethod.POST, ARTIFACTS_BUNDLE_URI, file); expectedRequest.setDownloadPath(ANY_FILE_PATH); expectedRequest.setContentType(ContentType.MULTIPART_FORM_DATA); expectedRequest.setForceReturnTask(true); then(baseClient).should().executeMonitorableRequest(expectedRequest); }
@Test public void shouldGetAllArtifactsBundles() { given(this.baseClient.executeRequest(any(Request.class), any(Type.class))) .willReturn(new ResourceCollection<>()); client.getAll(); Request expectedRequest = new Request(HttpMethod.GET, ARTIFACTS_BUNDLE_URI); then(baseClient) .should() .executeRequest( expectedRequest, new TypeToken<ResourceCollection<ArtifactsBundle>>() {}.getType()); }
@Test public void shouldStopBundleCreation() { TaskUri taskUri = new TaskUri(); taskUri.setTaskUri(ANY_TASK_URI); client.stopBundleCreation(ANY_RESOURCE_ID, taskUri); String expectedUri = ARTIFACTS_BUNDLE_URI + "/" + ANY_RESOURCE_ID + ARTIFACTS_BUNDLE_STOP_ARTIFACT_CREATE_URI; Request expectedRequest = new Request(HttpMethod.PUT, expectedUri, taskUri); then(baseClient).should().executeRequest(expectedRequest, TypeToken.of(String.class).getType()); }
@Test public void shouldCreateBackupArchiveBundle() { File file = new File(ANY_FILE_PATH); String deploymentGrpUri = DeploymentGroupClient.DEPLOYMENT_GROUP_URI + "/" + DEPLOYMENT_GROUP_RESOURCE_ID; UrlParameter query = new UrlParameter("deploymentGrpUri", deploymentGrpUri); client.createBackupArchiveBundle(file, deploymentGrpUri, DownloadPath.at(ANY_FILE_PATH)); String expectedUri = ARTIFACTS_BUNDLE_URI + ARTIFACTS_BUNDLE_BACKUPS_URI + ARTIFACTS_BUNDLE_ARCHIVE_URI; Request expectedRequest = new Request(HttpMethod.POST, expectedUri, file); expectedRequest.addQuery(query); expectedRequest.setDownloadPath(ANY_FILE_PATH); expectedRequest.setContentType(ContentType.MULTIPART_FORM_DATA); expectedRequest.setForceReturnTask(true); then(baseClient).should().executeMonitorableRequest(expectedRequest); }