Skip to content

Commit

Permalink
#761 - fixed tests issues with mongo starting without any JDBC/rdbms
Browse files Browse the repository at this point in the history
  • Loading branch information
grabdoc committed Nov 4, 2024
1 parent c9e2dca commit fb57ad0
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ build/

### VS Code ###
.vscode/

## jte ##
/jte-classes/**
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,10 @@ public DataSource dataSource() {
private Map<Object, Object> buildDataSources() {
final Map<Object, Object> result = new HashMap<>();

if(Objects.isNull(databaseProperties.getDatabases())) {
log.info("*** No database configured.");
log.info("Databases - {}", databaseProperties.getDatabases());

if(databaseProperties.isRdbmsConfigured()) {
log.info("*** No RDBMS configured.");
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ public boolean isMongo() {
}

public boolean isJdbcPresent() {
return StringUtils.isNoneBlank(url);
return StringUtils.isNoneBlank(url)
&& !StringUtils.equalsIgnoreCase(url, "${DB_URL}");
}

public boolean includeAllSchemas() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@

import lombok.Data;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Objects;
import java.util.Optional;

@Data
@Component
@ConfigurationProperties(prefix = "app")
@Slf4j
public class DatabaseProperties {


Expand All @@ -23,4 +26,16 @@ public Optional<DatabaseConnectionDetail> getDatabase(String dbId) {
.filter(databaseConnectionDetail -> StringUtils.equalsIgnoreCase(dbId, databaseConnectionDetail.id()))
.findFirst();
}

public boolean isRdbmsConfigured() {
if(Objects.isNull(databases)) {
log.info("*** No RDBMS configured.");
return false;
}

return databases.stream()
.anyMatch(DatabaseConnectionDetail::isJdbcPresent);


}
}

0 comments on commit fb57ad0

Please sign in to comment.