/** * Create Set of HColumns for the given Object. The Object must be annotated * with {@link Column} on the desired fields. * * @param obj * @return */ private Collection<HColumn<String, byte[]>> createColumnSet(Object obj) { Map<String, HColumn<String, byte[]>> map = createColumnMap(obj); if (null != map) { return map.values(); } else { return null; } }
@Test public void testNonStringAnonymousValues() { AnonymousWithLongSerializer b1 = new AnonymousWithLongSerializer(); b1.addAnonymousProp("one", 1L); b1.addAnonymousProp("two", 2L); b1.addAnonymousProp("three", 3L); Map<String, HColumn<String, byte[]>> colMap = new HectorObjectMapper(cacheMgr).createColumnMap(b1); assertEquals("should have added all props as anonymous", colMap.size(), b1.getAnonymousProps() .size()); }
@Test public void testCustomConvertedCollectionIsOneColumn() { MyConvertedCollectionBean b1 = new MyConvertedCollectionBean(); int first = 111; int second = 0; int third = -1; b1.addToList(first).addToList(second).addToList(third); Map<String, HColumn<String, byte[]>> colMap = new HectorObjectMapper(cacheMgr).createColumnMap(b1); CFMappingDef<MyConvertedCollectionBean> cfMapping = cacheMgr.getCfMapDef( MyConvertedCollectionBean.class, false); assertEquals( "collections with custom converters should be skipped by default collection mapping", colMap.size(), cfMapping.getAllProperties().size()); }
obj.addAnonymousProp("rice", "beans"); Map<String, HColumn<String, byte[]>> colMap = new HectorObjectMapper(cacheMgr).createColumnMap(obj);