2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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.policy.drools.pooling.message;
23 import static org.junit.Assert.assertEquals;
24 import static org.junit.Assert.assertNull;
26 import org.junit.Test;
28 public class MessageTest extends SupportBasicMessageTester<Message> {
30 public MessageTest() {
35 public void testGetSource_testSetSource() {
36 Message msg = new Message();
38 msg.setSource("hello");
39 assertEquals("hello", msg.getSource());
40 assertNull(msg.getChannel());
42 msg.setSource("world");
43 assertEquals("world", msg.getSource());
44 assertNull(msg.getChannel());
48 public void testGetChannel_testSetChannel() {
49 Message msg = new Message();
51 msg.setChannel("hello");
52 assertEquals("hello", msg.getChannel());
53 assertNull(msg.getSource());
55 msg.setChannel("world");
56 assertEquals("world", msg.getChannel());
57 assertNull(msg.getSource());
61 public void testCheckValidity_InvalidFields() {
62 // null or empty source
63 expectCheckValidityFailure_NullOrEmpty((msg, value) -> msg.setSource(value));
65 // null or empty channel
66 expectCheckValidityFailure_NullOrEmpty((msg, value) -> msg.setChannel(value));
70 * Makes a message that will pass the validity check.
72 * @return a valid Message
74 public Message makeValidMessage() {
75 Message msg = new Message(VALID_HOST);
76 msg.setChannel(VALID_CHANNEL);