Search in sources :

Example 11 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnValueTypesTest method test_getValueType_byClassType_enum_priority_classification.

public void test_getValueType_byClassType_enum_priority_classification() throws Exception {
    // ## Arrange ##
    // embedded
    Class<?> keyType = TestClassificationStatus.class;
    MockValueType mockValueType = new MockValueType();
    // ## Act ##
    TnValueTypes.registerBasicValueType(_currentDBDef, TestPlainStatus.class, mockValueType);
    TnValueTypes.registerBasicValueType(_currentDBDef, Enum.class, mockValueType);
    ValueType valueType = TnValueTypes.getValueType(keyType);
    // ## Assert ##
    assertNotSame(mockValueType, valueType);
    assertEquals(TnValueTypes.CLASSIFICATION, valueType);
}
Also used : MockValueType(org.dbflute.mock.MockValueType) ValueType(org.dbflute.jdbc.ValueType) MockValueType(org.dbflute.mock.MockValueType)

Example 12 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnValueTypesTest method test_registerBasicValueType_interface_threadSafe.

public void test_registerBasicValueType_interface_threadSafe() throws Exception {
    // ## Arrange ##
    ExecutionCreator<ValueType> creator = new ExecutionCreator<ValueType>() {

        public Execution<ValueType> create() {
            return new Execution<ValueType>() {

                public ValueType execute() {
                    MockValueType mockValueType = new MockValueType();
                    if (Thread.currentThread().getId() % 2 == 0) {
                        TnValueTypes.registerBasicValueType(_currentDBDef, FilenameFilter.class, mockValueType);
                        ValueType interfaceValueType = TnValueTypes.findValueTypes(_currentDBDef).getBasicInterfaceValueType(FilenameFilter.class);
                        return interfaceValueType;
                    } else {
                        TnValueTypes.registerBasicValueType(_currentDBDef, FileFilter.class, mockValueType);
                        ValueType interfaceValueType = TnValueTypes.findValueTypes(_currentDBDef).getBasicInterfaceValueType(FileFilter.class);
                        return interfaceValueType;
                    }
                }
            };
        }
    };
    // ## Act & Assert ##
    fireSameExecution(creator);
}
Also used : MockValueType(org.dbflute.mock.MockValueType) ValueType(org.dbflute.jdbc.ValueType) MockValueType(org.dbflute.mock.MockValueType)

Example 13 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnValueTypesTest method test_getValueType_byInstance_enum_priority_classification.

public void test_getValueType_byInstance_enum_priority_classification() throws Exception {
    // ## Arrange ##
    MockValueType mockValueType = new MockValueType();
    // ## Act ##
    TnValueTypes.registerBasicValueType(_currentDBDef, TestPlainStatus.class, mockValueType);
    TnValueTypes.registerBasicValueType(_currentDBDef, Enum.class, mockValueType);
    ValueType valueType = TnValueTypes.getValueType(TestClassificationStatus.FML);
    // ## Assert ##
    assertNotSame(mockValueType, valueType);
    assertEquals(TnValueTypes.CLASSIFICATION, valueType);
}
Also used : MockValueType(org.dbflute.mock.MockValueType) ValueType(org.dbflute.jdbc.ValueType) MockValueType(org.dbflute.mock.MockValueType)

Example 14 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnValueTypesTest method test_registerBasicValueType_interface_basic.

public void test_registerBasicValueType_interface_basic() throws Exception {
    // ## Arrange ##
    MockValueType mockValueType = new MockValueType();
    // ## Act ##
    TnValueTypes.registerBasicValueType(_currentDBDef, FilenameFilter.class, mockValueType);
    ValueType interfaceValueType = TnValueTypes.findValueTypes(_currentDBDef).getBasicInterfaceValueType(FilenameFilter.class);
    // ## Assert ##
    assertEquals(mockValueType, interfaceValueType);
    assertNull(TnValueTypes.findValueTypes(_currentDBDef).getBasicInterfaceValueType(FileFilter.class));
}
Also used : MockValueType(org.dbflute.mock.MockValueType) ValueType(org.dbflute.jdbc.ValueType) MockValueType(org.dbflute.mock.MockValueType) FileFilter(java.io.FileFilter)

Example 15 with ValueType

use of org.dbflute.jdbc.ValueType in project dbflute-core by dbflute.

the class TnValueTypesTest method test_getValueType_byClassType_enum_priority_enumKey.

public void test_getValueType_byClassType_enum_priority_enumKey() throws Exception {
    // ## Arrange ##
    Class<?> keyType = Enum.class;
    MockValueType mockValueType = new MockValueType();
    // ## Act ##
    TnValueTypes.registerBasicValueType(_currentDBDef, keyType, mockValueType);
    ValueType valueType = TnValueTypes.getValueType(keyType);
    // ## Assert ##
    assertNotSame(TnValueTypes.CLASSIFICATION, valueType);
    assertEquals(mockValueType, valueType);
}
Also used : MockValueType(org.dbflute.mock.MockValueType) ValueType(org.dbflute.jdbc.ValueType) MockValueType(org.dbflute.mock.MockValueType)

Aggregations

ValueType (org.dbflute.jdbc.ValueType)35 MockValueType (org.dbflute.mock.MockValueType)8 LinkedHashMap (java.util.LinkedHashMap)6 ArrayList (java.util.ArrayList)5 Map (java.util.Map)5 ResultSet (java.sql.ResultSet)4 SQLException (java.sql.SQLException)4 DfJFadStringConverter (org.dbflute.helper.jdbc.facade.DfJFadStringConverter)4 DfJdbcFacade (org.dbflute.helper.jdbc.facade.DfJdbcFacade)4 Entry (java.util.Map.Entry)3 TnPropertyType (org.dbflute.s2dao.metadata.TnPropertyType)3 Connection (java.sql.Connection)2 Statement (java.sql.Statement)2 Timestamp (java.sql.Timestamp)2 Column (org.apache.torque.engine.database.model.Column)2 SQLExceptionResource (org.dbflute.bhv.exception.SQLExceptionResource)2 PluginValueTypeNotFoundException (org.dbflute.exception.PluginValueTypeNotFoundException)2 StringKeyMap (org.dbflute.helper.StringKeyMap)2 DfJFadCursorCallback (org.dbflute.helper.jdbc.facade.DfJFadCursorCallback)2 ExceptionMessageBuilder (org.dbflute.helper.message.ExceptionMessageBuilder)2