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