MultiDataSourceProperties.java

1
package org.cardanofoundation.explorer.api.config.datasource;
2
3
import javax.sql.DataSource;
4
5
import lombok.AccessLevel;
6
import lombok.Data;
7
import lombok.Getter;
8
import lombok.Setter;
9
import lombok.experimental.FieldDefaults;
10
11
import org.springframework.boot.autoconfigure.flyway.FlywayProperties;
12
import org.springframework.boot.context.properties.ConfigurationProperties;
13
import org.springframework.context.annotation.Configuration;
14
15
import com.zaxxer.hikari.HikariConfig;
16
import com.zaxxer.hikari.HikariDataSource;
17
import org.flywaydb.core.Flyway;
18
19
@Getter
20
@Setter
21
@FieldDefaults(level = AccessLevel.PRIVATE)
22
@Configuration
23
@ConfigurationProperties(prefix = "multi-datasource")
24
public class MultiDataSourceProperties {
25
26 1 1. getDatasourceLedgerSync : replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::getDatasourceLedgerSync → NO_COVERAGE
  DataSourceConfig datasourceLedgerSync;
27 1 1. getDatasourceLedgerSyncAgg : replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::getDatasourceLedgerSyncAgg → NO_COVERAGE
  DataSourceConfig datasourceLedgerSyncAgg;
28 1 1. getDatasourceExplorer : replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::getDatasourceExplorer → NO_COVERAGE
  DataSourceConfig datasourceExplorer;
29
30 25 1. hashCode : Replaced integer multiplication with division → NO_COVERAGE
2. canEqual : replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::canEqual → NO_COVERAGE
3. hashCode : Replaced integer multiplication with division → NO_COVERAGE
4. canEqual : replaced boolean return with false for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::canEqual → NO_COVERAGE
5. equals : negated conditional → NO_COVERAGE
6. equals : replaced boolean return with false for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE
7. equals : negated conditional → NO_COVERAGE
8. equals : negated conditional → NO_COVERAGE
9. equals : negated conditional → NO_COVERAGE
10. equals : negated conditional → NO_COVERAGE
11. equals : replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE
12. hashCode : Replaced integer addition with subtraction → NO_COVERAGE
13. equals : negated conditional → NO_COVERAGE
14. equals : replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE
15. hashCode : replaced int return with 0 for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::hashCode → NO_COVERAGE
16. toString : replaced return value with "" for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::toString → NO_COVERAGE
17. hashCode : negated conditional → NO_COVERAGE
18. equals : negated conditional → NO_COVERAGE
19. hashCode : Replaced integer addition with subtraction → NO_COVERAGE
20. equals : negated conditional → NO_COVERAGE
21. equals : negated conditional → NO_COVERAGE
22. equals : replaced boolean return with false for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE
23. equals : replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE
24. hashCode : negated conditional → NO_COVERAGE
25. equals : replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE
  @Data
31
  @FieldDefaults(level = AccessLevel.PRIVATE)
32
  public static class DataSourceConfig {
33 1 1. getHikariConfig : replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::getHikariConfig → NO_COVERAGE
    HikariConfig hikariConfig;
34 1 1. getFlyway : replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::getFlyway → NO_COVERAGE
    FlywayProperties flyway;
35
  }
36
37
  public DataSource buildDataSource(DataSourceConfig dataSourceConfig) {
38
    HikariDataSource hikariDataSource = new HikariDataSource(dataSourceConfig.getHikariConfig());
39
    FlywayProperties flywayProperties = dataSourceConfig.getFlyway();
40 2 1. buildDataSource : negated conditional → NO_COVERAGE
2. buildDataSource : negated conditional → NO_COVERAGE
    if (flywayProperties != null && flywayProperties.isEnabled()) {
41
      Flyway.configure()
42
          .dataSource(hikariDataSource)
43
          .locations(flywayProperties.getLocations().toArray(new String[0]))
44
          .sqlMigrationPrefix(flywayProperties.getSqlMigrationPrefix())
45
          .sqlMigrationSeparator(flywayProperties.getSqlMigrationSeparator())
46
          .sqlMigrationSuffixes(flywayProperties.getSqlMigrationSuffixes().toArray(new String[0]))
47
          .group(flywayProperties.isGroup())
48
          .defaultSchema(flywayProperties.getDefaultSchema())
49
          .schemas(flywayProperties.getSchemas().toArray(new String[0]))
50
          .validateOnMigrate(flywayProperties.isValidateOnMigrate())
51
          .outOfOrder(flywayProperties.isOutOfOrder())
52
          .load()
53
          .migrate();
54
    }
55 1 1. buildDataSource : replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::buildDataSource → NO_COVERAGE
    return hikariDataSource;
56
  }
57
}

Mutations

26

1.1
Location : getDatasourceLedgerSync
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::getDatasourceLedgerSync → NO_COVERAGE

27

1.1
Location : getDatasourceLedgerSyncAgg
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::getDatasourceLedgerSyncAgg → NO_COVERAGE

28

1.1
Location : getDatasourceExplorer
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::getDatasourceExplorer → NO_COVERAGE

30

1.1
Location : hashCode
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

2.2
Location : canEqual
Killed by : none
replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::canEqual → NO_COVERAGE

3.3
Location : hashCode
Killed by : none
Replaced integer multiplication with division → NO_COVERAGE

4.4
Location : canEqual
Killed by : none
replaced boolean return with false for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::canEqual → NO_COVERAGE

5.5
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

6.6
Location : equals
Killed by : none
replaced boolean return with false for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE

7.7
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

8.8
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

9.9
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

10.10
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

11.11
Location : equals
Killed by : none
replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE

12.12
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

13.13
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

14.14
Location : equals
Killed by : none
replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE

15.15
Location : hashCode
Killed by : none
replaced int return with 0 for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::hashCode → NO_COVERAGE

16.16
Location : toString
Killed by : none
replaced return value with "" for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::toString → NO_COVERAGE

17.17
Location : hashCode
Killed by : none
negated conditional → NO_COVERAGE

18.18
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

19.19
Location : hashCode
Killed by : none
Replaced integer addition with subtraction → NO_COVERAGE

20.20
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

21.21
Location : equals
Killed by : none
negated conditional → NO_COVERAGE

22.22
Location : equals
Killed by : none
replaced boolean return with false for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE

23.23
Location : equals
Killed by : none
replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE

24.24
Location : hashCode
Killed by : none
negated conditional → NO_COVERAGE

25.25
Location : equals
Killed by : none
replaced boolean return with true for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::equals → NO_COVERAGE

33

1.1
Location : getHikariConfig
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::getHikariConfig → NO_COVERAGE

34

1.1
Location : getFlyway
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties$DataSourceConfig::getFlyway → NO_COVERAGE

40

1.1
Location : buildDataSource
Killed by : none
negated conditional → NO_COVERAGE

2.2
Location : buildDataSource
Killed by : none
negated conditional → NO_COVERAGE

55

1.1
Location : buildDataSource
Killed by : none
replaced return value with null for org/cardanofoundation/explorer/api/config/datasource/MultiDataSourceProperties::buildDataSource → NO_COVERAGE

Active mutators

Tests examined


Report generated by PIT 1.14.2