/
SonarSlackPusherTest.java
73 lines (57 loc) · 22.3 KB
/
SonarSlackPusherTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package org.jenkinsci.plugins.sonarslackpusher.test;
import org.jenkinsci.plugins.sonarslackpusher.SonarSlackPusher;
import org.junit.Ignore;
import org.junit.Test;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
public class SonarSlackPusherTest {
@Test
@Ignore
public void testSonarHook() throws Exception {
//SonarSlackPusher ssp = new SonarSlackPusher("", "", "http://sonar.company.org:9000");
//Method getSonarData = ssp.getClass().getMethod("getSonarData");
//getSonarData.setAccessible(true);
//getSonarData.invoke(ssp);
//ssp.getSonarData();
}
@Test
@Ignore
public void testParseData() throws Exception {
//String d = "[{\"id\":29064,\"key\":\"com.vips.annoysrv:annoysrv-manager-service\",\"name\":\"Vips Annoysrv Service\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-02-19T14:56:03+0100\",\"creationDate\":\"2015-02-19T14:56:03+0100\",\"lname\":\"Vips AdServer Manager Service\",\"version\":\"0-SNAPSHOT\",\"description\":\"\",\"msr\":[{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":null,\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":12.0,\"frmt_val\":\"12\",\"alert\":null,\"alert_text\":null}]},{\"id\":25181,\"key\":\"com.videoplaza.annoysrv:annoysrv:MASTER\",\"name\":\"Vips Karbon 2 MASTER\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-05T09:10:51+0100\",\"creationDate\":\"2015-02-16T19:58:41+0100\",\"lname\":\"Vips Karbon 2 MASTER\",\"version\":\"0-SNAPSHOT\",\"branch\":\"MASTER\",\"description\":\"Dedicated ad server for online video.\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":null,\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":55.0,\"frmt_val\":\"55\",\"alert\":null,\"alert_text\":null}]},{\"id\":24448,\"key\":\"com.videoplaza.forecast.api:root\",\"name\":\"Forecast API root\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T09:50:17+0100\",\"creationDate\":\"2015-02-12T11:38:48+0100\",\"lname\":\"Forecast API root\",\"version\":\"0-SNAPSHOT\",\"description\":\"\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":33.1,\"frmt_val\":\"33.1%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":31124,\"key\":\"com.videoplaza.forecast.api:root:KAR-8991\",\"name\":\"Forecast API root KAR-8991\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T09:57:11+0100\",\"creationDate\":\"2015-03-06T09:51:47+0100\",\"lname\":\"Forecast API root KAR-8991\",\"version\":\"0-SNAPSHOT\",\"branch\":\"KAR-8991\",\"description\":\"\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":33.1,\"frmt_val\":\"33.1%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":31629,\"key\":\"com.videoplaza.annoysrv:annoysrv-manager-service:KAR-8991\",\"name\":\"Vips AdServer Manager Service KAR-8991\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T11:02:28+0100\",\"creationDate\":\"2015-03-06T10:25:26+0100\",\"lname\":\"Vips AdServer Manager Service KAR-8991\",\"version\":\"0-SNAPSHOT\",\"branch\":\"KAR-8991\",\"description\":\"\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":null,\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":12.0,\"frmt_val\":\"12\",\"alert\":null,\"alert_text\":null}]},{\"id\":33849,\"key\":\"com.videoplaza.forecast.api:root:KAR-8991-E\",\"name\":\"Forecast API root KAR-8991-E\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T13:32:31+0100\",\"creationDate\":\"2015-03-06T13:32:32+0100\",\"lname\":\"Forecast API root KAR-8991-E\",\"version\":\"0-SNAPSHOT\",\"branch\":\"KAR-8991-E\",\"description\":\"\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":33.1,\"frmt_val\":\"33.1%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34080,\"key\":\"com.videoplaza.forecast:forecast-background-scheduler:newSonar\",\"name\":\"forecast-background-scheduler newSonar\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T14:52:04+0100\",\"creationDate\":\"2015-03-06T14:52:04+0100\",\"lname\":\"forecast-background-scheduler newSonar\",\"version\":\"0-SNAPSHOT\",\"branch\":\"newSonar\",\"description\":\"Forecast Background Scheduler\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":61.3,\"frmt_val\":\"61.3%\",\"alert\":\"WARN\",\"alert_text\":\"Coverage < 80\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34091,\"key\":\"com.videoplaza.forecast:forecast-common:newSonar\",\"name\":\"forecast-common newSonar\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T14:52:19+0100\",\"creationDate\":\"2015-03-06T14:52:19+0100\",\"lname\":\"forecast-common newSonar\",\"version\":\"0-SNAPSHOT\",\"branch\":\"newSonar\",\"description\":\"Forecast Common\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":23.2,\"frmt_val\":\"23.2%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34112,\"key\":\"com.videoplaza.forecast:forecast-data-sampler:newSonar\",\"name\":\"forecast-data-sampler newSonar\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T14:52:36+0100\",\"creationDate\":\"2015-03-06T14:52:36+0100\",\"lname\":\"forecast-data-sampler newSonar\",\"version\":\"0-SNAPSHOT\",\"branch\":\"newSonar\",\"description\":\"Forecast Data Sampler\",\"msr\":[{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34131,\"key\":\"com.videoplaza.forecast:forecast-worker:newSonar\",\"name\":\"forecast-worker newSonar\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-06T14:52:51+0100\",\"creationDate\":\"2015-03-06T14:52:51+0100\",\"lname\":\"forecast-worker newSonar\",\"version\":\"0-SNAPSHOT\",\"branch\":\"newSonar\",\"description\":\"Forecast Worker\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":43.0,\"frmt_val\":\"43.0%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":30920,\"key\":\"com.videoplaza.forecast.api:root:MASTER\",\"name\":\"Forecast API root MASTER\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-12T06:03:55+0100\",\"creationDate\":\"2015-02-24T12:50:01+0100\",\"lname\":\"Forecast API root MASTER\",\"version\":\"0-SNAPSHOT\",\"branch\":\"MASTER\",\"description\":\"\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":31.3,\"frmt_val\":\"31.3%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34214,\"key\":\"com.videoplaza.forecast:forecast-background-scheduler:NYBERG\",\"name\":\"forecast-background-scheduler NYBERG\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:03:37+0100\",\"creationDate\":\"2015-03-16T15:48:32+0100\",\"lname\":\"forecast-background-scheduler NYBERG\",\"version\":\"0-SNAPSHOT\",\"branch\":\"NYBERG\",\"description\":\"Forecast Background Scheduler\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":61.3,\"frmt_val\":\"61.3%\",\"alert\":\"WARN\",\"alert_text\":\"Coverage < 80\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34225,\"key\":\"com.videoplaza.forecast:forecast-common:NYBERG\",\"name\":\"forecast-common NYBERG\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:03:47+0100\",\"creationDate\":\"2015-03-16T15:48:43+0100\",\"lname\":\"forecast-common NYBERG\",\"version\":\"0-SNAPSHOT\",\"branch\":\"NYBERG\",\"description\":\"Forecast Common\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":23.2,\"frmt_val\":\"23.2%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34246,\"key\":\"com.videoplaza.forecast:forecast-data-sampler:NYBERG\",\"name\":\"forecast-data-sampler NYBERG\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:03:57+0100\",\"creationDate\":\"2015-03-16T15:48:54+0100\",\"lname\":\"forecast-data-sampler NYBERG\",\"version\":\"0-SNAPSHOT\",\"branch\":\"NYBERG\",\"description\":\"Forecast Data Sampler\",\"msr\":[{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34265,\"key\":\"com.videoplaza.forecast:forecast-worker:NYBERG\",\"name\":\"forecast-worker NYBERG\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:04:09+0100\",\"creationDate\":\"2015-03-16T15:49:04+0100\",\"lname\":\"forecast-worker NYBERG\",\"version\":\"0-SNAPSHOT\",\"branch\":\"NYBERG\",\"description\":\"Forecast Worker\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":42.9,\"frmt_val\":\"42.9%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":25054,\"key\":\"com.videoplaza.forecast:forecast-background-scheduler:MASTER\",\"name\":\"forecast-background-scheduler MASTER\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:29:44+0100\",\"creationDate\":\"2015-02-16T19:53:26+0100\",\"lname\":\"forecast-background-scheduler MASTER\",\"version\":\"0-SNAPSHOT\",\"branch\":\"MASTER\",\"description\":\"Forecast Background Scheduler\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":61.3,\"frmt_val\":\"61.3%\",\"alert\":\"WARN\",\"alert_text\":\"Coverage < 80\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":25065,\"key\":\"com.videoplaza.forecast:forecast-common:MASTER\",\"name\":\"forecast-common MASTER\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:29:53+0100\",\"creationDate\":\"2015-02-16T19:53:37+0100\",\"lname\":\"forecast-common MASTER\",\"version\":\"0-SNAPSHOT\",\"branch\":\"MASTER\",\"description\":\"Forecast Common\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":23.2,\"frmt_val\":\"23.2%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":25086,\"key\":\"com.videoplaza.forecast:forecast-data-sampler:MASTER\",\"name\":\"forecast-data-sampler MASTER\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:30:04+0100\",\"creationDate\":\"2015-02-16T19:53:49+0100\",\"lname\":\"forecast-data-sampler MASTER\",\"version\":\"0-SNAPSHOT\",\"branch\":\"MASTER\",\"description\":\"Forecast Data Sampler\",\"msr\":[{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":25105,\"key\":\"com.videoplaza.forecast:forecast-worker:MASTER\",\"name\":\"forecast-worker MASTER\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-16T16:30:14+0100\",\"creationDate\":\"2015-02-16T19:53:59+0100\",\"lname\":\"forecast-worker MASTER\",\"version\":\"0-SNAPSHOT\",\"branch\":\"MASTER\",\"description\":\"Forecast Worker\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":42.9,\"frmt_val\":\"42.9%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":28931,\"key\":\"com.videoplaza.forecast:forecast-background-scheduler\",\"name\":\"forecast-background-scheduler\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:07:21+0100\",\"creationDate\":\"2015-02-19T13:33:41+0100\",\"lname\":\"forecast-background-scheduler\",\"version\":\"0-SNAPSHOT\",\"description\":\"Forecast Background Scheduler\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":61.3,\"frmt_val\":\"61.3%\",\"alert\":\"WARN\",\"alert_text\":\"Coverage < 80\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":28942,\"key\":\"com.videoplaza.forecast:forecast-common\",\"name\":\"forecast-common\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:07:30+0100\",\"creationDate\":\"2015-02-19T13:33:53+0100\",\"lname\":\"forecast-common\",\"version\":\"0-SNAPSHOT\",\"description\":\"Forecast Common\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":23.2,\"frmt_val\":\"23.2%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":28963,\"key\":\"com.videoplaza.forecast:forecast-data-sampler\",\"name\":\"forecast-data-sampler\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:07:41+0100\",\"creationDate\":\"2015-02-19T13:34:08+0100\",\"lname\":\"forecast-data-sampler\",\"version\":\"0-SNAPSHOT\",\"description\":\"Forecast Data Sampler\",\"msr\":[{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":28982,\"key\":\"com.videoplaza.forecast:forecast-worker\",\"name\":\"forecast-worker\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:07:50+0100\",\"creationDate\":\"2015-02-19T13:34:21+0100\",\"lname\":\"forecast-worker\",\"version\":\"0-SNAPSHOT\",\"description\":\"Forecast Worker\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":42.9,\"frmt_val\":\"42.9%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34346,\"key\":\"com.videoplaza.forecast:forecast-background-scheduler:master\",\"name\":\"forecast-background-scheduler master\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:24:16+0100\",\"creationDate\":\"2015-03-17T15:24:16+0100\",\"lname\":\"forecast-background-scheduler master\",\"version\":\"0-SNAPSHOT\",\"branch\":\"master\",\"description\":\"Forecast Background Scheduler\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":61.3,\"frmt_val\":\"61.3%\",\"alert\":\"WARN\",\"alert_text\":\"Coverage < 80\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34357,\"key\":\"com.videoplaza.forecast:forecast-common:master\",\"name\":\"forecast-common master\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:24:25+0100\",\"creationDate\":\"2015-03-17T15:24:25+0100\",\"lname\":\"forecast-common master\",\"version\":\"0-SNAPSHOT\",\"branch\":\"master\",\"description\":\"Forecast Common\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":23.2,\"frmt_val\":\"23.2%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34378,\"key\":\"com.videoplaza.forecast:forecast-data-sampler:master\",\"name\":\"forecast-data-sampler master\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:24:36+0100\",\"creationDate\":\"2015-03-17T15:24:36+0100\",\"lname\":\"forecast-data-sampler master\",\"version\":\"0-SNAPSHOT\",\"branch\":\"master\",\"description\":\"Forecast Data Sampler\",\"msr\":[{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]},{\"id\":34397,\"key\":\"com.videoplaza.forecast:forecast-worker:master\",\"name\":\"forecast-worker master\",\"scope\":\"PRJ\",\"qualifier\":\"TRK\",\"date\":\"2015-03-17T15:24:46+0100\",\"creationDate\":\"2015-03-17T15:24:46+0100\",\"lname\":\"forecast-worker master\",\"version\":\"0-SNAPSHOT\",\"branch\":\"master\",\"description\":\"Forecast Worker\",\"msr\":[{\"key\":\"test_success_density\",\"val\":100.0,\"frmt_val\":\"100.0%\",\"alert\":null,\"alert_text\":null},{\"key\":\"coverage\",\"val\":42.9,\"frmt_val\":\"42.9%\",\"alert\":\"ERROR\",\"alert_text\":\"Coverage < 60\"},{\"key\":\"blocker_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null},{\"key\":\"critical_violations\",\"val\":0.0,\"frmt_val\":\"0\",\"alert\":\"OK\",\"alert_text\":null}]}]";
//SonarSlackPusher ssp = new SonarSlackPusher("https://hooks.slack.com/services/12345678/12345678/12345678C9ugOn8YYaf7s2hV", "http://sonar.company.org:9000", "fbs master");
//ssp.getAllNotifications(d);
//ssp.pushNotification();
}
@Test
public void testReplaceWithParameters() throws Exception {
SonarSlackPusher ssp = new SonarSlackPusher("", "", "http://sonar.company.org:9000", "", "");
Method replace = ssp.getClass().getDeclaredMethod("getParams", String.class);
replace.setAccessible(true);
String s = "abc${efg}hij";
assertEquals(1, ((List<String>) (replace.invoke(ssp, s))).size());
assertEquals("efg", ((ArrayList<String>) (replace.invoke(ssp, s))).get(0));
s = "123${köadsfökjadsf";
assertEquals(0, ((List<String>) (replace.invoke(ssp, s))).size());
s = "123${456${789}0";
assertEquals(1, ((List<String>) (replace.invoke(ssp, s))).size());
assertEquals("789", ((ArrayList<String>) (replace.invoke(ssp, s))).get(0));
s = "${}";
assertEquals(0, ((List<String>) (replace.invoke(ssp, s))).size());
s = "${456${789}0";
assertEquals(1, ((List<String>) (replace.invoke(ssp, s))).size());
assertEquals("789", ((ArrayList<String>) (replace.invoke(ssp, s))).get(0));
s = "${456${789}";
assertEquals(1, ((List<String>) (replace.invoke(ssp, s))).size());
assertEquals("789", ((ArrayList<String>) (replace.invoke(ssp, s))).get(0));
s = "${456}${789}";
assertEquals(2, ((List<String>) (replace.invoke(ssp, s))).size());
assertEquals("456", ((ArrayList<String>) (replace.invoke(ssp, s))).get(0));
assertEquals("789", ((ArrayList<String>) (replace.invoke(ssp, s))).get(1));
s = "123${456}${789}0";
assertEquals(2, ((List<String>) (replace.invoke(ssp, s))).size());
assertEquals("456", ((ArrayList<String>) (replace.invoke(ssp, s))).get(0));
assertEquals("789", ((ArrayList<String>) (replace.invoke(ssp, s))).get(1));
}
}