Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.persist.core

File DataSourceConfigurations.java

 

Coverage histogram

../../../../img/srcFileCovDistChart5.png
36% of files have more coverage

Code metrics

4
16
6
1
44
36
11
0.69
2.67
6
1.83

Classes

Class Line # Actions
DataSourceConfigurations 5 16 11
0.4615384646.2%
 

Contributing tests

This file is covered by 2 tests. .

Source view

1    package io.sunshower.persist.core;
2   
3    import com.zaxxer.hikari.HikariConfig;
4   
 
5    public class DataSourceConfigurations {
6   
 
7  0 toggle public static HikariConfig toNative(DatabaseConfigurationSource source) {
8  0 final HikariConfig cfg = new HikariConfig();
9  0 cfg.setJdbcUrl(source.url());
10  0 cfg.setUsername(source.username());
11  0 cfg.setPassword(source.password());
12  0 cfg.setDriverClassName(source.driverClass());
13  0 return cfg;
14    }
15   
 
16  1 toggle static boolean isBaseline(DatabaseConfigurationSource source) {
17  1 String version = source.version();
18  1 return source.baseline()
19    && !(version == null || version.trim().isEmpty() || "-1".equals(version));
20    }
21   
 
22  2 toggle static boolean useLocation(DatabaseConfigurationSource source) {
23  2 return nullOrEmpty(source.jndiPath());
24    }
25   
 
26  3 toggle public static boolean nullOrEmpty(String value) {
27  3 if (value == null || value.trim().equals("") || value.trim().toLowerCase().equals("empty")) {
28  3 return true;
29    }
30  0 return false;
31    }
32   
 
33  1 toggle public static void validate(DatabaseConfigurationSource source) {
34  1 if (!(nullOrEmpty(source.jndiPath()) || nullOrEmpty(source.username()))) {
35  0 throw new IllegalStateException("Only one of jndi-path or username may be set");
36    }
37    }
38   
 
39  0 toggle public static boolean isBaselineVersion(DatabaseConfigurationSource source) {
40  0 String version = source.version();
41  0 return source.baseline()
42    && !(version == null || version.trim().isEmpty() || "-1".equals(version));
43    }
44    }