|
| 1 | +/*- |
| 2 | + * #%L |
| 3 | + * athena-redshift |
| 4 | + * %% |
| 5 | + * Copyright (C) 2019 - 2025 Amazon Web Services |
| 6 | + * %% |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * you may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + * #L% |
| 19 | + */ |
| 20 | +package com.amazonaws.athena.connectors.redshift; |
| 21 | + |
| 22 | +import org.junit.Before; |
| 23 | +import org.junit.Test; |
| 24 | + |
| 25 | +import java.util.HashMap; |
| 26 | +import java.util.Map; |
| 27 | + |
| 28 | +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.DATABASE; |
| 29 | +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.DEFAULT; |
| 30 | +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.HOST; |
| 31 | +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.PORT; |
| 32 | +import static com.amazonaws.athena.connector.lambda.connection.EnvironmentConstants.SECRET_NAME; |
| 33 | +import static org.junit.Assert.assertEquals; |
| 34 | + |
| 35 | +public class RedshiftEnvironmentPropertiesTest { |
| 36 | + private static final String TEST_HOST = "redshift-cluster-endpoint"; |
| 37 | + private static final String TEST_DATABASE = "testdb"; |
| 38 | + private static final String TEST_SECRET = "redshift-secret"; |
| 39 | + private static final String TEST_PORT = "5436"; |
| 40 | + private static final String EXPECTED_CONNECTION_STRING = "redshift://jdbc:redshift://redshift-cluster-endpoint:5436/testdb?${redshift-secret}"; |
| 41 | + |
| 42 | + private Map<String, String> connectionProperties; |
| 43 | + private RedshiftEnvironmentProperties redshiftEnvironmentProperties; |
| 44 | + |
| 45 | + @Before |
| 46 | + public void setUp() { |
| 47 | + connectionProperties = new HashMap<>(); |
| 48 | + connectionProperties.put(HOST, TEST_HOST); |
| 49 | + connectionProperties.put(DATABASE, TEST_DATABASE); |
| 50 | + connectionProperties.put(SECRET_NAME, TEST_SECRET); |
| 51 | + connectionProperties.put(PORT, TEST_PORT); |
| 52 | + redshiftEnvironmentProperties = new RedshiftEnvironmentProperties(); |
| 53 | + } |
| 54 | + |
| 55 | + @Test |
| 56 | + public void redshiftConnectionPropertiesTest() { |
| 57 | + Map<String, String> redshiftConnectionProperties = redshiftEnvironmentProperties.connectionPropertiesToEnvironment(connectionProperties); |
| 58 | + |
| 59 | + assertEquals(EXPECTED_CONNECTION_STRING, redshiftConnectionProperties.get(DEFAULT)); |
| 60 | + } |
| 61 | +} |
0 commit comments