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);
}
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);
}
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);
}
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));
}
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);
}
Aggregations