InjectorUtil { public PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details) { details.setActions(actions); final AtomicBoolean allowDistributedRun = new AtomicBoolean(); final List<ActionForm> metadata = actions .stream() .map(a -> registry.get(a.getName())) .peek(a -> { if (allowDistributedRun.get()) { allowDistributedRun.set(a.getBehavior().contains(ActionDefinition.Behavior.FORBID_DISTRIBUTED)); } }) .map(a -> a.getActionForm(LocaleContextHolder.getLocale(), Locale.US)) .map(InjectorUtil::disallowColumnCreationChange) .collect(Collectors.toList()); details.setMetadata(metadata); details.setAllowDistributedRun(allowDistributedRun.get()); return details; }  PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details);  }
@Test public void testInjectPreparationDetailsDTO() throws IllegalAccessException, InstantiationException { PreparationDetailsDTO prep = new PreparationDetailsDTO(); List<Action> actions = new ArrayList<>(); actions.add(getSimpleAction("uppercase", "column_name", "lastname")); actions.add(getSimpleAction("lowercase", "column_name", "lastname")); when(actionRegistry.get("uppercase")).thenReturn(UpperCase.class.newInstance()); when(actionRegistry.get("lowercase")).thenReturn(LowerCase.class.newInstance()); PreparationDetailsDTO detailsPrep = injectorUtil.injectPreparationDetails(actions, prep); detailsPrep.getMetadata().forEach(af -> { af.getParameters().forEach(p -> { if (p.getName().equals(CREATE_NEW_COLUMN)) { assertTrue(p.isReadonly()); } }); }); assertEquals("Number of action should be the same", actions.size(), detailsPrep.getActions().size()); assertEquals("Number of ActionForm should be the same", actions.size(), detailsPrep.getMetadata().size()); }