test_class.declarator: task
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private ComputePreparationId task;
test_class.type: ComputePreparationId
test_class.var_name: task
test_class.declarator: preparationRepository
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private PreparationRepository preparationRepository;
test_class.type: PreparationRepository
test_class.var_name: preparationRepository
test_class.file: dataprep-upgrade/src/test/java/org/talend/dataprep/upgrade/to_1_2_0_PE/ComputePreparationIdTest.java
test_class.identifier: ComputePreparationIdTest
test_class.superclass: extends Base_1_2_0_PE_Test
test_case.body: @Test
      public void shouldComputePreparationsId() throws Exception {
          // given
          final Stream<Preparation> initialPreparations = preparationRepository.list(Preparation.class);
          final List<String> initialIds = initialPreparations.map(Preparation::getId).collect(Collectors.toList());
  
          // when
          task.run();
  
          // then
          final Stream<Preparation> preparations = preparationRepository.list(Preparation.class);
          final List<String> updatedIds = preparations.map(Preparation::getId).collect(Collectors.toList());
          assertEquals(initialIds.size(), updatedIds.size());
          updatedIds.forEach(id -> assertFalse(initialIds.contains(id)));
  
      }
test_case.class_method_signature: ComputePreparationIdTest.shouldComputePreparationsId()
test_case.full_signature: @Test public void shouldComputePreparationsId()
test_case.identifier: shouldComputePreparationsId
test_case.invocations: list collect map toList run list collect map toList assertEquals size size forEach assertFalse contains
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldComputePreparationsId()
focal_class.declarator: LOG = getLogger(ComputePreparationId.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = getLogger(ComputePreparationId.class);
focal_class.type: Logger
focal_class.var_name: LOG
focal_class.declarator: repository
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private PreparationRepository repository;
focal_class.type: PreparationRepository
focal_class.var_name: repository
focal_class.file: dataprep-upgrade/src/main/java/org/talend/dataprep/upgrade/to_1_2_0_PE/ComputePreparationId.java
focal_class.identifier: ComputePreparationId
focal_class.interfaces: implements BaseUpgradeTaskTo_1_2_0_PE
focal_class.class_method_signature: ComputePreparationId.getOrder()
focal_class.full_signature: @Override public int getOrder()
focal_class.identifier: getOrder
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getOrder()
focal_class.class_method_signature: ComputePreparationId.getTarget()
focal_class.full_signature: @Override public target getTarget()
focal_class.identifier: getTarget
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: target
focal_class.signature: target getTarget()
focal_class.class_method_signature: ComputePreparationId.run()
focal_class.full_signature: @Override public void run()
focal_class.identifier: run
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void run()
focal_method.body: @Override
      public void run() {
  
          final Stream<Preparation> preparations = repository.list(Preparation.class);
          preparations.forEach(p -> {
              // preparation needs to be removed first as its id will change
              repository.remove(p);
  
              // change the preparation id and save id
              p.setId(UUID.randomUUID().toString());
              repository.add(p);
  
              LOG.debug("preparation {} has a new id {}", p.getName(), p.getName());
          });
      }
focal_method.class_method_signature: ComputePreparationId.run()
focal_method.full_signature: @Override public void run()
focal_method.identifier: run
focal_method.invocations: list forEach remove setId toString randomUUID add debug getName getName
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()