public void testTargetClassNotSupported() { DefaultConversionService service = new DefaultConversionService(); try { service.getConversionExecutor(String.class, HashMap.class); fail("Should have thrown an exception"); } catch (ConversionExecutorNotFoundException e) { } }
public void testRegisterCustomConverterListToListBogus() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", List.class, List.class); List<Integer> princyList = new ArrayList<>(); princyList.add(1); try { executor.execute(princyList); fail("Should have failed"); } catch (ConversionExecutionException e) { } }
public void testRegisterCustomConverterObjectToArrayBogus() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); try { service.getConversionExecutor("princy", Integer.class, Principal[].class); fail("Should have failed"); } catch (ConversionExecutorNotFoundException e) { } }
public void testRegisterCustomConverterArrayToListBogus() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); try { service.getConversionExecutor("princy", Integer[].class, List.class); fail("Should have failed"); } catch (ConversionExecutorNotFoundException e) { } }
public void testRegisterCustomConverterArrayToArrayBogus() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); try { service.getConversionExecutor("princy", Integer[].class, Principal[].class); fail("Should have failed"); } catch (ConversionExecutorNotFoundException e) { } }
public void testRegisterCustomConverterListToArrayBogus() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); try { service.getConversionExecutor("princy", List.class, Integer[].class); fail("Should have failed"); } catch (ConversionExecutorNotFoundException e) { } }
public void testRegisterCustomConverterObjectToListBogus() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", Integer.class, List.class); try { executor.execute(1); fail("Should have failed"); } catch (ConversionExecutionException e) { } }
public void testOverrideConverter() { Converter customConverter = new StringToBoolean("ja", "nee"); DefaultConversionService service = new DefaultConversionService(); StaticConversionExecutor executor = (StaticConversionExecutor) service.getConversionExecutor(String.class, Boolean.class); try { executor.execute("ja"); fail(); } catch (ConversionExecutionException e) { // expected } service.addConverter(customConverter); executor = (StaticConversionExecutor) service.getConversionExecutor(String.class, Boolean.class); assertTrue(((Boolean) executor.execute("ja"))); }