test_class.declarator: task
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private ToPEPersistentIdentifiable task;
test_class.type: ToPEPersistentIdentifiable
test_class.var_name: task
test_class.declarator: repository
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private PreparationRepository repository;
test_class.type: PreparationRepository
test_class.var_name: repository
test_class.declarator: dataSetMetadataRepository
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private DataSetMetadataRepository dataSetMetadataRepository;
test_class.type: DataSetMetadataRepository
test_class.var_name: dataSetMetadataRepository
test_class.declarator: builder
test_class.modifier: @Autowired
      private
test_class.original_string: @Autowired
      private DataSetMetadataBuilder builder;
test_class.type: DataSetMetadataBuilder
test_class.var_name: builder
test_class.file: dataprep-upgrade/src/test/java/org/talend/dataprep/upgrade/to_2_1_0_PE/ToPEPersistentIdentifiableTest.java
test_class.identifier: ToPEPersistentIdentifiableTest
test_class.superclass: extends Base_2_1_0_PE_Test
test_case.body: @Test
      public void shouldUpdatePersistentClasses() {
          // when
          task.run();
  
          // then
          assertEquals(2, repository.list(PersistentPreparation.class).count());
          List<PersistentPreparation> persistentPreparationList = repository
                  .list(PersistentPreparation.class)
                  .sorted(Comparator.comparingInt(p1 -> p1.getSteps().size()))
                  .collect(Collectors.toList());
          persistentPreparationList.forEach(p -> {
              assertNotNull(p.getSteps());
              assertNotNull(p.getRowMetadata());
              assertFalse(p.getSteps().isEmpty());
              assertEquals(Type.INTEGER.getName(), p.getRowMetadata().getColumns().get(0).getType());
          });
          assertEquals(6, persistentPreparationList.get(0).getRowMetadata().getColumns().size());
          assertEquals(5, persistentPreparationList.get(1).getRowMetadata().getColumns().size());
  
          repository.list(Preparation.class).forEach(p -> {
              // make sure preparation steps are read
              assertNotNull(p.getSteps());
              assertFalse(p.getSteps().isEmpty());
          });
  
          // root step is filtered
          assertEquals(10, repository.list(PersistentStep.class).filter(s -> s.getParentId() != null).count());
          repository.list(Step.class).forEach(s -> assertNotNull(s.getId()));
      }
test_case.class_method_signature: ToPEPersistentIdentifiableTest.shouldUpdatePersistentClasses()
test_case.full_signature: @Test public void shouldUpdatePersistentClasses()
test_case.identifier: shouldUpdatePersistentClasses
test_case.invocations: run assertEquals count list collect sorted list comparingInt size getSteps toList forEach assertNotNull getSteps assertNotNull getRowMetadata assertFalse isEmpty getSteps assertEquals getName getType get getColumns getRowMetadata assertEquals size getColumns getRowMetadata get assertEquals size getColumns getRowMetadata get forEach list assertNotNull getSteps assertFalse isEmpty getSteps assertEquals count filter list getParentId forEach list assertNotNull getId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldUpdatePersistentClasses()
focal_class.declarator: LOGGER = getLogger(ToPEPersistentIdentifiable.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOGGER = getLogger(ToPEPersistentIdentifiable.class);
focal_class.type: Logger
focal_class.var_name: LOGGER
focal_class.declarator: preparationUtils
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private PreparationUtils preparationUtils;
focal_class.type: PreparationUtils
focal_class.var_name: preparationUtils
focal_class.declarator: preparationRepository
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private PreparationRepository preparationRepository;
focal_class.type: PreparationRepository
focal_class.var_name: preparationRepository
focal_class.declarator: dataSetMetadataRepository
focal_class.modifier: @Autowired
      private
focal_class.original_string: @Autowired
      private DataSetMetadataRepository dataSetMetadataRepository;
focal_class.type: DataSetMetadataRepository
focal_class.var_name: dataSetMetadataRepository
focal_class.declarator: fileSystemPreparationRepository
focal_class.modifier: private
focal_class.original_string: private FileSystemPreparationRepository fileSystemPreparationRepository;
focal_class.type: FileSystemPreparationRepository
focal_class.var_name: fileSystemPreparationRepository
focal_class.file: dataprep-upgrade/src/main/java/org/talend/dataprep/upgrade/to_2_1_0_PE/ToPEPersistentIdentifiable.java
focal_class.identifier: ToPEPersistentIdentifiable
focal_class.interfaces: implements BaseUpgradeTaskTo_2_1_0_PE
focal_class.class_method_signature: ToPEPersistentIdentifiable.postInitialize()
focal_class.full_signature: @PostConstruct private void postInitialize()
focal_class.identifier: postInitialize
focal_class.modifiers: @PostConstruct private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void postInitialize()
focal_class.class_method_signature: ToPEPersistentIdentifiable.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_class.class_method_signature: ToPEPersistentIdentifiable.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: ToPEPersistentIdentifiable.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: ToPEPersistentIdentifiable.turnToPersistentStep(Step step)
focal_class.full_signature: private PersistentStep turnToPersistentStep(Step step)
focal_class.identifier: turnToPersistentStep
focal_class.modifiers: private
focal_class.parameters: (Step step)
focal_class.return: PersistentStep
focal_class.signature: PersistentStep turnToPersistentStep(Step step)
focal_class.class_method_signature: ToPEPersistentIdentifiable.turnToPersistentPreparation(Preparation preparation)
focal_class.full_signature: private PersistentPreparation turnToPersistentPreparation(Preparation preparation)
focal_class.identifier: turnToPersistentPreparation
focal_class.modifiers: private
focal_class.parameters: (Preparation preparation)
focal_class.return: PersistentPreparation
focal_class.signature: PersistentPreparation turnToPersistentPreparation(Preparation preparation)
focal_method.body: @Override
      public void run() {
          LOGGER.debug("starting upgrade from {} to {}.", Step.class, PersistentStep.class);
          final AtomicLong counter = new AtomicLong(0L);
          fileSystemPreparationRepository.list(Step.class).forEach(s -> {
              fileSystemPreparationRepository.remove(s);
              PersistentStep persistentStep = turnToPersistentStep(s);
              preparationRepository.add(persistentStep);
              LOGGER.debug("step {} updated to {}", s, persistentStep);
              counter.incrementAndGet();
          });
          LOGGER.info("Upgrade from {} to {} done, {} steps processed.", Step.class, PersistentStep.class, counter.get());
  
          LOGGER.debug("starting upgrade from {} to {}.", Preparation.class, PersistentPreparation.class);
          final Stream<Preparation> preparations = fileSystemPreparationRepository.list(Preparation.class);
          preparations.forEach(p -> {
              fileSystemPreparationRepository.remove(p);
              PersistentPreparation persistentPreparation = turnToPersistentPreparation(p);
              preparationRepository.add(persistentPreparation);
          });
          LOGGER.info("Upgrade from {} to {} done.", Preparation.class, PersistentPreparation.class);
  
          LOGGER.info("Migration of step ids in preparation...");
          final Stream<PersistentPreparation> persistentPreparations =
                  preparationRepository.list(PersistentPreparation.class);
          persistentPreparations.forEach(p -> {
              LOGGER.info("Migration of preparation #{}", p.getId());
              final List<String> stepsIds = preparationUtils.listStepsIds(p.getHeadId(), preparationRepository);
              p.setSteps(stepsIds);
  
              final DataSetMetadata metadata = dataSetMetadataRepository.get(p.getDataSetId());
              if (metadata != null) {
                  LOGGER.info("Set metadata {} in preparation {}.", p.getDataSetId(), p.getId());
                  p.setRowMetadata(metadata.getRowMetadata());
              } else {
                  LOGGER.info("Metadata {} not found for preparation {}.", p.getDataSetId(), p.getId());
                  p.setRowMetadata(new RowMetadata());
              }
  
              preparationRepository.add(p);
              LOGGER.info("Migration of preparation #{} done ({} steps)", p.getId(), stepsIds.size());
          });
          LOGGER.info("Migration of step ids in preparation done.");
      }
focal_method.class_method_signature: ToPEPersistentIdentifiable.run()
focal_method.full_signature: @Override public void run()
focal_method.identifier: run
focal_method.invocations: debug forEach list remove turnToPersistentStep add debug incrementAndGet info get debug list forEach remove turnToPersistentPreparation add info info list forEach info getId listStepsIds getHeadId setSteps get getDataSetId info getDataSetId getId setRowMetadata getRowMetadata info getDataSetId getId setRowMetadata add info getId size info
focal_method.modifiers: @Override public
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void run()