Skip to content

Commit d7d9542

Browse files
authored
Merge pull request #43 from EMResearch/refactor-db
refactor handling of DB
2 parents 4b2a5f3 + 6c54d07 commit d7d9542

39 files changed

Lines changed: 45 additions & 374 deletions

File tree

jdk_11_gradle/em/embedded/graphql/patio-api/src/main/java/em/embedded/patio/EmbeddedEvoMasterController.java

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,9 @@ public String startSut() {
9494
throw new RuntimeException(e);
9595
}
9696

97-
dbSpecification = Arrays.asList(new DbSpecification(){{
98-
dbType = DatabaseType.POSTGRES;
99-
schemaNames = Arrays.asList("public");
100-
// initSqlOnResourcePath = "/initDb.sql";
101-
connection = sqlConnection;
102-
employSmartDbClean = false;
103-
}});
97+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.POSTGRES,sqlConnection)
98+
.withSchemas("public").withDisabledSmartClean());
99+
// initSqlOnResourcePath = "/initDb.sql";
104100

105101
return "http://localhost:" + getSutPort();
106102
}
@@ -163,14 +159,9 @@ public List<AuthenticationDto> getInfoForAuthentication() {
163159
return List.of(dto);
164160
}
165161

166-
public Connection getConnection() {
167-
return sqlConnection;
168-
}
169162

170-
@Override
171-
public String getDatabaseDriverName() {
172-
return "org.postgresql.Driver";
173-
}
163+
164+
174165

175166
public List<DbSpecification> getDbSpecifications() {
176167
return dbSpecification;

jdk_11_gradle/em/external/graphql/patio-api/src/main/java/em/external/patio/ExternalEvoMasterController.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,11 @@ public void postStart() {
151151
closeDataBaseConnection();
152152

153153
try {
154-
Class.forName(getDatabaseDriverName());
155154
sqlConnection = DriverManager.getConnection(dbUrl(), "patio", "patio");
156-
dbSpecification = Arrays.asList(new DbSpecification(){{
157-
dbType = DatabaseType.POSTGRES;
158-
schemaNames = Arrays.asList("public");
159-
// initSqlOnResourcePath = "/initDb.sql";
160-
connection = sqlConnection;
161-
employSmartDbClean = false;
162-
}});
155+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.POSTGRES,sqlConnection)
156+
.withSchemas("public").withDisabledSmartClean());
157+
// initSqlOnResourcePath = "/initDb.sql";
158+
163159
} catch (Exception e) {
164160
throw new RuntimeException(e);
165161
}
@@ -207,15 +203,7 @@ public SutInfoDto.OutputFormat getPreferredOutputFormat() {
207203
return SutInfoDto.OutputFormat.JAVA_JUNIT_5;
208204
}
209205

210-
@Override
211-
public Connection getConnection() {
212-
return sqlConnection;
213-
}
214206

215-
@Override
216-
public String getDatabaseDriverName() {
217-
return "org.postgresql.Driver";
218-
}
219207

220208
@Override
221209
public List<AuthenticationDto> getInfoForAuthentication() {

jdk_11_maven/em/embedded/graphql/timbuctoo/src/main/java/em/embedded/nl/knaw/huygens/EmbeddedEvoMasterController.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,6 @@ public List<AuthenticationDto> getInfoForAuthentication() {
173173
return List.of(AuthUtils.getForAuthorizationHeader("user", "u33707283d426f900d4d33707283d426f900d4d0d"));
174174
}
175175

176-
public Connection getConnection() {
177-
return null;
178-
}
179176

180177

181178
private void deleteDir(File file) {

jdk_11_maven/em/embedded/rest/cwa-verification/src/main/java/em/embedded/app/coronawarn/verification/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,7 @@ public String startSut() {
7979
}
8080

8181
// need to check tablesToSkip with DATABASECHANGELOG
82-
dbSpecification = Arrays.asList(new DbSpecification(){{
83-
dbType = DatabaseType.H2;
84-
connection = sqlConnection;
85-
}});
82+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection));
8683

8784
return "http://localhost:" + getSutPort();
8885
}
@@ -136,9 +133,6 @@ public List<AuthenticationDto> getInfoForAuthentication() {
136133
return null;
137134
}
138135

139-
public Connection getConnection() {
140-
return sqlConnection;
141-
}
142136

143137

144138
@Override

jdk_11_maven/em/external/graphql/timbuctoo/src/main/java/em/external/nl/knaw/huygens/ExternalEvoMasterController.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,7 @@ public List<AuthenticationDto> getInfoForAuthentication() {
223223
return List.of(AuthUtils.getForAuthorizationHeader("user", "u33707283d426f900d4d33707283d426f900d4d0d"));
224224
}
225225

226-
@Override
227-
public Connection getConnection() {
228-
return null;
229-
}
226+
230227

231228
@Override
232229
public List<DbSpecification> getDbSpecifications() {

jdk_11_maven/em/external/rest/cwa-verification/src/main/java/em/external/app/coronawarn/verification/ExternalEvoMasterController.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,7 @@ public void postStart() {
147147
try {
148148
Class.forName("org.h2.Driver");
149149
sqlConnection = DriverManager.getConnection(dbUrl(), "sa", "");
150-
dbSpecification = Arrays.asList(new DbSpecification(){{
151-
dbType = DatabaseType.H2;
152-
connection = sqlConnection;
153-
}});
150+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection));
154151
} catch (Exception e) {
155152
throw new RuntimeException(e);
156153
}
@@ -212,10 +209,7 @@ public List<AuthenticationDto> getInfoForAuthentication() {
212209
return null;
213210
}
214211

215-
@Override
216-
public Connection getConnection() {
217-
return sqlConnection;
218-
}
212+
219213

220214
@Override
221215
public List<DbSpecification> getDbSpecifications() {

jdk_8_maven/em/embedded/graphql/graphql-ncs/src/main/java/em/embedded/org/graphqlncs/EmbeddedEvoMasterController.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -96,14 +96,6 @@ public List<AuthenticationDto> getInfoForAuthentication() {
9696
return null;
9797
}
9898

99-
public Connection getConnection() {
100-
return null;
101-
}
102-
103-
@Override
104-
public String getDatabaseDriverName() {
105-
return null;
106-
}
10799

108100
@Override
109101
public List<DbSpecification> getDbSpecifications() {

jdk_8_maven/em/embedded/graphql/graphql-scs/src/main/java/em/embedded/org/graphqlscs/EmbeddedEvoMasterController.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,6 @@ public List<AuthenticationDto> getInfoForAuthentication() {
9494
return null;
9595
}
9696

97-
public Connection getConnection() {
98-
return null;
99-
}
100-
101-
@Override
102-
public String getDatabaseDriverName() {
103-
return null;
104-
}
105-
10697
@Override
10798
public List<DbSpecification> getDbSpecifications() {
10899
return null;

jdk_8_maven/em/embedded/graphql/spring-petclinic-graphql/src/main/java/em/embedded/org/springframework/samples/petclinic/EmbeddedEvoMasterController.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,8 @@ public String startSut() {
9292

9393

9494

95-
dbSpecification = Arrays.asList(new DbSpecification(){{
96-
dbType = DatabaseType.POSTGRES;
97-
connection = sqlConnection;
98-
schemaNames = Arrays.asList("public");
99-
//initSqlOnResourcePath = "/db/postgresql/populateDB.sql";
100-
employSmartDbClean = false;
101-
}});
95+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.POSTGRES,sqlConnection)
96+
.withSchemas("public").withDisabledSmartClean());
10297

10398
SqlScriptRunnerCached.runScriptFromResourceFile(sqlConnection,"/db/postgresql/initDB.sql");
10499

@@ -150,14 +145,6 @@ public List<AuthenticationDto> getInfoForAuthentication() {
150145
return null;
151146
}
152147

153-
public Connection getConnection() {
154-
return sqlConnection;
155-
}
156-
157-
@Override
158-
public String getDatabaseDriverName() {
159-
return "org.postgresql.Driver";
160-
}
161148

162149
@Override
163150
public List<DbSpecification> getDbSpecifications() {

jdk_8_maven/em/embedded/rest/catwatch/src/main/java/em/embedded/org/zalando/EmbeddedEvoMasterController.java

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,7 @@ public String startSut() {
7878
} catch (SQLException e) {
7979
throw new RuntimeException(e);
8080
}
81-
dbSpecification = Arrays.asList(new DbSpecification(){{
82-
dbType = DatabaseType.H2;
83-
connection = sqlConnection;
84-
}});
81+
dbSpecification = Arrays.asList(new DbSpecification(DatabaseType.H2,sqlConnection));
8582

8683
return "http://localhost:" + getSutPort();
8784
}
@@ -134,14 +131,6 @@ public List<AuthenticationDto> getInfoForAuthentication() {
134131
return null;
135132
}
136133

137-
public Connection getConnection() {
138-
return sqlConnection;
139-
}
140-
141-
@Override
142-
public String getDatabaseDriverName() {
143-
return "org.h2.Driver";
144-
}
145134

146135
@Override
147136
public List<DbSpecification> getDbSpecifications() {

0 commit comments

Comments
 (0)