}
@Test
public void testContextMappingWithNestedContext() throws Exception {
Mapper mapper = getMapper("contextMapping.xml");
ContextMappingNested cmn = newInstance(ContextMappingNested.class);
cmn.setLoanNo("loanNoNested");
List<ContextMappingNested> list = newInstance(ArrayList.class);
list.add(cmn);
ContextMapping cm = newInstance(ContextMapping.class);
cm.setLoanNo("loanNo");
cm.setContextList(list);
ContextMappingPrime cmpA = mapper.map(cm, ContextMappingPrime.class, "caseA");
assertNull(cmpA.getLoanNo());
assertNull(((ContextMappingNestedPrime) cmpA.getContextList().get(0)).getLoanNo());
ContextMappingPrime cmpB = mapper.map(cm, ContextMappingPrime.class, "caseB");
assertEquals("loanNo", cmpB.getLoanNo());
assertEquals("loanNoNested", ((ContextMappingNested) cmpB.getContextList().get(0)).getLoanNo());
ContextMappingNestedPrime cmn2 = newInstance(ContextMappingNestedPrime.class);
cmn2.setLoanNo("loanNoNested");
List<ContextMappingNestedPrime> list2 = newInstance(ArrayList.class);
list2.add(cmn2);
ContextMappingPrime prime = newInstance(ContextMappingPrime.class);
prime.setLoanNo("loanNo");
prime.setContextList(list2);
ContextMapping cmDest = mapper.map(prime, ContextMapping.class, "caseA");
assertNull(cmDest.getLoanNo());
assertNull(((ContextMappingNested) cmDest.getContextList().get(0)).getLoanNo());
ContextMapping cmpBDest = mapper.map(prime, ContextMapping.class, "caseB");
assertEquals("loanNo", cmpBDest.getLoanNo());
assertEquals("loanNoNested", ((ContextMappingNestedPrime) cmpBDest.getContextList().get(0)).getLoanNo());
}