test_class.declarator: service
test_class.modifier: @InjectMocks
      private
test_class.original_string: @InjectMocks
      private UpgradeService service;
test_class.type: UpgradeService
test_class.var_name: service
test_class.declarator: repository
test_class.modifier: @Mock
      private
test_class.original_string: @Mock
      private UpgradeTaskRepository repository;
test_class.type: UpgradeTaskRepository
test_class.var_name: repository
test_class.declarator: tasks = new ArrayList<>()
test_class.modifier: private
test_class.original_string: private List<UpgradeTask> tasks = new ArrayList<>();
test_class.type: List<UpgradeTask>
test_class.var_name: tasks
test_class.file: dataprep-upgrade-common/src/test/java/org/talend/dataprep/upgrade/UpgradeServiceTest.java
test_class.identifier: UpgradeServiceTest
test_case.body: @Test
      public void shouldApplyTasksToUser() throws Exception {
          // given
          List<UpgradeTask> expected = new ArrayList<>();
          expected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-first", 1, USER));
          expected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-second", 2, USER));
          expected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-third", 3, USER));
          expected.add(new MockUpgradeTask("1.3.0-PE", "1.3.0-1-fourth", 1, USER));
          expected.add(new MockUpgradeTask("1.4.0-PE", "1.4.0-twelfth", 12, USER));
          expected.add(new MockUpgradeTask("2.12.0-EE", "2.12.0-fourth", 4, USER));
          expected.add(new MockUpgradeTask("10.5.0-EE", "2.12.0-fifth", 5, USER));
  
          List<UpgradeTask> unexpected = new ArrayList<>();
          unexpected.add(new MockUpgradeTask("1.2.0-PE", "1.2.0-second", 2, VERSION));
          unexpected.add(new MockUpgradeTask("1.3.0-PE", "1.3.0-1-fifth", 5, VERSION));
          unexpected.add(new MockUpgradeTask("1.4.0-PE", "1.4.0-eleventh", 11, VERSION));
          unexpected.add(new MockUpgradeTask("2.12.0-EE", "2.12.0-third", 3, VERSION));
  
          tasks.addAll(expected);
          tasks.addAll(unexpected);
  
          // when
          when(repository.isAlreadyApplied(anyString(), any())).thenReturn(false);
          service.upgradeUser("Mr Anonymous");
  
          // then
          for (UpgradeTask task : expected) {
              final MockUpgradeTask mockTask = (MockUpgradeTask) task;
              assertTrue(mockTask.applied);
          }
          for (UpgradeTask task : unexpected) {
              final MockUpgradeTask mockTask = (MockUpgradeTask) task;
              assertFalse(mockTask.applied);
          }
      }
test_case.class_method_signature: UpgradeServiceTest.shouldApplyTasksToUser()
test_case.full_signature: @Test public void shouldApplyTasksToUser()
test_case.identifier: shouldApplyTasksToUser
test_case.invocations: add add add add add add add add add add add addAll addAll thenReturn when isAlreadyApplied anyString any upgradeUser assertTrue assertFalse
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldApplyTasksToUser()
focal_class.declarator: LOG = getLogger(UpgradeService.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger LOG = getLogger(UpgradeService.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 UpgradeTaskRepository repository;
focal_class.type: UpgradeTaskRepository
focal_class.var_name: repository
focal_class.declarator: tasks = emptyList()
focal_class.modifier: @Autowired(required = false)
      private
focal_class.original_string: @Autowired(required = false)
      private List<UpgradeTask> tasks = emptyList();
focal_class.type: List<UpgradeTask>
focal_class.var_name: tasks
focal_class.file: dataprep-upgrade-common/src/main/java/org/talend/dataprep/upgrade/UpgradeService.java
focal_class.identifier: UpgradeService
focal_class.class_method_signature: UpgradeService.sortAndCheckTasks()
focal_class.full_signature: @PostConstruct void sortAndCheckTasks()
focal_class.identifier: sortAndCheckTasks
focal_class.modifiers: @PostConstruct
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void sortAndCheckTasks()
focal_class.class_method_signature: UpgradeService.needUpgrade()
focal_class.full_signature: public boolean needUpgrade()
focal_class.identifier: needUpgrade
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean needUpgrade()
focal_class.class_method_signature: UpgradeService.upgradeVersion()
focal_class.full_signature: public void upgradeVersion()
focal_class.identifier: upgradeVersion
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void upgradeVersion()
focal_class.class_method_signature: UpgradeService.upgradeUser(String userId)
focal_class.full_signature: public void upgradeUser(String userId)
focal_class.identifier: upgradeUser
focal_class.modifiers: public
focal_class.parameters: (String userId)
focal_class.return: void
focal_class.signature: void upgradeUser(String userId)
focal_class.class_method_signature: UpgradeService.setTasks(List<UpgradeTask> tasks)
focal_class.full_signature:  void setTasks(List<UpgradeTask> tasks)
focal_class.identifier: setTasks
focal_class.parameters: (List<UpgradeTask> tasks)
focal_class.return: void
focal_class.signature: void setTasks(List<UpgradeTask> tasks)
focal_method.body: public void upgradeUser(String userId) {
  
          LOG.info("Upgrade process starting for user {}", userId);
  
          int numberOfTasksApplied = 0;
          for (UpgradeTask task : tasks) {
  
              // skip non user upgrade task
              if (task.getTarget() != USER) {
                  LOG.debug("{} does not target users", task.getId());
                  continue;
              }
  
              final String targetId = USER.name() + '-' + userId;
  
              if (repository.isAlreadyApplied(targetId, task.getId())) {
                  LOG.debug("{} already applied for user {}, let's skip it", task.getId(), userId);
              } else {
                  LOG.debug("apply upgrade {} for user {}", task.getId(), userId);
                  task.run();
                  repository.applied(targetId, task.getId());
                  numberOfTasksApplied++;
              }
  
          }
          LOG.info("Upgrade process finished for user {}, {}/{} upgrade(s) performed", userId, numberOfTasksApplied,
                  tasks.size());
      }
focal_method.class_method_signature: UpgradeService.upgradeUser(String userId)
focal_method.full_signature: public void upgradeUser(String userId)
focal_method.identifier: upgradeUser
focal_method.invocations: info getTarget debug getId name isAlreadyApplied getId debug getId debug getId run applied getId info size
focal_method.modifiers: public
focal_method.parameters: (String userId)
focal_method.return: void
focal_method.signature: void upgradeUser(String userId)