com.amazonaws.client.builder.AwsSyncClientBuilder Java Examples

The following examples show how to use com.amazonaws.client.builder.AwsSyncClientBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CFNUpdateStackTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.stack = Mockito.mock(CloudFormationStack.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.whenNew(CloudFormationStack.class)
			.withAnyArguments()
			.thenReturn(this.stack);
	this.cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class)))
			.thenReturn(this.cloudFormation);
}
 
Example #2
Source File: LambdaVersionCleanupStepTest.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	PowerMockito.mockStatic(AWSClientFactory.class);
	this.awsLambda = Mockito.mock(AWSLambda.class);
	this.cloudformation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
		.thenAnswer( (x) -> {
			if (x.getArgumentAt(0, AwsSyncClientBuilder.class) instanceof AWSLambdaClientBuilder) {
				return awsLambda;
			} else {
				return cloudformation;
			}
		});
}
 
Example #3
Source File: EC2ShareAmiStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	PowerMockito.mockStatic(AWSClientFactory.class);
	this.ec2 = Mockito.mock(AmazonEC2.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(this.ec2);
}
 
Example #4
Source File: UpdateTrustPolicyStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	PowerMockito.mockStatic(AWSClientFactory.class);
	this.iam = Mockito.mock(AmazonIdentityManagement.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(this.iam);
}
 
Example #5
Source File: CFNCreateChangeSetTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.stack = Mockito.mock(CloudFormationStack.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.whenNew(CloudFormationStack.class)
			.withAnyArguments()
			.thenReturn(this.stack);
	AmazonCloudFormation cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class)))
			.thenReturn(cloudFormation);
}
 
Example #6
Source File: CFNDescribeStackTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.stack = Mockito.mock(CloudFormationStack.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.whenNew(CloudFormationStack.class)
			.withAnyArguments()
			.thenReturn(this.stack);
	this.cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class)))
			.thenReturn(this.cloudFormation);
}
 
Example #7
Source File: CFNUpdateStackSetStepTest.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	stackSet = Mockito.mock(CloudFormationStackSet.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.whenNew(CloudFormationStackSet.class)
			.withAnyArguments()
			.thenReturn(stackSet);
	AmazonCloudFormation cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class)))
			.thenReturn(cloudFormation);
}
 
Example #8
Source File: CFNDeleteStackSetStepTest.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	stackSet = Mockito.mock(CloudFormationStackSet.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.whenNew(CloudFormationStackSet.class)
			.withAnyArguments()
			.thenReturn(stackSet);
	AmazonCloudFormation cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(cloudFormation);
}
 
Example #9
Source File: CFNExportsStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	PowerMockito.mockStatic(AWSClientFactory.class);
	this.cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(this.cloudFormation);
}
 
Example #10
Source File: CFNDeleteStackTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.stack = Mockito.mock(CloudFormationStack.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.whenNew(CloudFormationStack.class)
			.withAnyArguments()
			.thenReturn(this.stack);
	this.cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class)))
			.thenReturn(this.cloudFormation);
}
 
Example #11
Source File: CFNExecuteChangeSetTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.stack = Mockito.mock(CloudFormationStack.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.whenNew(CloudFormationStack.class)
			.withAnyArguments()
			.thenReturn(this.stack);
	AmazonCloudFormation cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class)))
			.thenReturn(cloudFormation);
}
 
Example #12
Source File: CFNValidateStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	PowerMockito.mockStatic(AWSClientFactory.class);
	this.cloudFormation = Mockito.mock(AmazonCloudFormation.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(this.cloudFormation);
}
 
Example #13
Source File: S3UploadStepTransferManagerIntegrationTest.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	PowerMockito.mockStatic(AWSClientFactory.class);
	AmazonS3 amazonS3 = PowerMockito.mock(AmazonS3.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(amazonS3);

	PowerMockito.mockStatic(TransferManagerBuilder.class);
	transferManager = Mockito.mock(TransferManager.class);
	TransferManagerBuilder transferManagerBuilder = PowerMockito.mock(TransferManagerBuilder.class);
	PowerMockito.when(TransferManagerBuilder.standard()).thenReturn(transferManagerBuilder);
	PowerMockito.when(transferManagerBuilder.withS3Client(Mockito.any(AmazonS3.class))).thenReturn(transferManagerBuilder);
	PowerMockito.when(transferManagerBuilder.build()).thenReturn(transferManager);
}
 
Example #14
Source File: S3PresignUrlStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	PowerMockito.mockStatic(AWSClientFactory.class);
	this.s3 = Mockito.mock(AmazonS3.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(EnvVars.class)))
			.thenReturn(this.s3);
}
 
Example #15
Source File: ECRSetRepositoryPolicyStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.ecr = Mockito.mock(AmazonECR.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(ecr);
}
 
Example #16
Source File: ECRDeleteImagesStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.ecr = Mockito.mock(AmazonECR.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(ecr);
}
 
Example #17
Source File: ECRListImagesStepTests.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
@Before
public void setupSdk() throws Exception {
	this.ecr = Mockito.mock(AmazonECR.class);
	PowerMockito.mockStatic(AWSClientFactory.class);
	PowerMockito.when(AWSClientFactory.create(Mockito.any(AwsSyncClientBuilder.class), Mockito.any(StepContext.class)))
			.thenReturn(ecr);
}
 
Example #18
Source File: AWSClientFactory.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
public static <B extends AwsSyncClientBuilder<?, ?>> B configureBuilder(final B clientBuilder, final EnvVars vars) {
	if (clientBuilder == null) {
		throw new IllegalArgumentException("ClientBuilder must not be null");
	}
	if (StringUtils.isNotBlank(vars.get(AWS_ENDPOINT_URL))) {
		clientBuilder.setEndpointConfiguration(new AwsClientBuilder.EndpointConfiguration(vars.get(AWS_ENDPOINT_URL), vars.get(AWS_REGION)));
	} else {
		clientBuilder.setRegion(AWSClientFactory.getRegion(vars).getName());
	}
	clientBuilder.setCredentials(AWSClientFactory.getCredentials(vars));
	clientBuilder.setClientConfiguration(AWSClientFactory.getClientConfiguration(vars));
	return clientBuilder;
}
 
Example #19
Source File: AWSClientFactory.java    From pipeline-aws-plugin with Apache License 2.0 5 votes vote down vote up
public static <B extends AwsSyncClientBuilder<?, T>, T> T create(B clientBuilder, StepContext context) {
	try {
		return configureBuilder(clientBuilder, context.get(EnvVars.class)).build();
	} catch (Exception e) {
		throw new IllegalArgumentException(e);
	}
}
 
Example #20
Source File: AWSTokenRequestGenerator.java    From docker-registry-artifact-plugin with Apache License 2.0 4 votes vote down vote up
AWSTokenRequestGenerator(AwsSyncClientBuilder<AmazonECRClientBuilder, AmazonECR> builder) {
    this.builder = builder;
}
 
Example #21
Source File: AWSClientFactory.java    From pipeline-aws-plugin with Apache License 2.0 4 votes vote down vote up
public static <B extends AwsSyncClientBuilder<?, T>, T> T create(B clientBuilder, EnvVars vars) {
	return configureBuilder(clientBuilder, vars).build();
}
 
Example #22
Source File: AWSTokenRequestGenerator.java    From docker-registry-artifact-plugin with Apache License 2.0 4 votes vote down vote up
AwsSyncClientBuilder<AmazonECRClientBuilder, AmazonECR> getBuilder() {
    return builder;
}