Update license header in appc-event-listener files
[appc.git] / appc-event-listener / appc-event-listener-bundle / src / test / java / org / onap / appc / listener / LCM / model / DmaapMessageTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2018 Nokia Solutions and Networks
8  * =============================================================================
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  * 
13  *      http://www.apache.org/licenses/LICENSE-2.0
14  * 
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  * 
21  * ============LICENSE_END=========================================================
22  */
23 package org.onap.appc.listener.LCM.model;
24
25 import static org.junit.Assert.assertEquals;
26 import static org.onap.appc.listener.TestUtil.JSON_INPUT_BODY_STR;
27
28 import com.fasterxml.jackson.databind.JsonNode;
29 import org.junit.Before;
30 import org.junit.Test;
31 import org.onap.appc.listener.util.Mapper;
32
33 public class DmaapMessageTest {
34
35     private DmaapMessage dmaapMessage;
36
37     @Before
38     public void setup() {
39         dmaapMessage = new DmaapMessage();
40     }
41
42     @Test
43     public void should_set_properties() {
44
45         JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
46
47         dmaapMessage.setVersion("test-version");
48         dmaapMessage.setType("test-type");
49         dmaapMessage.setCorrelationID("test-correlation-id");
50         dmaapMessage.setCambriaPartition("test-cambria-partition");
51         dmaapMessage.setRpcName("test-rpc-name");
52         dmaapMessage.setBody(jsonNode);
53
54         assertEquals("test-version", dmaapMessage.getVersion());
55         assertEquals("test-type", dmaapMessage.getType());
56         assertEquals("test-correlation-id", dmaapMessage.getCorrelationID());
57         assertEquals("test-cambria-partition", dmaapMessage.getCambriaPartition());
58         assertEquals("test-rpc-name", dmaapMessage.getRpcName());
59         assertEquals(jsonNode, dmaapMessage.getBody());
60     }
61
62     @Test
63     public void toString_should_return_valid_string_representation() {
64         JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
65
66         dmaapMessage.setVersion("test-version");
67         dmaapMessage.setType("test-type");
68         dmaapMessage.setCorrelationID("test-correlation-id");
69         dmaapMessage.setCambriaPartition("test-cambria-partition");
70         dmaapMessage.setRpcName("test-rpc-name");
71         dmaapMessage.setBody(jsonNode);
72
73         assertEquals("DmaapMessage{" +
74             "version='" + dmaapMessage.getVersion() + '\'' +
75             ", type='" + dmaapMessage.getType() + '\'' +
76             ", correlationId='" + dmaapMessage.getCorrelationID() + '\'' +
77             ", cambriaPartition='" + dmaapMessage.getCambriaPartition() + '\'' +
78             ", rpcName='" + dmaapMessage.getRpcName() + '\'' +
79             ", body=" + dmaapMessage.getBody() +
80             '}', dmaapMessage.toString());
81     }
82 }
83