Search in sources :

Example 1 with MockValueType

use of org.dbflute.mock.MockValueType 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 2 with MockValueType

use of org.dbflute.mock.MockValueType 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 3 with MockValueType

use of org.dbflute.mock.MockValueType 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 4 with MockValueType

use of org.dbflute.mock.MockValueType 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 5 with MockValueType

use of org.dbflute.mock.MockValueType 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

MockValueType (org.dbflute.mock.MockValueType)9 ValueType (org.dbflute.jdbc.ValueType)7 ResultSet (java.sql.ResultSet)2 MockResultSet (org.dbflute.mock.MockResultSet)2 FileFilter (java.io.FileFilter)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1