-
Notifications
You must be signed in to change notification settings - Fork 100
Open
Description
I just started using boon and it is FAST! However, I think I found an issue with subclassing. Parsing is not detecting the "class" attribute. I saw the Person/Pet/Dog example, and verified that example does work. I am not entirely sure why my case does not work but I am thinking it is because there are no abstract, interfaces defined.
I believe I am using boon correctly in my test case. If you could please look at this issue, I would appreciated it. And if you agree, is the proposed fix correct?
Please see complete test project attached. I am using boon-0.30.jar.
I was able to get the test case attached to work by changing the code in
org.boon.core.reflection.MapperSimple
private <T> void fromValueMapHandleValueCase(T newInstance, FieldAccess field, Value value) {
case INSTANCE:
switch (value.type()) {
case MAP:
// ********************************************
// Begin fix
// ********************************************
final Map<String, Value> valueMap = (Map<String, Value>) objValue;
final Value aClass = valueMap.get("class");
if (aClass != null) {
clazz = Reflection.loadClass(aClass.stringValue());
}
// ********************************************
// End fix
// ********************************************
objValue = fromValueMap( ( Map<String, Value> ) objValue, clazz );
break;
case LIST:
objValue = fromList((List<Object>) objValue, clazz);
break;
}
field.setValue(newInstance, objValue);
break;I think a similar change is needed to MapperComplex.
@Test
public void test() {
RequestContext requestContext = new RequestContext();
requestContext.setMessageID("123");
DoThisApplicationRequest doThisApplicationRequest = new DoThisApplicationRequest();
doThisApplicationRequest.setSomeValue("hello");
ApplicationRequest applicationRequest = new ApplicationRequest();
applicationRequest.setRequestContext(requestContext);
applicationRequest.setServiceRequest(doThisApplicationRequest);
applicationRequest.setVersion("1.0.0");
final JsonSerializer serializer = new JsonSerializerFactory ().useAnnotations().create ();
JsonParserAndMapper jsonParserAndMapper = new JsonParserFactory().setLazyChop(true).create();
ApplicationRequest applicationRequestCopy = jsonParserAndMapper.parse(ApplicationRequest.class, serializer.serialize(applicationRequest).toCharArray());
assertTrue(applicationRequest.getServiceRequest() instanceof DoThisApplicationRequest);
assertTrue(applicationRequestCopy.getServiceRequest() instanceof DoThisApplicationRequest);
}Metadata
Metadata
Assignees
Labels
No labels