use of org.apache.cayenne.reflect.generic.DefaultValueComparisonStrategyFactory in project cayenne by apache.
the class DescriptorColumnExtractorTest method testExtractNoPrefix.
@Test
public void testExtractNoPrefix() {
DbEntity mockDbEntity = createMockDbEntity("mock");
TranslatableQueryWrapper wrapper = new MockQueryWrapperBuilder().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("java.lang.Integer");
entity.addAttribute(attribute);
dataMap.addObjEntity(entity);
EntityResolver resolver = new EntityResolver();
resolver.addDataMap(dataMap);
resolver.setValueComparisionStrategyFactory(new DefaultValueComparisonStrategyFactory(mock(ValueObjectTypeRegistry.class)));
DescriptorColumnExtractor extractor = new DescriptorColumnExtractor(context, resolver.getClassDescriptor("mock"));
extractor.extract();
assertEquals(2, context.getResultNodeList().size());
ResultNodeDescriptor descriptor0 = context.getResultNodeList().get(0);
ResultNodeDescriptor descriptor1 = context.getResultNodeList().get(1);
assertNull(descriptor0.getProperty());
assertNotNull(descriptor0.getNode());
assertThat(descriptor0.getNode(), instanceOf(ColumnNode.class));
assertFalse(descriptor0.isAggregate());
assertTrue(descriptor0.isInDataRow());
assertNotNull(descriptor0.getDbAttribute());
assertEquals("name", descriptor0.getDataRowKey());
assertEquals(Types.VARBINARY, descriptor0.getJdbcType());
assertEquals("java.lang.Integer", descriptor0.getJavaType());
assertNull(descriptor1.getProperty());
assertNotNull(descriptor1.getNode());
assertThat(descriptor1.getNode(), instanceOf(ColumnNode.class));
assertFalse(descriptor1.isAggregate());
assertTrue(descriptor1.isInDataRow());
assertEquals("id", descriptor1.getDataRowKey());
assertNotNull(descriptor1.getDbAttribute());
assertEquals(Types.BIGINT, descriptor1.getJdbcType());
}
Aggregations