test_class.declarator: actionRegistry
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private ActionRegistry actionRegistry;
test_class.type: ActionRegistry
test_class.var_name: actionRegistry
test_class.declarator: injectorUtil
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private InjectorUtil injectorUtil;
test_class.type: InjectorUtil
test_class.var_name: injectorUtil
test_class.file: dataprep-backend-service/src/test/java/org/talend/dataprep/util/InjectorUtilTest.java
test_class.identifier: InjectorUtilTest
test_case.body: @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 -> {
  
                  // we check if action create new column then it is on readonly mode
                  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());
  
      }
test_case.class_method_signature: InjectorUtilTest.testInjectPreparationDetailsDTO()
test_case.full_signature: @Test public void testInjectPreparationDetailsDTO()
test_case.identifier: testInjectPreparationDetailsDTO
test_case.invocations: add getSimpleAction add getSimpleAction thenReturn when get newInstance thenReturn when get newInstance injectPreparationDetails forEach getMetadata forEach getParameters equals getName assertTrue isReadonly assertEquals size size getActions assertEquals size size getMetadata
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testInjectPreparationDetailsDTO()
focal_class.declarator: registry
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private ActionRegistry registry;
focal_class.type: ActionRegistry
focal_class.var_name: registry
focal_class.file: dataprep-backend-service/src/main/java/org/talend/dataprep/util/InjectorUtil.java
focal_class.identifier: InjectorUtil
focal_class.class_method_signature: InjectorUtil.injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details)
focal_class.full_signature: public PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details)
focal_class.identifier: injectPreparationDetails
focal_class.modifiers: public
focal_class.parameters: (List<Action> actions, PreparationDetailsDTO details)
focal_class.return: PreparationDetailsDTO
focal_class.signature: PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details)
focal_class.class_method_signature: InjectorUtil.disallowColumnCreationChange(ActionForm form)
focal_class.full_signature: private static ActionForm disallowColumnCreationChange(ActionForm form)
focal_class.identifier: disallowColumnCreationChange
focal_class.modifiers: private static
focal_class.parameters: (ActionForm form)
focal_class.return: ActionForm
focal_class.signature: ActionForm disallowColumnCreationChange(ActionForm form)
focal_method.body: public PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details) {
          // Append actions and action forms
          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));
                      }
                  }) //
                  // action must be adapted before usage. See problems with masking action
                  .map(a -> a.getActionForm(LocaleContextHolder.getLocale(), Locale.US)) //
                  .map(InjectorUtil::disallowColumnCreationChange) //
                  .collect(Collectors.toList());
          details.setMetadata(metadata);
  
          // Flag for allow distributed run (based on metadata).
          details.setAllowDistributedRun(allowDistributedRun.get());
  
          return details;
      }
focal_method.class_method_signature: InjectorUtil.injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details)
focal_method.full_signature: public PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details)
focal_method.identifier: injectPreparationDetails
focal_method.invocations: setActions collect map map peek map stream get getName get set contains getBehavior getActionForm getLocale toList setMetadata setAllowDistributedRun get
focal_method.modifiers: public
focal_method.parameters: (List<Action> actions, PreparationDetailsDTO details)
focal_method.return: PreparationDetailsDTO
focal_method.signature: PreparationDetailsDTO injectPreparationDetails(List<Action> actions, PreparationDetailsDTO details)