diff options
author | Klaudio Sinani <klaudio.sinani@sonarsource.com> | 2021-11-17 22:54:06 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2021-11-19 20:03:27 +0000 |
commit | a3d88ea27c35921647d7602755828ca73e15e865 (patch) | |
tree | 5626c38afab1ea00ab9897da431476c17b478bbe /server/sonar-ce-common | |
parent | 92f482f2aa43e4aa36e0fda377d13b9dc3282ff9 (diff) | |
download | sonarqube-a3d88ea27c35921647d7602755828ca73e15e865.tar.gz sonarqube-a3d88ea27c35921647d7602755828ca73e15e865.zip |
SONAR-15631 - Refactor UTs to stop using ExpectedException
Diffstat (limited to 'server/sonar-ce-common')
-rw-r--r-- | server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java b/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java index 7dcc3045805..3eb566dfeef 100644 --- a/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java +++ b/server/sonar-ce-common/src/test/java/org/sonar/ce/queue/CeQueueImplTest.java @@ -27,7 +27,6 @@ import java.util.stream.IntStream; import javax.annotation.Nullable; import org.junit.Rule; import org.junit.Test; -import org.junit.rules.ExpectedException; import org.sonar.api.impl.utils.TestSystem2; import org.sonar.api.utils.System2; import org.sonar.ce.queue.CeTaskSubmit.Component; @@ -50,9 +49,9 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptyMap; import static org.apache.commons.lang.RandomStringUtils.randomAlphabetic; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; import static org.assertj.core.api.Assertions.catchThrowable; import static org.assertj.core.api.Assertions.tuple; -import static org.hamcrest.Matchers.startsWith; import static org.sonar.ce.queue.CeQueue.SubmitOption.UNIQUE_QUEUE_PER_MAIN_COMPONENT; public class CeQueueImplTest { @@ -63,8 +62,6 @@ public class CeQueueImplTest { private System2 system2 = new TestSystem2().setNow(NOW); @Rule - public ExpectedException expectedException = ExpectedException.none(); - @Rule public DbTester db = DbTester.create(system2); private DbSession session = db.getSession(); @@ -395,10 +392,9 @@ public class CeQueueImplTest { submit(CeTaskTypes.REPORT, newComponent(randomAlphabetic(11))); CeQueueDto ceQueueDto = db.getDbClient().ceQueueDao().peek(session, WORKER_UUID, false, false).get(); - expectedException.expect(IllegalStateException.class); - expectedException.expectMessage(startsWith("Task is in progress and can't be canceled")); - - underTest.cancel(db.getSession(), ceQueueDto); + assertThatThrownBy(() -> underTest.cancel(db.getSession(), ceQueueDto)) + .isInstanceOf(IllegalStateException.class) + .hasMessageStartingWith("Task is in progress and can't be canceled"); } @Test |