@Test public void testConvertFloatValue() throws Exception { List<String> values = Arrays.asList("1"); Parameter parameter = new QueryParameter().items(new FloatProperty()); Object o = utils.cast(values, parameter, Float.class, null); assertTrue(o instanceof Float); }
@Test public void testConvertInvalidIntegerValue() throws Exception { List<String> values = Arrays.asList("1abczdf"); Parameter parameter = new QueryParameter().items(new IntegerProperty()); Object o = utils.cast(values, parameter, Integer.class, null); assertNull(o); }
@Test public void testConvertInvalidLongValue() throws Exception { List<String> values = Arrays.asList("1zzzzz"); Parameter parameter = new QueryParameter().items(new LongProperty()); Object o = utils.cast(values, parameter, Long.class, null); assertNull(o); }
@Test public void testConvertEmailValue() throws Exception { List<String> values = Arrays.asList("*****@*****.**"); Parameter parameter = new QueryParameter().items(new EmailProperty()); Object o = utils.cast(values, parameter, String.class, null); assertTrue(o instanceof String); }
@Test public void testConvertUUIDValue() throws Exception { List<String> values = Arrays.asList("163e1000-2a5a-4be2-b271-3470b63dff00"); Parameter parameter = new QueryParameter().items(new UUIDProperty()); Object o = utils.cast(values, parameter, UUID.class, null); assertTrue(o instanceof UUID); }
@Test public void testConvertBooleanValue() throws Exception { List<String> values = Arrays.asList("true"); Parameter parameter = new QueryParameter().items(new BooleanProperty()); Object o = utils.cast(values, parameter, Boolean.class, null); assertTrue(o instanceof Boolean); }
@Test public void testConvertInvalidDoubleValue() throws Exception { List<String> values = Arrays.asList("abcdefg"); Parameter parameter = new QueryParameter().items(new DoubleProperty()); Object o = utils.cast(values, parameter, Double.class, null); assertNull(o); }
@Test public void testConvertInvalidFloatValue() throws Exception { List<String> values = Arrays.asList("1;;lkaj;lasjkdfs"); Parameter parameter = new QueryParameter().items(new FloatProperty()); Object o = utils.cast(values, parameter, Float.class, null); assertNull(o); }