use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfCraftDiffAssertProvider method processTableEquals.
protected DfCraftDiffAssertHandler processTableEquals(File sqlFile, String plainSql, final String resolvedSql) {
// space after '--' has been resolved here
final String keyPrefix = "--#df:assertTableEquals(";
final String keySuffix = ")#";
final ScopeInfo scopeFirst = Srl.extractScopeFirst(resolvedSql, keyPrefix, keySuffix);
if (scopeFirst == null) {
// not found
return null;
}
final String args = scopeFirst.getContent().trim();
if (Srl.is_Null_or_TrimmedEmpty(args)) {
throwCraftDiffCraftTitleNotFoundException(sqlFile, plainSql);
}
final List<String> argList = Srl.splitListTrimmed(args, ",");
if (argList.size() < 2) {
throwCraftDiffTableEqualsParameterNotFound(sqlFile, resolvedSql, argList);
}
final String craftTitle = argList.get(0);
final String tableHint = argList.get(1);
final String exceptExp = argList.size() > 2 ? argList.get(2) : null;
// *unsupported envType on assert definition
return createTableEqualsAssertHandler(craftTitle, tableHint, exceptExp);
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfStringUtilTest method test_extractScopeList_replaceInterspaceOnBaseString.
public void test_extractScopeList_replaceInterspaceOnBaseString() {
// ## Arrange ##
String str = "/*foo*/foo/*bar*/bar/*foobarbaz*/";
// ## Act ##
List<ScopeInfo> list = extractScopeList(str, "/*", "*/");
// ## Assert ##
ScopeInfo scope = list.get(1);
String baseString1 = scope.replaceInterspaceOnBaseString("foo", "jflute");
assertEquals("/*foo*/jflute/*bar*/bar/*foobarbaz*/", baseString1);
String baseString2 = scope.replaceInterspaceOnBaseString("*", "jflute");
// marks no change
assertEquals(str, baseString2);
// no change
assertEquals(str, scope.getBaseString());
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfStringUtilTest method test_extractScopeList_nested.
public void test_extractScopeList_nested() {
// ## Arrange ##
String str = "sea(hangar(mystic)stage):land(showbase(oneman)stage)";
// ## Act ##
List<ScopeInfo> scopeList = extractScopeList(str, "(", ")");
// ## Assert ##
ScopeInfo first = scopeList.get(0);
ScopeInfo second = scopeList.get(1);
assertEquals("hangar(mystic", first.getContent());
assertEquals("showbase(oneman", second.getContent());
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfStringUtilTest method test_extractScopeList_basic.
public void test_extractScopeList_basic() {
// ## Arrange ##
String str = "sea:(hangar)mystic, land:(showbase)oneman";
// ## Act ##
List<ScopeInfo> list = extractScopeList(str, "(", ")");
// ## Assert ##
for (ScopeInfo scope : list) {
log("scope:");
log(" baseString: " + scope.getBaseString());
log(" beginIndex: " + scope.getBeginIndex());
log(" endIndex: " + scope.getEndIndex());
log(" beginMark: " + scope.getBeginMark());
log(" endMark: " + scope.getEndMark());
log(" content: " + scope.getContent());
log(" scope: " + scope.getScope());
log(" previous: " + scope.getPrevious());
log(" next: " + scope.getNext());
}
assertEquals(2, list.size());
ScopeInfo first = list.get(0);
ScopeInfo second = list.get(1);
assertEquals("hangar", first.getContent());
assertEquals("(hangar)", first.getScope());
assertNull(first.getPrevious());
assertEquals(second, first.getNext());
assertEquals("showbase", second.getContent());
assertEquals("(showbase)", second.getScope());
assertEquals(first, second.getPrevious());
assertNull(second.getNext());
assertEquals("sea:(stage)mystic, land:(stage)oneman", first.replaceContentOnBaseString("stage"));
assertEquals("sea:(hbngbr)mystic, land:(showbbse)oneman", first.replaceContentOnBaseString("a", "b"));
assertEquals("seb:(hangar)mystic, lbnd:(showbase)onembn", first.replaceInterspaceOnBaseString("a", "b"));
assertEquals("sea:", first.substringInterspaceToPrevious());
assertEquals("mystic, land:", first.substringInterspaceToNext());
assertEquals("sea:(hangar)", first.substringScopeToPrevious());
assertEquals("(hangar)mystic, land:(showbase)", first.substringScopeToNext());
assertEquals("sea:(stage)mystic, land:(stage)oneman", second.replaceContentOnBaseString("stage"));
assertEquals("sea:(hbngbr)mystic, land:(showbbse)oneman", second.replaceContentOnBaseString("a", "b"));
assertEquals("seb:(hangar)mystic, lbnd:(showbase)onembn", second.replaceInterspaceOnBaseString("a", "b"));
assertEquals("mystic, land:", second.substringInterspaceToPrevious());
assertEquals("oneman", second.substringInterspaceToNext());
assertEquals("(hangar)mystic, land:(showbase)", second.substringScopeToPrevious());
assertEquals("(showbase)oneman", second.substringScopeToNext());
}
use of org.dbflute.util.Srl.ScopeInfo in project dbflute-core by dbflute.
the class DfStringUtilTest method test_extractScopeList_crossed.
public void test_extractScopeList_crossed() {
// ## Arrange ##
String str = "sea(hangar)mystic):land(showbase)oneman)";
// ## Act ##
List<ScopeInfo> scopeList = extractScopeList(str, "(", ")");
// ## Assert ##
ScopeInfo first = scopeList.get(0);
ScopeInfo second = scopeList.get(1);
assertEquals("hangar", first.getContent());
assertEquals("showbase", second.getContent());
}
Aggregations