|
1 | 1 | package io.airbyte.integrations.destination.mysql;
|
2 | 2 |
|
| 3 | +import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; |
3 | 4 | import static org.junit.jupiter.api.Assertions.assertEquals;
|
4 | 5 | import static org.junit.jupiter.api.Assertions.assertThrows;
|
5 | 6 | import static org.mockito.Mockito.spy;
|
6 | 7 |
|
7 | 8 | import com.fasterxml.jackson.databind.JsonNode;
|
8 | 9 | import com.google.common.collect.ImmutableMap;
|
9 | 10 | import io.airbyte.commons.json.Jsons;
|
| 11 | +import io.airbyte.commons.map.MoreMaps; |
| 12 | +import java.util.Map; |
10 | 13 | import java.util.Map.Entry;
|
11 | 14 | import org.junit.jupiter.api.Test;
|
12 | 15 |
|
@@ -87,17 +90,19 @@ void testExtraParams() {
|
87 | 90 |
|
88 | 91 | @Test
|
89 | 92 | void testExtraParamsWithDefaultParameter() {
|
90 |
| - for (final Entry<String, String> entry : MySQLDestination.SSL_JDBC_PARAMETERS.entrySet()) { |
91 |
| - final String extraParam = MySQLDestination.formatParameter(entry.getKey(), entry.getValue()); |
92 |
| - assertThrows(RuntimeException.class, () -> |
93 |
| - getDestination().toJdbcConfig(buildConfigWithExtraJdbcParameters(extraParam)) |
| 93 | + final Map<String, String> allDefaultParameters = MoreMaps.merge(MySQLDestination.SSL_JDBC_PARAMETERS, |
| 94 | + MySQLDestination.DEFAULT_JDBC_PARAMETERS); |
| 95 | + for (final Entry<String, String> entry : allDefaultParameters.entrySet()) { |
| 96 | + final String identicalParameter = MySQLDestination.formatParameter(entry.getKey(), entry.getValue()); |
| 97 | + final String overridingParameter = MySQLDestination.formatParameter(entry.getKey(), "DIFFERENT_VALUE"); |
| 98 | + |
| 99 | + // Do not throw an exception if the values are equal |
| 100 | + assertDoesNotThrow(() -> |
| 101 | + getDestination().toJdbcConfig(buildConfigWithExtraJdbcParameters(identicalParameter)).get("jdbc_url").asText() |
94 | 102 | );
|
95 |
| - } |
96 |
| - |
97 |
| - for (final Entry<String, String> entry : MySQLDestination.DEFAULT_JDBC_PARAMETERS.entrySet()) { |
98 |
| - final String extraParam = MySQLDestination.formatParameter(entry.getKey(), entry.getValue()); |
| 103 | + // Throw an exception if the values are different |
99 | 104 | assertThrows(RuntimeException.class, () ->
|
100 |
| - getDestination().toJdbcConfig(buildConfigWithExtraJdbcParameters(extraParam)) |
| 105 | + getDestination().toJdbcConfig(buildConfigWithExtraJdbcParameters(overridingParameter)) |
101 | 106 | );
|
102 | 107 | }
|
103 | 108 | }
|
|
0 commit comments