/** @throws Exception */ public void testGetDateFormat() throws Exception { assertEquals( "class default", factory .getAnnotationReader() .getDatePattern(Dxo.class, Dxo.class.getMethod("converted", new Class[] {List.class}))); assertEquals( "foo", factory .getAnnotationReader() .getDatePattern(Dxo.class, Dxo.class.getMethod("convert", new Class[] {Object.class}))); assertEquals( "bar", factory .getAnnotationReader() .getDatePattern( Dxo.class, Dxo.class.getMethod("convert", new Class[] {Number.class, String.class}))); assertEquals( "baz", factory .getAnnotationReader() .getDatePattern( Dxo.class, Dxo.class.getMethod("convert", new Class[] {Object[].class}))); assertNull( factory .getAnnotationReader() .getDatePattern( Dxo2.class, Dxo2.class.getMethod("convert", new Class[] {Object.class}))); }
/** @throws Exception */ @SuppressWarnings("unchecked") public void testIsExcludeWs() throws Exception { assertTrue( factory .getAnnotationReader() .isExcludeWhitespace( Dxo.class, Dxo.class.getMethod("convertExWs", new Class[] {Object.class}))); assertTrue( factory .getAnnotationReader() .isExcludeWhitespace( Dxo2.class, Dxo2.class.getMethod("convertExWs", new Class[] {Object.class}))); assertFalse( factory .getAnnotationReader() .isExcludeWhitespace( Dxo.class, Dxo.class.getMethod("convertExNull", new Class[] {Object.class}))); }
/** @throws Exception */ public void testGetMapConversion() throws Exception { assertEquals( "map1", factory .getAnnotationReader() .getConversionRule( Dxo.class, Dxo.class.getMethod("convert", new Class[] {Integer.class}))); assertEquals( "map2", factory .getAnnotationReader() .getConversionRule( Dxo.class, Dxo.class.getMethod("convert", new Class[] {Integer.class, Map.class}))); assertNull( factory .getAnnotationReader() .getConversionRule( Dxo.class, Dxo.class.getMethod("convert", new Class[] {Integer[].class}))); }
/** @throws Exception */ @SuppressWarnings("unchecked") public void testGetConverters() throws Exception { Map<String, Converter> converters = factory.getAnnotationReader().getConverters(Hoge.class); assertNotNull(converters); assertEquals(3, converters.size()); Converter converter = converters.get("foo"); assertNotNull(converter); assertEquals("foo", converter.convert("foo", String.class, null)); converter = converters.get("bar"); assertNotNull(converter); assertEquals("a_bar_b", converter.convert("bar", String.class, null)); converter = converters.get("baz"); assertNotNull(converter); assertEquals("baz", converter.convert("baz", String.class, null)); }