private <T> void parseDiscriminatorColumnAnnotation(DiscriminatorColumn anno, CFMappingDef<T> cfMapDef) { cfMapDef.setDiscColumn(anno.name()); cfMapDef.setDiscType(anno.discriminatorType()); }
@Test(expected = HectorObjectMapperException.class) public void testValidateMissingDiscriminatorValue() { CFMappingDef<MyTestBean> cfMapDef = new CFMappingDef<MyTestBean>(MyTestBean.class); cfMapDef.setInheritanceType(InheritanceType.SINGLE_TABLE); cfMapDef.setDiscColumn("myType"); InheritanceParserValidator val = new InheritanceParserValidator(); val.validateAndSetDefaults(null, cfMapDef); fail("should have reported missing discriminator value annotation"); }
@Test public void testValidate() { CFMappingDef<MyTestBean> cfMapDef = new CFMappingDef<MyTestBean>(MyTestBean.class); cfMapDef.setInheritanceType(InheritanceType.SINGLE_TABLE); cfMapDef.setDiscColumn("myType"); cfMapDef.setDiscValue("blue"); InheritanceParserValidator val = new InheritanceParserValidator(); try { val.validateAndSetDefaults(null, cfMapDef); } catch (HectorObjectMapperException e) { fail(e.getMessage()); } }
public void testValidateDerivedClass() { CFMappingDef<MyTestBean> cfBaseMapDef = new CFMappingDef<MyTestBean>( MyTestBean.class); cfBaseMapDef.setInheritanceType(InheritanceType.SINGLE_TABLE); cfBaseMapDef.setDiscColumn("myType"); CFMappingDef<MyBlueTestBean> cfMapDef = new CFMappingDef<MyBlueTestBean>( MyBlueTestBean.class); cfMapDef.setCfBaseMapDef(cfBaseMapDef); cfMapDef.setDiscValue("blue"); InheritanceParserValidator val = new InheritanceParserValidator(); try { val.validateAndSetDefaults(null, cfMapDef); } catch (HectorObjectMapperException e) { fail(e.getMessage()); } }
@Test(expected = HectorObjectMapperException.class) public void testValidateDerivedClassMissingDiscriminatorValue() { ClassCacheMgr cacheMgr = new ClassCacheMgr(); CFMappingDef<MyTestBean> cfBaseMapDef = new CFMappingDef<MyTestBean>( MyTestBean.class); cfBaseMapDef.setInheritanceType(InheritanceType.SINGLE_TABLE); cfBaseMapDef.setDiscColumn("myType"); CFMappingDef<MyBlueTestBean> cfMapDef = new CFMappingDef<MyBlueTestBean>( MyBlueTestBean.class); cfMapDef.setCfSuperMapDef(cfBaseMapDef); cfMapDef.setCfBaseMapDef(cfBaseMapDef); InheritanceParserValidator val = new InheritanceParserValidator(); val.validateAndSetDefaults(cacheMgr, cfMapDef); fail("should have reported missing discriminator value annotation"); }