use of org.apache.cayenne.exp.property.Property in project cayenne by apache.
the class CustomColumnSetExtractorTest method testExtractWithoutPrefix.
@Test
public void testExtractWithoutPrefix() {
DbEntity mockDbEntity = createMockDbEntity("mock");
TranslatableQueryWrapper wrapper = new MockQueryWrapperBuilder().withNeedsResultSetMapping(true).withMetaData(new MockQueryMetadataBuilder().withDbEntity(mockDbEntity).build()).build();
TranslatorContext context = new MockTranslatorContext(wrapper);
DataMap dataMap = new DataMap();
dataMap.addDbEntity(mockDbEntity);
ObjEntity entity = new ObjEntity();
entity.setName("mock");
entity.setDataMap(dataMap);
entity.setDbEntity(mockDbEntity);
ObjAttribute attribute = new ObjAttribute();
attribute.setName("not_name");
attribute.setDbAttributePath("name");
attribute.setType("my.type");
entity.addAttribute(attribute);
dataMap.addObjEntity(entity);
EntityResolver resolver = new EntityResolver();
resolver.addDataMap(dataMap);
BaseProperty<?> property0 = PropertyFactory.createBase(ExpressionFactory.dbPathExp("name"), String.class);
Collection<Property<?>> properties = Collections.singleton(property0);
CustomColumnSetExtractor extractor = new CustomColumnSetExtractor(context, properties);
extractor.extract();
assertEquals(1, context.getResultNodeList().size());
ResultNodeDescriptor descriptor0 = context.getResultNodeList().get(0);
assertSame(property0, descriptor0.getProperty());
assertNotNull(descriptor0.getNode());
assertThat(descriptor0.getNode(), instanceOf(ColumnNode.class));
assertFalse(descriptor0.isAggregate());
assertTrue(descriptor0.isInDataRow());
assertNotNull(descriptor0.getDbAttribute());
assertNull(descriptor0.getDataRowKey());
assertEquals(Types.VARBINARY, descriptor0.getJdbcType());
assertEquals("java.lang.String", descriptor0.getJavaType());
}
Aggregations