2 * ===============================LICENSE_START======================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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===========================================
21 package org.onap.dcae.apod.analytics.common.service.processor;
23 import org.junit.Test;
24 import org.onap.dcae.apod.analytics.common.BaseAnalyticsCommonUnitTest;
26 import java.util.List;
28 import static org.hamcrest.CoreMatchers.is;
29 import static org.junit.Assert.assertThat;
32 * @author Rajiv Singla . Creation Date: 12/12/2016.
34 public class AbstractProcessorContextTest extends BaseAnalyticsCommonUnitTest {
36 class TestAbstractMessageProcessorContext extends AbstractProcessorContext {
38 public TestAbstractMessageProcessorContext(String message, boolean canProcessingContinue) {
39 super(message, canProcessingContinue);
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));
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));
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));
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));