Skip to content

Commit

Permalink
[0.6.1-SNAPSHOT]
Browse files Browse the repository at this point in the history
Alias & Image empty value fixed
  • Loading branch information
GoodforGod committed Aug 25, 2023
1 parent 8e2b935 commit da2f9e0
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,10 @@ protected Optional<CassandraMetadata> findMetadata(@NotNull ExtensionContext con
@NotNull
protected CassandraConnection getConnectionForContainer(CassandraMetadata metadata,
@NotNull CassandraContainer<?> container) {
final String alias = Optional.ofNullable(metadata.networkAliasOrDefault())
.filter(a -> !a.isBlank())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final String alias = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.orElse(null);

return CassandraConnectionImpl.forContainer(container.getHost(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,10 @@ protected Optional<CockroachMetadata> findMetadata(@NotNull ExtensionContext con

@NotNull
protected JdbcConnection getConnectionForContainer(CockroachMetadata metadata, @NotNull CockroachContainer container) {
final String alias = Optional.ofNullable(metadata.networkAliasOrDefault())
.filter(a -> !a.isBlank())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final String alias = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.orElse(null);

return JdbcConnectionImpl.forJDBC(container.getJdbcUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,15 @@ private void setupBeforeAll(ExtensionContext context) {
.map(c -> c.getNetwork() == Network.SHARED)
.orElse(metadata.networkShared());

var networkAlias = metadata.networkAlias();
var sharedKey = new SharedKey(imageShared, networkShared, networkAlias);
var networkAlias = containerFromField.map(c -> c.getNetworkAliases())
.filter(a -> !a.isEmpty())
.map(a -> a.stream()
.filter(alias -> alias.equals(metadata.networkAlias()))
.findFirst()
.orElse(a.get(0)))
.orElse(metadata.networkAlias());

var sharedKey = new SharedKey(imageShared, networkShared, networkAlias);
var sharedContainerMap = CLASS_TO_SHARED_CONTAINERS.computeIfAbsent(getClass().getCanonicalName(),
k -> new ConcurrentHashMap<>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,10 @@ protected KafkaConnection getConnectionForContainer(KafkaMetadata metadata, Kafk
final Properties properties = new Properties();
properties.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, container.getBootstrapServers());

final Properties networkProperties = Optional.ofNullable(metadata.networkAliasOrDefault())
.filter(a -> !a.isBlank())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final Properties networkProperties = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.map(alias -> {
final Properties props = new Properties();
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ protected Optional<MariadbMetadata> findMetadata(@NotNull ExtensionContext conte

@NotNull
protected JdbcConnection getConnectionForContainer(MariadbMetadata metadata, @NotNull MariaDBContainer<?> container) {
final String alias = Optional.ofNullable(metadata.networkAliasOrDefault())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final String alias = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.orElse(null);

return JdbcConnectionImpl.forJDBC(container.getJdbcUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,10 @@ protected Optional<MysqlMetadata> findMetadata(@NotNull ExtensionContext context

@NotNull
protected JdbcConnection getConnectionForContainer(MysqlMetadata metadata, @NotNull MySQLContainer<?> container) {
final String alias = Optional.ofNullable(metadata.networkAliasOrDefault())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final String alias = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.orElse(null);

return JdbcConnectionImpl.forJDBC(container.getJdbcUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ protected Optional<OracleMetadata> findMetadata(@NotNull ExtensionContext contex

@NotNull
protected JdbcConnection getConnectionForContainer(OracleMetadata metadata, @NotNull OracleContainer container) {
final String alias = Optional.ofNullable(metadata.networkAliasOrDefault())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final String alias = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.orElse(null);

return JdbcConnectionImpl.forJDBC(container.getJdbcUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ protected Optional<PostgresMetadata> findMetadata(@NotNull ExtensionContext cont

@NotNull
protected JdbcConnection getConnectionForContainer(PostgresMetadata metadata, @NotNull PostgreSQLContainer<?> container) {
final String alias = Optional.ofNullable(metadata.networkAliasOrDefault())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final String alias = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.orElse(null);

return JdbcConnectionImpl.forJDBC(container.getJdbcUrl(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ protected Optional<RedisMetadata> findMetadata(@NotNull ExtensionContext context

@NotNull
protected RedisConnection getConnectionForContainer(RedisMetadata metadata, @NotNull RedisContainer container) {
final String alias = Optional.ofNullable(metadata.networkAliasOrDefault())
.or(() -> (container.getNetworkAliases().isEmpty())
? Optional.empty()
: Optional.of(container.getNetworkAliases().get(container.getNetworkAliases().size() - 1)))
final String alias = container.getNetworkAliases().stream()
.filter(a -> a.equals(metadata.networkAliasOrDefault()))
.findFirst()
.or(() -> container.getNetworkAliases().stream().findFirst())
.orElse(null);

return RedisConnectionImpl.forContainer(container.getHost(),
Expand Down

0 comments on commit da2f9e0

Please sign in to comment.