7b42a754a1e92e85a8352bd1692a37e80ec845b9
[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 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  * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22  * ============LICENSE_END=========================================================
23  */
24 package org.onap.appc.listener.LCM.model;
25
26 import static org.junit.Assert.assertEquals;
27 import static org.onap.appc.listener.TestUtil.JSON_INPUT_BODY_STR;
28
29 import com.fasterxml.jackson.databind.JsonNode;
30 import org.junit.Before;
31 import org.junit.Test;
32 import org.onap.appc.listener.util.Mapper;
33
34 public class DmaapMessageTest {
35
36     private DmaapMessage dmaapMessage;
37
38     @Before
39     public void setup() {
40         dmaapMessage = new DmaapMessage();
41     }
42
43     @Test
44     public void should_set_properties() {
45
46         JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
47
48         dmaapMessage.setVersion("test-version");
49         dmaapMessage.setType("test-type");
50         dmaapMessage.setCorrelationID("test-correlation-id");
51         dmaapMessage.setCambriaPartition("test-cambria-partition");
52         dmaapMessage.setRpcName("test-rpc-name");
53         dmaapMessage.setBody(jsonNode);
54
55         assertEquals("test-version", dmaapMessage.getVersion());
56         assertEquals("test-type", dmaapMessage.getType());
57         assertEquals("test-correlation-id", dmaapMessage.getCorrelationID());
58         assertEquals("test-cambria-partition", dmaapMessage.getCambriaPartition());
59         assertEquals("test-rpc-name", dmaapMessage.getRpcName());
60         assertEquals(jsonNode, dmaapMessage.getBody());
61     }
62
63     @Test
64     public void toString_should_return_valid_string_representation() {
65         JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
66
67         dmaapMessage.setVersion("test-version");
68         dmaapMessage.setType("test-type");
69         dmaapMessage.setCorrelationID("test-correlation-id");
70         dmaapMessage.setCambriaPartition("test-cambria-partition");
71         dmaapMessage.setRpcName("test-rpc-name");
72         dmaapMessage.setBody(jsonNode);
73
74         assertEquals("DmaapMessage{" +
75             "version='" + dmaapMessage.getVersion() + '\'' +
76             ", type='" + dmaapMessage.getType() + '\'' +
77             ", correlationId='" + dmaapMessage.getCorrelationID() + '\'' +
78             ", cambriaPartition='" + dmaapMessage.getCambriaPartition() + '\'' +
79             ", rpcName='" + dmaapMessage.getRpcName() + '\'' +
80             ", body=" + dmaapMessage.getBody() +
81             '}', dmaapMessage.toString());
82     }
83 }
84