Search in sources :

Example 31 with ScopeInfo

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);
}
Also used : ScopeInfo(org.dbflute.util.Srl.ScopeInfo)

Example 32 with ScopeInfo

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());
}
Also used : ScopeInfo(org.dbflute.util.Srl.ScopeInfo)

Example 33 with ScopeInfo

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());
}
Also used : ScopeInfo(org.dbflute.util.Srl.ScopeInfo)

Example 34 with ScopeInfo

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());
}
Also used : ScopeInfo(org.dbflute.util.Srl.ScopeInfo)

Example 35 with ScopeInfo

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());
}
Also used : ScopeInfo(org.dbflute.util.Srl.ScopeInfo)

Aggregations

ScopeInfo (org.dbflute.util.Srl.ScopeInfo)42 File (java.io.File)7 ArrayList (java.util.ArrayList)7 Map (java.util.Map)7 LinkedHashMap (java.util.LinkedHashMap)6 List (java.util.List)6 FileTextIO (org.dbflute.helper.filesystem.FileTextIO)6 FileInputStream (java.io.FileInputStream)4 FileNotFoundException (java.io.FileNotFoundException)4 LinkedHashSet (java.util.LinkedHashSet)4 IOException (java.io.IOException)3 Arrays (java.util.Arrays)3 Set (java.util.Set)3 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)3 DateTimeFormatter (java.time.format.DateTimeFormatter)2 TemporalAccessor (java.time.temporal.TemporalAccessor)2 DfBuildProperties (org.dbflute.DfBuildProperties)2 DfIllegalPropertySettingException (org.dbflute.exception.DfIllegalPropertySettingException)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 FileHierarchyTracer (org.dbflute.helper.filesystem.FileHierarchyTracer)2