99import org .springframework .beans .factory .annotation .Autowired ;
1010import org .springframework .beans .factory .annotation .Value ;
1111import org .springframework .stereotype .Service ;
12+ import org .springframework .util .CollectionUtils ;
1213import org .springframework .util .StringUtils ;
1314
1415import jakarta .annotation .Resource ;
1516import javax .naming .ConfigurationException ;
1617import java .sql .*;
17- import java .util .ArrayList ;
18- import java .util .Arrays ;
19- import java .util .Collection ;
20- import java .util .List ;
18+ import java .util .*;
2119import java .util .concurrent .*;
2220import java .util .regex .Pattern ;
2321
2624public class AssertionExecutionService {
2725
2826 private static final String FAILED_TO_FIND_RVF_DB_SCHEMA = "Failed to find rvf db schema for " ;
27+ private static final String NOT_SUPPLIED = "NOT_SUPPLIED" ;
28+
2929 @ Autowired
3030 private AssertionService assertionService ;
3131 @ Resource (name = "dataSource" )
@@ -232,19 +232,14 @@ private List<String> transformSql(List<String> parts, Assertion assertion, Mysql
232232 String prospectiveSchema = config .getProspectiveVersion ();
233233 final String [] nameParts = config .getProspectiveVersion ().split ("_" );
234234 String defaultModuleId = StringUtils .hasLength (config .getDefaultModuleId ()) ? config .getDefaultModuleId () : getModuleId (nameParts );
235- String includedModules = String .join ("," , config .getIncludedModules ());
236- String version = (nameParts .length >= 3 ? nameParts [2 ] : " NOT_SUPPLIED" );
235+ String includedModules = CollectionUtils . isEmpty ( config . getIncludedModules ()) ? "NULL" : String .join ("," , config .getIncludedModules ());
236+ String version = (nameParts .length >= 3 ? nameParts [2 ] : NOT_SUPPLIED );
237237
238238 String previousReleaseSchema = config .getPreviousVersion ();
239239 String dependencyReleaseSchema = config .getExtensionDependencyVersion ();
240240 validateSchemas (config , prospectiveSchema , previousReleaseSchema );
241241
242242 for ( String part : parts ) {
243- if ((part .contains ("<PREVIOUS>" ) && previousReleaseSchema == null )
244- || (part .contains ("<DEPENDENCY>" ) && dependencyReleaseSchema == null )) {
245- continue ;
246- }
247-
248243 logger .debug ("Original sql statement: {}" , part );
249244 final Pattern commentPattern = Pattern .compile ("/\\ *.*?\\ */" , Pattern .DOTALL );
250245 part = commentPattern .matcher (part ).replaceAll ("" );
@@ -259,12 +254,8 @@ private List<String> transformSql(List<String> parts, Assertion assertion, Mysql
259254 part = part .replace ("<PROSPECTIVE>" , prospectiveSchema );
260255 part = part .replace ("<TEMP>" , prospectiveSchema );
261256 part = part .replace ("<INTERNATIONAL_MODULES>" , internationalModules );
262- if (previousReleaseSchema != null ) {
263- part = part .replace ("<PREVIOUS>" , previousReleaseSchema );
264- }
265- if (dependencyReleaseSchema != null ) {
266- part = part .replace ("<DEPENDENCY>" , dependencyReleaseSchema );
267- }
257+ part = part .replace ("<PREVIOUS>" , previousReleaseSchema );
258+ part = part .replace ("<DEPENDENCY>" , dependencyReleaseSchema );
268259 part = part .replace ("<DELTA>" , DELTA_TABLE_SUFFIX );
269260 part = part .replace ("<SNAPSHOT>" , SNAPSHOT_TABLE_SUFFIX );
270261 part = part .replace ("<FULL>" , FULL_TABLE_SUFFIX );
@@ -276,7 +267,7 @@ private List<String> transformSql(List<String> parts, Assertion assertion, Mysql
276267 }
277268
278269 private static String getModuleId (String [] nameParts ) {
279- return nameParts .length >= 2 ? ProductName .toModuleId (nameParts [1 ]) : " NOT_SUPPLIED" ;
270+ return nameParts .length >= 2 ? ProductName .toModuleId (nameParts [1 ]) : NOT_SUPPLIED ;
280271 }
281272
282273 private static void validateSchemas (MysqlExecutionConfig config , String prospectiveSchema , String previousReleaseSchema ) throws ConfigurationException {
0 commit comments