public void afterPropertiesSet() throws Exception { Assert.notNull(flowDefinitionLocator, "The flow definition locator property is required"); if (conversionService == null) { conversionService = new DefaultConversionService(); } MutableAttributeMap<Object> executionAttributes = createFlowExecutionAttributes(); FlowExecutionImplFactory executionFactory = createFlowExecutionFactory(executionAttributes); DefaultFlowExecutionRepository executionRepository = createFlowExecutionRepository(executionFactory); executionFactory.setExecutionKeyFactory(executionRepository); flowExecutor = new FlowExecutorImpl(flowDefinitionLocator, executionFactory, executionRepository); }
public static FlowBuilderServices getServices() { FlowBuilderServices services = new FlowBuilderServices() { // The SpEL parser must use the currently configured conversion service. public void setConversionService(ConversionService conversionService) { super.setConversionService(conversionService); setExpressionParser(new WebFlowSpringELExpressionParser(new SpelExpressionParser(), conversionService)); } }; services.setViewFactoryCreator(new MockViewFactoryCreator()); services.setConversionService(new DefaultConversionService()); services.setApplicationContext(createTestApplicationContext()); return services; }
/** * Creates a new expression parser that uses a {@link DefaultConversionService} to perform type conversion. */ public BeanWrapperExpressionParser() { this.conversionService = new DefaultConversionService(); }
public void afterPropertiesSet() throws Exception { Assert.notNull(flowDefinitionLocator, "The flow definition locator property is required"); if (conversionService == null) { conversionService = new DefaultConversionService(); } MutableAttributeMap<Object> executionAttributes = createFlowExecutionAttributes(); FlowExecutionImplFactory executionFactory = createFlowExecutionFactory(executionAttributes); DefaultFlowExecutionRepository executionRepository = createFlowExecutionRepository(executionFactory); executionFactory.setExecutionKeyFactory(executionRepository); flowExecutor = new FlowExecutorImpl(flowDefinitionLocator, executionFactory, executionRepository); }
public void afterPropertiesSet() throws Exception { Assert.notNull(flowDefinitionLocator, "The flow definition locator property is required"); if (conversionService == null) { conversionService = new DefaultConversionService(); } MutableAttributeMap executionAttributes = createFlowExecutionAttributes(); FlowExecutionImplFactory executionFactory = createFlowExecutionFactory(executionAttributes); DefaultFlowExecutionRepository executionRepository = createFlowExecutionRepository(executionFactory); executionFactory.setExecutionKeyFactory(executionRepository); flowExecutor = new FlowExecutorImpl(flowDefinitionLocator, executionFactory, executionRepository); }
public void testTargetClassNotSupported() { DefaultConversionService service = new DefaultConversionService(); try { service.getConversionExecutor(String.class, HashMap.class); fail("Should have thrown an exception"); } catch (ConversionExecutorNotFoundException e) { } }
@SuppressWarnings("unchecked") public void testRegisterCustomConverterListToList() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", List.class, List.class); List<String> princyList = new ArrayList<>(); princyList.add("princy1"); princyList.add("princy2"); List<Principal> list = (List<Principal>) executor.execute(princyList); assertEquals("princy1", list.get(0).getName()); assertEquals("princy2", list.get(1).getName()); }
public void testConvertCompatibleTypes() { DefaultConversionService service = new DefaultConversionService(); List<Object> lst = new ArrayList<>(); assertSame(lst, service.getConversionExecutor(ArrayList.class, List.class).execute(lst)); }
public void testRegisterCustomConverterListToArray() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", List.class, Principal[].class); List<String> princyList = new ArrayList<>(); princyList.add("princy1"); princyList.add("princy2"); Principal[] p = (Principal[]) executor.execute(princyList); assertEquals("princy1", p[0].getName()); assertEquals("princy2", p[1].getName()); }
@SuppressWarnings("unchecked") public void testArrayToLinkedListConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(String[].class, LinkedList.class); LinkedList<String> result = (LinkedList<String>) executor.execute(new String[] { "1", "2", "3" }); assertEquals("1", result.get(0)); assertEquals("2", result.get(1)); assertEquals("3", result.get(2)); }
@SuppressWarnings("unchecked") public void testArrayToListConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(String[].class, List.class); List<String> result = (List<String>) executor.execute(new String[] { "1", "2", "3" }); assertEquals("1", result.get(0)); assertEquals("2", result.get(1)); assertEquals("3", result.get(2)); }
@SuppressWarnings("unchecked") public void testStringToListConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(String.class, List.class); List<String> result = (List<String>) executor.execute("1,2,3"); assertEquals(3, result.size()); assertEquals("1", result.get(0)); assertEquals("2", result.get(1)); assertEquals("3", result.get(2)); }
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 testRegisterCustomConverterReverseNotCompatibleSource() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); try { service.getConversionExecutor("trimmer", Principal.class, Object.class); } catch (ConversionException e) { } }
@SuppressWarnings("unchecked") public void testRegisterCustomConverterObjectToList() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", String.class, List.class); List<Principal> list = (List<Principal>) executor.execute("princy1"); assertEquals("princy1", list.get(0).getName()); }
public void testStringToArrayConversionWithElementConversion() { DefaultConversionService service = new DefaultConversionService(); ConversionExecutor executor = service.getConversionExecutor(String.class, Integer[].class); Integer[] result = (Integer[]) executor.execute("123"); assertEquals(1, result.length); assertEquals(new Integer(123), result[0]); }
public void testRegisterCustomConverterArrayToArray() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", String[].class, Principal[].class); Principal[] p = (Principal[]) executor.execute(new String[] { "princy1", "princy2" }); assertEquals("princy1", p[0].getName()); assertEquals("princy2", p[1].getName()); }
@SuppressWarnings("unchecked") public void testRegisterCustomConverterObjectToListReverse() { DefaultConversionService service = new DefaultConversionService(); service.addConverter("princy", new CustomTwoWayConverter()); ConversionExecutor executor = service.getConversionExecutor("princy", Principal.class, List.class); final Principal princy1 = () -> "princy1"; List<String> list = (List<String>) executor.execute(princy1); assertEquals("princy1", list.get(0)); }
public void setUp() { conversionService = new DefaultConversionService(); expressionParser = new WebFlowSpringELExpressionParser(new SpelExpressionParser(), conversionService); converterRegistry = (ConverterRegistry) conversionService.getDelegateConversionService(); }
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) { } }