Got this:
org.dozer.MappingException: No read or write method found for field (id) in class (interface java.util.Map)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.determinePropertyType(GetterSetterPropertyDescriptor.java:291)
at org.dozer.propertydescriptor.GetterSetterPropertyDescriptor.getPropertyType(GetterSetterPropertyDescriptor.java:66)
at org.dozer.fieldmap.FieldMap.getDestFieldType(FieldMap.java:115)
at org.dozer.util.MappingUtils.applyGlobalCopyByReference(MappingUtils.java:212)
at org.dozer.loader.MappingsParser.processMappings(MappingsParser.java:128)
at org.dozer.loader.CustomMappingsLoader.load(CustomMappingsLoader.java:65)
at org.dozer.DozerBeanMapper.loadCustomMappings(DozerBeanMapper.java:213)
at org.dozer.DozerBeanMapper.getMappingProcessor(DozerBeanMapper.java:186)
at org.dozer.DozerBeanMapper.map(DozerBeanMapper.java:111)
at id.co.bippo.magento.api.ProductService.mapProducts(ProductService.java:55)
at id.co.bippo.magento.api.ProductServiceTest.testDozerMapping(ProductServiceTest.java:20)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Test:
@Test
public void testDozerMapping() {
ProductService productService = new ProductService(null);
HashMap<String, Object> input = new HashMap<String, Object>();
input.put("id", 54);
List<ProductSummary> products = productService.mapProducts(new Map[]{ input });
assertEquals(54, products.get(0).getId());
}
Mapping file (doesn't have effect whether it's used or not):
<?xml version="1.0" encoding="UTF-8"?>
<mappings xmlns="http://dozer.sourceforge.net" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://dozer.sourceforge.net
http://dozer.sourceforge.net/schema/beanmapping.xsd">
<mapping map-id="ProductSummary">
<class-a>id.co.bippo.magento.domain.ProductSummary</class-a>
<class-b>java.util.Map</class-b>
<field><a>id</a><b>product_id</b></field>
<field><a>setId</a><b>set</b></field>
<field><a>categoryIds</a><b>category_ids</b></field>
</mapping>
</mappings>
Mapper usage :
public List<ProductSummary> mapProducts(Object input) {
DozerBeanMapper mapper = new DozerBeanMapper(Arrays.asList( new String[]{ "id/co/bippo/magento/api/dozer-mapping.xml"} ));
Map<String, Object>[] response = (Map<String, Object>[]) input;
ArrayList<ProductSummary> result = new ArrayList<ProductSummary>();
for (Map<String, Object> row : response) {
ProductSummary product = mapper.map(row, ProductSummary.class, "ProductSummary");
result.add(product);
}
return result;
}
starting partial work here:
https://github.com/ceefour/dozer/tree/bug-3404163-map
I've completed branch : https://github.com/ceefour/dozer/tree/bug-3404162-classldr
which is a bugfix of this issue.
Please merge this patch.
BTW,
I propose to move dozer from Sourceforge SVN to GitHub. To facilitate contributions easily.
Please consider. Thank you.
I've completed branch : https://github.com/ceefour/dozer/tree/bug-3404163-map
which is a bugfix of this issue.
Please merge this patch.
BTW,
I propose to move dozer from Sourceforge SVN to GitHub. To facilitate contributions easily.
Please consider. Thank you.