99import static org .mockito .Mockito .when ;
1010
1111import com .fasterxml .jackson .databind .ObjectMapper ;
12+ import com .google .common .collect .ImmutableMap ;
1213import com .ibm .mq .constants .CMQC ;
1314import com .ibm .mq .constants .CMQCFC ;
1415import com .ibm .mq .headers .pcf .PCFMessage ;
@@ -66,32 +67,24 @@ void testProcessPcfRequestAndPublishQMetricsForInquireQStatusCmd() throws Except
6667 collectorContext , request , "*" , InquireQStatusCmdCollector .ATTRIBUTES );
6768
6869 Map <String , Map <String , Long >> expectedValues =
69- new HashMap <String , Map <String , Long >>() {
70- {
71- put (
70+ new HashMap <String , Map <String , Long >>(
71+ ImmutableMap .of (
7272 "DEV.DEAD.LETTER.QUEUE" ,
73- new HashMap <String , Long >() {
74- {
75- put ("mq.oldest.msg.age" , -1L );
76- put ("mq.uncommitted.messages" , 0L );
77- put ("mq.onqtime.1" , -1L );
78- put ("mq.onqtime.2" , -1L );
79- put ("mq.queue.depth" , 0L );
80- }
81- });
82- put (
73+ new HashMap <>(
74+ ImmutableMap .of (
75+ "mq.oldest.msg.age" , -1L ,
76+ "mq.uncommitted.messages" , 0L ,
77+ "mq.onqtime.1" , -1L ,
78+ "mq.onqtime.2" , -1L ,
79+ "mq.queue.depth" , 0L )),
8380 "DEV.QUEUE.1" ,
84- new HashMap <String , Long >() {
85- {
86- put ("mq.oldest.msg.age" , -1L );
87- put ("mq.uncommitted.messages" , 10L );
88- put ("mq.onqtime.1" , -1L );
89- put ("mq.onqtime.2" , -1L );
90- put ("mq.queue.depth" , 1L );
91- }
92- });
93- }
94- };
81+ new HashMap <String , Long >(
82+ ImmutableMap .of (
83+ "mq.oldest.msg.age" , -1L ,
84+ "mq.uncommitted.messages" , 10L ,
85+ "mq.onqtime.1" , -1L ,
86+ "mq.onqtime.2" , -1L ,
87+ "mq.queue.depth" , 1L ))));
9588
9689 for (MetricData metric : otelTesting .getMetrics ()) {
9790 for (LongPointData d : metric .getLongGaugeData ().getPoints ()) {
@@ -115,30 +108,22 @@ void testProcessPcfRequestAndPublishQMetricsForInquireQCmd() throws Exception {
115108 collectorContext , request , "*" , InquireQCmdCollector .ATTRIBUTES );
116109
117110 Map <String , Map <String , Long >> expectedValues =
118- new HashMap <String , Map <String , Long >>() {
119- {
120- put (
111+ new HashMap <>(
112+ ImmutableMap .of (
121113 "DEV.DEAD.LETTER.QUEUE" ,
122- new HashMap <String , Long >() {
123- {
124- put ("mq.queue.depth" , 2L );
125- put ("mq.max.queue.depth" , 5000L );
126- put ("mq.open.input.count" , 2L );
127- put ("mq.open.output.count" , 2L );
128- }
129- });
130- put (
114+ new HashMap <>(
115+ ImmutableMap .of (
116+ "mq.queue.depth" , 2L ,
117+ "mq.max.queue.depth" , 5000L ,
118+ "mq.open.input.count" , 2L ,
119+ "mq.open.output.count" , 2L )),
131120 "DEV.QUEUE.1" ,
132- new HashMap <String , Long >() {
133- {
134- put ("mq.queue.depth" , 3L );
135- put ("mq.max.queue.depth" , 5000L );
136- put ("mq.open.input.count" , 3L );
137- put ("mq.open.output.count" , 3L );
138- }
139- });
140- }
141- };
121+ new HashMap <>(
122+ ImmutableMap .of (
123+ "mq.queue.depth" , 3L ,
124+ "mq.max.queue.depth" , 5000L ,
125+ "mq.open.input.count" , 3L ,
126+ "mq.open.output.count" , 3L ))));
142127
143128 for (MetricData metric : otelTesting .getMetrics ()) {
144129 for (LongPointData d : metric .getLongGaugeData ().getPoints ()) {
@@ -183,7 +168,7 @@ void testProcessPcfRequestAndPublishQMetricsForResetQStatsCmd() throws Exception
183168 MQCFST [type: 4, strucLength: 24, parameter: 2016 (MQCA_Q_NAME), codedCharSetId: 0, stringLength: 1, string: *]
184169 MQCFIL [type: 5, strucLength: 32, parameter: 1026 (MQIACF_Q_STATUS_ATTRS), count: 4, values: {2016, 1226, 1227, 1027}]
185170 */
186- private PCFMessage createPCFRequestForInquireQStatusCmd () {
171+ private static PCFMessage createPCFRequestForInquireQStatusCmd () {
187172 PCFMessage request = new PCFMessage (CMQCFC .MQCMD_INQUIRE_Q_STATUS );
188173 request .addParameter (CMQC .MQCA_Q_NAME , "*" );
189174 request .addParameter (CMQCFC .MQIACF_Q_STATUS_ATTRS , new int [] {2016 , 1226 , 1227 , 1027 });
@@ -218,7 +203,7 @@ private PCFMessage createPCFRequestForInquireQStatusCmd() {
218203 MQCFIL [type: 5, strucLength: 24, parameter: 1226 (MQIACF_Q_TIME_INDICATOR), count: 2, values: {-1, -1}]
219204 MQCFIN [type: 3, strucLength: 16, parameter: 1027 (MQIACF_UNCOMMITTED_MSGS), value: 0]"
220205 */
221- private PCFMessage [] createPCFResponseForInquireQStatusCmd () {
206+ private static PCFMessage [] createPCFResponseForInquireQStatusCmd () {
222207 PCFMessage response1 = new PCFMessage (2 , CMQCFC .MQCMD_INQUIRE_Q_STATUS , 1 , false );
223208 response1 .addParameter (CMQC .MQCA_Q_NAME , "AMQ.5AF1608820C7D76E" );
224209 response1 .addParameter (CMQCFC .MQIACF_Q_STATUS_TYPE , 1105 );
@@ -253,7 +238,7 @@ private PCFMessage[] createPCFResponseForInquireQStatusCmd() {
253238 MQCFIN [type: 3, strucLength: 16, parameter: 20 (MQIA_Q_TYPE), value: 1001]
254239 MQCFIL [type: 5, strucLength: 36, parameter: 1002 (MQIACF_Q_ATTRS), count: 5, values: {2016, 15, 3, 17, 18}]
255240 */
256- private PCFMessage createPCFRequestForInquireQCmd () {
241+ private static PCFMessage createPCFRequestForInquireQCmd () {
257242 PCFMessage request = new PCFMessage (CMQCFC .MQCMD_INQUIRE_Q );
258243 request .addParameter (CMQC .MQCA_Q_NAME , "*" );
259244 request .addParameter (CMQC .MQIA_Q_TYPE , CMQC .MQQT_ALL );
@@ -290,7 +275,7 @@ private PCFMessage createPCFRequestForInquireQCmd() {
290275 MQCFIN [type: 3, strucLength: 16, parameter: 18 (MQIA_OPEN_OUTPUT_COUNT), value: 0]"
291276 */
292277
293- private PCFMessage [] createPCFResponseForInquireQCmd () {
278+ private static PCFMessage [] createPCFResponseForInquireQCmd () {
294279 PCFMessage response1 = new PCFMessage (2 , CMQCFC .MQCMD_INQUIRE_Q , 1 , false );
295280 response1 .addParameter (CMQC .MQCA_Q_NAME , "AMQ.5AF1608820C76D80" );
296281 response1 .addParameter (CMQC .MQIA_Q_TYPE , 1 );
@@ -326,7 +311,7 @@ private PCFMessage[] createPCFResponseForInquireQCmd() {
326311 MQCFH [type: 1, strucLength: 36, version: 1, command: 17 (MQCMD_RESET_Q_STATS), msgSeqNumber: 1, control: 1, compCode: 0, reason: 0, parameterCount: 1]
327312 MQCFST [type: 4, strucLength: 24, parameter: 2016 (MQCA_Q_NAME), codedCharSetId: 0, stringLength: 1, string: *]
328313 */
329- private PCFMessage createPCFRequestForResetQStatsCmd () {
314+ private static PCFMessage createPCFRequestForResetQStatsCmd () {
330315 PCFMessage request = new PCFMessage (CMQCFC .MQCMD_RESET_Q_STATS );
331316 request .addParameter (CMQC .MQCA_Q_NAME , "*" );
332317 return request ;
@@ -341,7 +326,7 @@ private PCFMessage createPCFRequestForResetQStatsCmd() {
341326 MQCFIN [type: 3, strucLength: 16, parameter: 36 (MQIA_HIGH_Q_DEPTH), value: 0]
342327 MQCFIN [type: 3, strucLength: 16, parameter: 35 (MQIA_TIME_SINCE_RESET), value: 65]"
343328 */
344- private PCFMessage [] createPCFResponseForResetQStatsCmd () {
329+ private static PCFMessage [] createPCFResponseForResetQStatsCmd () {
345330 PCFMessage response1 = new PCFMessage (2 , CMQCFC .MQCMD_RESET_Q_STATS , 1 , false );
346331 response1 .addParameter (CMQC .MQCA_Q_NAME , "DEV.DEAD.LETTER.QUEUE" );
347332 response1 .addParameter (CMQC .MQIA_MSG_ENQ_COUNT , 3 );
0 commit comments