Sonar Critical Fix
[dcaegen2/analytics/tca.git] / dcae-analytics-common / src / test / java / org / openecomp / dcae / apod / analytics / common / service / processor / AbstractProcessorContextTest.java
1 /*\r
2  * ===============================LICENSE_START======================================\r
3  *  dcae-analytics\r
4  * ================================================================================\r
5  *    Copyright © 2017 AT&T Intellectual Property. All rights reserved.\r
6  * ================================================================================\r
7  *  Licensed under the Apache License, Version 2.0 (the "License");\r
8  *  you may not use this file except in compliance with the License.\r
9  *   You may obtain a copy of the License at\r
10  *\r
11  *          http://www.apache.org/licenses/LICENSE-2.0\r
12  *\r
13  *  Unless required by applicable law or agreed to in writing, software\r
14  *  distributed under the License is distributed on an "AS IS" BASIS,\r
15  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  *  See the License for the specific language governing permissions and\r
17  *  limitations under the License.\r
18  *  ============================LICENSE_END===========================================\r
19  */\r
20 \r
21 package org.openecomp.dcae.apod.analytics.common.service.processor;\r
22 \r
23 import org.junit.Test;\r
24 import org.openecomp.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;\r
25 \r
26 import java.util.List;\r
27 \r
28 import static org.hamcrest.CoreMatchers.is;\r
29 import static org.junit.Assert.assertThat;\r
30 \r
31 /**\r
32  * @author Rajiv Singla . Creation Date: 12/12/2016.\r
33  */\r
34 public class AbstractProcessorContextTest extends BaseAnalyticsCommonUnitTest {\r
35 \r
36     class TestAbstractMessageProcessorContext extends AbstractProcessorContext {\r
37 \r
38         public TestAbstractMessageProcessorContext(String message, boolean canProcessingContinue) {\r
39             super(message, canProcessingContinue);\r
40         }\r
41     }\r
42 \r
43 \r
44     @Test\r
45     public void testGetMessage() throws Exception {\r
46         TestAbstractMessageProcessorContext testProcessorContext =\r
47                 new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);\r
48         final String message = testProcessorContext.getMessage();\r
49         assertThat("Message Processor message must match", message, is(TEST_MESSAGE_PROCESSOR_MESSAGE));\r
50     }\r
51 \r
52     @Test\r
53     public void testCanProcessingContinue() throws Exception {\r
54         TestAbstractMessageProcessorContext testProcessorContext =\r
55                 new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);\r
56         final boolean canProcessingContinue = testProcessorContext.canProcessingContinue();\r
57         assertThat("Message Can Processing flag must be true", canProcessingContinue, is(true));\r
58     }\r
59 \r
60     @Test\r
61     public void testSetProcessingContinueFlag() throws Exception {\r
62         TestAbstractMessageProcessorContext testProcessorContext =\r
63                 new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);\r
64         testProcessorContext.setProcessingContinueFlag(false);\r
65         assertThat("Message Can processing flag must be false",\r
66                 testProcessorContext.canProcessingContinue(), is(false));\r
67 \r
68     }\r
69 \r
70     @Test\r
71     public void testGetMessageProcessors() throws Exception {\r
72         TestAbstractMessageProcessorContext testProcessorContext =\r
73                 new TestAbstractMessageProcessorContext(TEST_MESSAGE_PROCESSOR_MESSAGE, true);\r
74         final List<? super MessageProcessor<? extends ProcessorContext>> messageProcessors =\r
75                 testProcessorContext.getMessageProcessors();\r
76         assertThat("Message processor processing message must match", messageProcessors.size(), is(0));\r
77     }\r
78 \r
79 }\r