diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-02-13 17:51:42 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-02-13 17:51:42 +0100 |
commit | 5edf34024a334785a5f045fafebc20b10d46761f (patch) | |
tree | 9b0c468e72b4e635d854c761bddfc0eba653d724 /sonar-batch/src/test/java/org/sonar | |
parent | 5a6ded21de3623dc57d5ddc1667be27d855db493 (diff) | |
download | sonarqube-5edf34024a334785a5f045fafebc20b10d46761f.tar.gz sonarqube-5edf34024a334785a5f045fafebc20b10d46761f.zip |
Add unit test to ListTasksTask
Diffstat (limited to 'sonar-batch/src/test/java/org/sonar')
-rw-r--r-- | sonar-batch/src/test/java/org/sonar/batch/tasks/ListTasksTaskTest.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/sonar-batch/src/test/java/org/sonar/batch/tasks/ListTasksTaskTest.java b/sonar-batch/src/test/java/org/sonar/batch/tasks/ListTasksTaskTest.java new file mode 100644 index 00000000000..d66c0c688ed --- /dev/null +++ b/sonar-batch/src/test/java/org/sonar/batch/tasks/ListTasksTaskTest.java @@ -0,0 +1,44 @@ +/* + * Sonar, open source software quality management tool. + * Copyright (C) 2008-2012 SonarSource + * mailto:contact AT sonarsource DOT com + * + * Sonar is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * Sonar is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Sonar; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02 + */ +package org.sonar.batch.tasks; + +import org.junit.Test; +import org.sonar.api.task.TaskDefinition; + +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.spy; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; + +public class ListTasksTaskTest { + @Test + public void should_list_available_tasks() { + TaskDefinition def = TaskDefinition.create().setCommand("purge").setName("Purge").setDescription("Purge database"); + Tasks tasks = mock(Tasks.class); + when(tasks.getTaskDefinitions()).thenReturn(new TaskDefinition[]{def}); + ListTasksTask task = spy(new ListTasksTask(tasks)); + + task.execute(); + + verify(task, times(1)).log("Available tasks:"); + verify(task, times(1)).log(" - purge: Purge database"); + } +} |