use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class ExpressionEvaluatorTest method shouldReturnTrueIfNotNull.
@Test
public void shouldReturnTrueIfNotNull() {
boolean value = evaluator.evaluateBoolean("username", new Author(1, "cbegin", "******", "cbegin@apache.org", "N/A", Section.NEWS));
assertEquals(true, value);
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class ExecutorTestHelper method prepareSelectOneAuthorMappedStatement.
public static MappedStatement prepareSelectOneAuthorMappedStatement(final Configuration config) {
final TypeHandlerRegistry registry = config.getTypeHandlerRegistry();
final ResultMap rm = new ResultMap.Builder(config, "defaultResultMap", Author.class, new ArrayList<ResultMapping>() {
{
add(new ResultMapping.Builder(config, "id", "id", registry.getTypeHandler(int.class)).build());
add(new ResultMapping.Builder(config, "username", "username", registry.getTypeHandler(String.class)).build());
add(new ResultMapping.Builder(config, "password", "password", registry.getTypeHandler(String.class)).build());
add(new ResultMapping.Builder(config, "email", "email", registry.getTypeHandler(String.class)).build());
add(new ResultMapping.Builder(config, "bio", "bio", registry.getTypeHandler(String.class)).build());
add(new ResultMapping.Builder(config, "favouriteSection", "favourite_section", registry.getTypeHandler(Section.class)).build());
}
}).build();
MappedStatement ms = new MappedStatement.Builder(config, "selectAuthor", new StaticSqlSource(config, "SELECT * FROM author WHERE id = ?"), SqlCommandType.SELECT).parameterMap(new ParameterMap.Builder(config, "defaultParameterMap", Author.class, new ArrayList<ParameterMapping>() {
{
add(new ParameterMapping.Builder(config, "id", registry.getTypeHandler(int.class)).build());
}
}).build()).resultMaps(new ArrayList<ResultMap>() {
{
add(rm);
}
}).cache(authorCache).build();
return ms;
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldCreateAProxyForAPartiallyLoadedBean.
@Test
public void shouldCreateAProxyForAPartiallyLoadedBean() throws Exception {
ResultLoaderMap loader = new ResultLoaderMap();
loader.addLoader("id", null, null);
Object proxy = proxyFactory.createProxy(author, loader, new Configuration(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
Author author2 = (Author) deserialize(serialize((Serializable) proxy));
assertTrue(author2 instanceof Factory);
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldLetCallALoadedProperty.
@Test
public void shouldLetCallALoadedProperty() throws Exception {
Author author2 = (Author) ((CglibProxyFactory) proxyFactory).createDeserializationProxy(author, new HashMap<String, ResultLoaderMap.LoadPair>(), new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
assertEquals(999, author2.getId());
}
use of org.apache.ibatis.domain.blog.Author in project mybatis-3 by mybatis.
the class CglibProxyTest method shouldFailCallingAnUnloadedProperty.
@Test(expected = ExecutorException.class)
public void shouldFailCallingAnUnloadedProperty() throws Exception {
// yes, it must go in uppercase
HashMap<String, ResultLoaderMap.LoadPair> unloadedProperties = new HashMap<String, ResultLoaderMap.LoadPair>();
unloadedProperties.put("ID", null);
Author author2 = (Author) ((CglibProxyFactory) proxyFactory).createDeserializationProxy(author, unloadedProperties, new DefaultObjectFactory(), new ArrayList<Class<?>>(), new ArrayList<Object>());
author2.getId();
}
Aggregations