VariableIntegerConverter implements Converter<Object> { @Override public Object convertCassTypeToObjType(PropertyMappingDefinition md, byte[] value) { BigInteger bigInt = new BigInteger(value); Class<?> targetClass = md.getPropDesc().getPropertyType(); if (targetClass.equals(Integer.class) || targetClass.equals(int.class)) { return Integer.valueOf(bigInt.intValue()); } else if (targetClass.equals(Long.class) || targetClass.equals(long.class)) { return Long.valueOf(bigInt.longValue()); } else if (targetClass.equals(Short.class) || targetClass.equals(short.class)) { return Short.valueOf(bigInt.shortValue()); } else if (targetClass.equals(Byte.class) || targetClass.equals(byte.class)) { return Byte.valueOf(bigInt.byteValue()); } else if (targetClass.equals(BigInteger.class)) { return bigInt; } else { throw new HectorObjectMapperException("Column, " + md.getColName() + ", cannot be converted using " + getClass().getSimpleName() + " because POJO property, " + md.getPropDesc().getName() + ", of type " + md.getPropDesc().getPropertyType().getName() + " is not an integer type (in a mathematical context)"); } }  @Override Object convertCassTypeToObjType(PropertyMappingDefinition md, byte[] value); @Override byte[] convertObjTypeToCassType(Object value);  }
@Test(expected=HectorObjectMapperException.class) public void testStringFromCassNotWork() throws Exception { conv.convertCassTypeToObjType(new PropertyMappingDefinition( new PropertyDescriptor("str1", TestClass.class), "foo", VariableIntegerConverter.class), new String("123").getBytes()); }