DisableStreamingTaskRunner extends BaseStreamingTaskRunner { public String performTask(String taskParameters) { DisableStreamingTaskParameters taskParams = DisableStreamingTaskParameters.deserialize(taskParameters); String spaceId = taskParams.getSpaceId(); log.info("Performing " + TASK_NAME + " task on space " + spaceId); String bucketName = unwrappedS3Provider.getBucketName(spaceId); DisableStreamingTaskResult taskResult = new DisableStreamingTaskResult(); removeStreamingHostFromSpaceProps(spaceId); StreamingDistributionSummary existingDist = getExistingDistribution(bucketName); if (existingDist != null) { s3Client.deleteBucketPolicy(bucketName); } else { throw new RuntimeException("No streaming distribution " + "exists for space " + spaceId); } taskResult.setResult("Disable Streaming Task completed successfully"); String toReturn = taskResult.serialize(); log.info("Result of " + TASK_NAME + " task: " + toReturn); return toReturn; } DisableStreamingTaskRunner(StorageProvider s3Provider,
                                      S3StorageProvider unwrappedS3Provider,
                                      AmazonS3 s3Client,
                                      AmazonCloudFrontClient cfClient); String getName(); String performTask(String taskParameters);  }
@Test public void testPerformTask1() throws Exception { DisableStreamingTaskRunner runner = createRunner(createMockStorageProviderV2(true), createMockUnwrappedS3StorageProviderV2(), createMockS3ClientV1(), createMockCFClientV3()); try { runner.performTask(null); fail("Exception expected"); } catch (Exception expected) { assertNotNull(expected); } DisableStreamingTaskParameters taskParams = new DisableStreamingTaskParameters(); taskParams.setSpaceId(spaceId); try { runner.performTask(taskParams.serialize()); fail("Exception expected"); } catch (Exception expected) { assertNotNull(expected); } testCapturedProps(); }
@Test public void testPerformTask2() throws Exception { DisableStreamingTaskRunner runner = createRunner(createMockStorageProviderV2(true), createMockUnwrappedS3StorageProviderV2(), createMockS3ClientV3(), createMockCFClientV4()); DisableStreamingTaskParameters taskParams = new DisableStreamingTaskParameters(); taskParams.setSpaceId(spaceId); String results = runner.performTask(taskParams.serialize()); assertNotNull(results); testCapturedProps(); }