use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project aws-athena-query-federation by awslabs.
the class OracleMetadataHandlerTest method setup.
@Before
public void setup() {
this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class, Mockito.RETURNS_DEEP_STUBS);
this.connection = Mockito.mock(Connection.class, Mockito.RETURNS_DEEP_STUBS);
Mockito.when(this.jdbcConnectionFactory.getConnection(Mockito.any(JdbcCredentialProvider.class))).thenReturn(this.connection);
this.secretsManager = Mockito.mock(AWSSecretsManager.class);
this.athena = Mockito.mock(AmazonAthena.class);
Mockito.when(this.secretsManager.getSecretValue(Mockito.eq(new GetSecretValueRequest().withSecretId("testSecret")))).thenReturn(new GetSecretValueResult().withSecretString("{\"username\": \"testUser\", \"password\": \"testPassword\"}"));
this.oracleMetadataHandler = new OracleMetadataHandler(databaseConnectionConfig, this.secretsManager, this.athena, this.jdbcConnectionFactory);
this.federatedIdentity = Mockito.mock(FederatedIdentity.class);
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project aws-athena-query-federation by awslabs.
the class RedisMetadataHandlerTest method setUp.
@Before
public void setUp() throws Exception {
logger.info("{}: enter", testName.getMethodName());
when(mockFactory.getOrCreateConn(eq(decodedEndpoint), anyBoolean(), anyBoolean(), anyString())).thenReturn(mockConnection);
when(mockConnection.sync()).thenReturn(mockSyncCommands);
handler = new RedisMetadataHandler(mockGlue, new LocalKeyFactory(), mockSecretsManager, mockAthena, mockFactory, "bucket", "prefix");
allocator = new BlockAllocatorImpl();
when(mockSecretsManager.getSecretValue(any(GetSecretValueRequest.class))).thenAnswer((InvocationOnMock invocation) -> {
GetSecretValueRequest request = invocation.getArgumentAt(0, GetSecretValueRequest.class);
if ("endpoint".equalsIgnoreCase(request.getSecretId())) {
return new GetSecretValueResult().withSecretString(decodedEndpoint);
}
throw new RuntimeException("Unknown secret " + request.getSecretId());
});
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project aws-athena-query-federation by awslabs.
the class RedisRecordHandlerTest method setUp.
@Before
public void setUp() {
logger.info("{}: enter", testName.getMethodName());
when(mockFactory.getOrCreateConn(eq(decodedEndpoint), anyBoolean(), anyBoolean(), anyString())).thenReturn(mockConnection);
when(mockConnection.sync()).thenReturn(mockSyncCommands);
allocator = new BlockAllocatorImpl();
amazonS3 = mock(AmazonS3.class);
when(amazonS3.putObject(anyObject(), anyObject(), anyObject(), anyObject())).thenAnswer((InvocationOnMock invocationOnMock) -> {
InputStream inputStream = (InputStream) invocationOnMock.getArguments()[2];
ByteHolder byteHolder = new ByteHolder();
byteHolder.setBytes(ByteStreams.toByteArray(inputStream));
synchronized (mockS3Storage) {
mockS3Storage.add(byteHolder);
logger.info("puObject: total size " + mockS3Storage.size());
}
return mock(PutObjectResult.class);
});
when(amazonS3.getObject(anyString(), anyString())).thenAnswer((InvocationOnMock invocationOnMock) -> {
S3Object mockObject = mock(S3Object.class);
ByteHolder byteHolder;
synchronized (mockS3Storage) {
byteHolder = mockS3Storage.get(0);
mockS3Storage.remove(0);
logger.info("getObject: total size " + mockS3Storage.size());
}
when(mockObject.getObjectContent()).thenReturn(new S3ObjectInputStream(new ByteArrayInputStream(byteHolder.getBytes()), null));
return mockObject;
});
when(mockSecretsManager.getSecretValue(any(GetSecretValueRequest.class))).thenAnswer((InvocationOnMock invocation) -> {
GetSecretValueRequest request = invocation.getArgumentAt(0, GetSecretValueRequest.class);
if ("endpoint".equalsIgnoreCase(request.getSecretId())) {
return new GetSecretValueResult().withSecretString(decodedEndpoint);
}
throw new RuntimeException("Unknown secret " + request.getSecretId());
});
handler = new RedisRecordHandler(amazonS3, mockSecretsManager, mockAthena, mockFactory);
spillReader = new S3BlockSpillReader(amazonS3, allocator);
logger.info("setUpBefore - exit");
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project aws-athena-query-federation by awslabs.
the class SnowflakeMetadataHandlerTest method setup.
@Before
public void setup() {
environmentVariables.set("pagecount", "300000");
environmentVariables.set("partitionlimit", "300000");
this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class, Mockito.RETURNS_DEEP_STUBS);
this.connection = Mockito.mock(Connection.class, Mockito.RETURNS_DEEP_STUBS);
Mockito.when(this.jdbcConnectionFactory.getConnection(Mockito.any(JdbcCredentialProvider.class))).thenReturn(this.connection);
this.secretsManager = Mockito.mock(AWSSecretsManager.class);
this.athena = Mockito.mock(AmazonAthena.class);
Mockito.when(this.secretsManager.getSecretValue(Mockito.eq(new GetSecretValueRequest().withSecretId("testSecret")))).thenReturn(new GetSecretValueResult().withSecretString("{\"username\": \"testUser\", \"password\": \"testPassword\"}"));
this.snowflakeMetadataHandler = new SnowflakeMetadataHandler(databaseConnectionConfig, this.secretsManager, this.athena, this.jdbcConnectionFactory);
this.federatedIdentity = Mockito.mock(FederatedIdentity.class);
this.blockAllocator = Mockito.mock(BlockAllocator.class);
}
use of com.amazonaws.services.secretsmanager.model.GetSecretValueResult in project aws-athena-query-federation by awslabs.
the class SynapseMetadataHandlerTest method setup.
@Before
public void setup() {
System.setProperty("aws.region", "us-east-1");
this.jdbcConnectionFactory = Mockito.mock(JdbcConnectionFactory.class, Mockito.RETURNS_DEEP_STUBS);
this.connection = Mockito.mock(Connection.class, Mockito.RETURNS_DEEP_STUBS);
logger.info(" this.connection.." + this.connection);
Mockito.when(this.jdbcConnectionFactory.getConnection(Mockito.any(JdbcCredentialProvider.class))).thenReturn(this.connection);
this.secretsManager = Mockito.mock(AWSSecretsManager.class);
this.athena = Mockito.mock(AmazonAthena.class);
Mockito.when(this.secretsManager.getSecretValue(Mockito.eq(new GetSecretValueRequest().withSecretId("testSecret")))).thenReturn(new GetSecretValueResult().withSecretString("{\"user\": \"testUser\", \"password\": \"testPassword\"}"));
this.synapseMetadataHandler = new SynapseMetadataHandler(databaseConnectionConfig, this.secretsManager, this.athena, this.jdbcConnectionFactory);
this.federatedIdentity = Mockito.mock(FederatedIdentity.class);
}
Aggregations