3 * Copyright (C) 2009-2020 SonarSource SA
4 * mailto:info AT sonarsource DOT com
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 3 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 package org.sonar.ce.task.projectanalysis.taskprocessor;
22 import java.util.List;
23 import org.assertj.core.api.Assertions;
24 import org.junit.Test;
25 import org.mockito.Mockito;
26 import org.sonar.ce.task.CeTask;
27 import org.sonar.ce.task.container.TaskContainer;
28 import org.sonar.ce.task.step.ComputationStep;
29 import org.sonar.core.platform.ComponentContainer;
31 import static org.mockito.ArgumentMatchers.any;
32 import static org.sonar.ce.task.projectanalysis.taskprocessor.IssueSyncTaskProcessor.*;
33 import static org.sonar.db.ce.CeTaskTypes.BRANCH_ISSUE_SYNC;
35 public class IssueSyncTaskProcessorTest {
37 private ComponentContainer ceEngineContainer = Mockito.mock(ComponentContainer.class);
39 private IssueSyncTaskProcessor underTest = new IssueSyncTaskProcessor(ceEngineContainer);
40 private TaskContainer container = Mockito.spy(TaskContainer.class);
43 public void getHandledCeTaskTypes() {
44 Assertions.assertThat(underTest.getHandledCeTaskTypes()).containsExactly(BRANCH_ISSUE_SYNC);
48 public void newContainerPopulator() {
49 CeTask task = new CeTask.Builder()
50 .setOrganizationUuid("ORGANIZATION_UUID")
55 IssueSyncTaskProcessor.newContainerPopulator(task).populateContainer(container);
56 Mockito.verify(container, Mockito.times(4)).add(any());
60 public void orderedStepClasses(){
61 SyncComputationSteps syncComputationSteps = new SyncComputationSteps(null);
63 List<Class<? extends ComputationStep>> steps = syncComputationSteps.orderedStepClasses();
65 Assertions.assertThat(steps).containsExactly(IndexIssuesStep.class);