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 shouldSortTasks() throws Exception {
          // given
          tasks.add(new MockUpgradeTask("12.3-EE", "fourth", 4, USER)); // 4
          tasks.add(new MockUpgradeTask("1.4-EE", "second", 2, USER)); // 2
          tasks.add(new MockUpgradeTask("75.12.0-EE", "sixth", 6, USER)); // 6
          tasks.add(new MockUpgradeTask("100.5.0-EE", "seventh", 7, USER)); // 7
          tasks.add(new MockUpgradeTask("2.5-PE", "third", 3, USER)); // 3
          tasks.add(new MockUpgradeTask("1.3-PE", "first", 1, USER)); // 1
          tasks.add(new MockUpgradeTask("50.4-PE", "fifth", 5, USER)); // 5
  
          // when
          service.sortAndCheckTasks();
  
          // then
          int i = 1;
          for (UpgradeTask task : tasks) {
              assertEquals(i, task.getId().getOrder());
              i++;
          }
      }
test_case.class_method_signature: UpgradeServiceTest.shouldSortTasks()
test_case.full_signature: @Test public void shouldSortTasks()
test_case.identifier: shouldSortTasks
test_case.invocations: add add add add add add add sortAndCheckTasks assertEquals getOrder getId
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void shouldSortTasks()
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: @PostConstruct
      void sortAndCheckTasks() { // NOSONAR called by @PostConstruct annotation
          Collections.sort(tasks);
  
          Map<String, List<Integer>> groupTasks = new HashMap<>();
          List<UpgradeTaskId> conflictTasks = new ArrayList<>();
          tasks.stream().map(UpgradeTask::getId).forEach(id -> {
              // add the version entry if needed
              if (!groupTasks.containsKey(id.getVersion())) {
                  groupTasks.put(id.getVersion(), new ArrayList<>());
              }
              // check if there's already a task for this order
              final List<Integer> orders = groupTasks.get(id.getVersion());
              if (orders.contains(id.getOrder())) {
                  conflictTasks.add(id);
              } else {
                  orders.add(id.getOrder());
              }
          });
  
          if (!conflictTasks.isEmpty()) {
              throw new IllegalArgumentException("The are " + conflictTasks.size()
                      + " conflicted upgrade tasks (task with the same order for one version) : " + conflictTasks);
          }
      }
focal_method.class_method_signature: UpgradeService.sortAndCheckTasks()
focal_method.full_signature: @PostConstruct void sortAndCheckTasks()
focal_method.identifier: sortAndCheckTasks
focal_method.invocations: sort forEach map stream containsKey getVersion put getVersion get getVersion contains getOrder add add getOrder isEmpty size
focal_method.modifiers: @PostConstruct
focal_method.parameters: ()
focal_method.return: void
focal_method.signature: void sortAndCheckTasks()