aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-process/src/test/java
diff options
context:
space:
mode:
authorSimon Brandhof <simon.brandhof@sonarsource.com>2016-11-16 15:51:13 +0100
committerSimon Brandhof <simon.brandhof@sonarsource.com>2016-11-17 07:36:51 +0100
commitb612813d06583cb5021469afb6a06c15ecdc3662 (patch)
treea521ed1c5d728180f509fd41fc9822f8a7df9b9e /server/sonar-process/src/test/java
parent75bae1e0539dd6504c898814621262f1739d08d4 (diff)
downloadsonarqube-b612813d06583cb5021469afb6a06c15ecdc3662.tar.gz
sonarqube-b612813d06583cb5021469afb6a06c15ecdc3662.zip
SONAR-8383 add param "process" to api/system/logs
Diffstat (limited to 'server/sonar-process/src/test/java')
-rw-r--r--server/sonar-process/src/test/java/org/sonar/process/ProcessIdTest.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/server/sonar-process/src/test/java/org/sonar/process/ProcessIdTest.java b/server/sonar-process/src/test/java/org/sonar/process/ProcessIdTest.java
index 4eebf2cd124..5a652bcb110 100644
--- a/server/sonar-process/src/test/java/org/sonar/process/ProcessIdTest.java
+++ b/server/sonar-process/src/test/java/org/sonar/process/ProcessIdTest.java
@@ -21,12 +21,17 @@ package org.sonar.process;
import java.util.HashSet;
import java.util.Set;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.ExpectedException;
import static org.assertj.core.api.Assertions.assertThat;
public class ProcessIdTest {
+ @Rule
+ public ExpectedException expectedException = ExpectedException.none();
+
@Test
public void test_constants() {
assertThat(ProcessId.COMPUTE_ENGINE.getKey()).isEqualTo("ce");
@@ -44,4 +49,28 @@ public class ProcessIdTest {
assertThat(ipcIndices).hasSize(ProcessId.values().length);
assertThat(keys).hasSize(ProcessId.values().length);
}
+
+ @Test
+ public void fromKey_searches_process_by_its_key() {
+ assertThat(ProcessId.fromKey("app")).isEqualTo(ProcessId.APP);
+ assertThat(ProcessId.fromKey("ce")).isEqualTo(ProcessId.COMPUTE_ENGINE);
+ assertThat(ProcessId.fromKey("es")).isEqualTo(ProcessId.ELASTICSEARCH);
+ assertThat(ProcessId.fromKey("web")).isEqualTo(ProcessId.WEB_SERVER);
+ }
+
+ @Test
+ public void fromKey_throws_IAE_if_key_is_null() {
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("Process [null] does not exist");
+
+ ProcessId.fromKey(null);
+ }
+
+ @Test
+ public void fromKey_throws_IAE_if_key_does_not_exist() {
+ expectedException.expect(IllegalArgumentException.class);
+ expectedException.expectMessage("Process [foo] does not exist");
+
+ ProcessId.fromKey("foo");
+ }
}