ValueConversionHelper { public static Object applyCompatibilityLogic(Class targetType, Object targetValue) { if (targetType.isPrimitive() && targetValue == null) { return nullToPrimitive(targetType); } if (targetValue == null) { return null; } if (targetType.isAssignableFrom(targetValue.getClass())) { return targetValue; } return compatibilize(targetValue, targetType); }  static Object applyCompatibilityLogic(Class targetType, Object targetValue);  }
@Test public void testNullDoubleConversion() { double val = (Double) ValueConversionHelper.applyCompatibilityLogic(double.class, null); assertEquals("Null should be compatibilized to 0", 0, val, 0.0001); }
@Test public void testNullFloatConversion() { float val = (Float) ValueConversionHelper.applyCompatibilityLogic(float.class, null); assertEquals("Null should be compatibilized to 0", 0, val, 0.0001); }
@Test public void testNullShortConversion() { short val = (Short) ValueConversionHelper.applyCompatibilityLogic(short.class, null); assertEquals("Null should be compatibilized to 0", 0, val); }
@Test public void testNullLongConversion() { long val = (Long) ValueConversionHelper.applyCompatibilityLogic(long.class, null); assertEquals("Null should be compatibilized to 0", 0, val); }
@Test public void testNullCharConversion() { char val = (Character) ValueConversionHelper.applyCompatibilityLogic(char.class, null); assertEquals("Null should be compatibilized to 0", 0, val); }
@Test public void testNullBooleanConversion() { boolean val = (Boolean) ValueConversionHelper.applyCompatibilityLogic(boolean.class, null); assertEquals("Null should be compatibilized to false", false, val); }
@Test public void testNullIntConversion() { int val = (Integer) ValueConversionHelper.applyCompatibilityLogic(int.class, null); assertEquals("Null should be compatibilized to 0", 0, val); }
@Test public void testNullByteConversion() { byte val = (Byte) ValueConversionHelper.applyCompatibilityLogic(byte.class, null); assertEquals("Null should be compatibilized to 0", 0, val); }