LCM package test classes refactor
[appc.git] / appc-event-listener / appc-event-listener-bundle / src / test / java / org / onap / appc / listener / LCM / model / DmaapOutgoingMessageTest.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 DmaapOutgoingMessageTest {
35
36     private DmaapOutgoingMessage dmaapOutgoingMessage;
37
38     @Before
39     public void setup() {
40         dmaapOutgoingMessage = new DmaapOutgoingMessage();
41     }
42
43     @Test
44     public void should_set_default_cambria_partition_when_initialized() {
45
46         assertEquals("MSO", dmaapOutgoingMessage.getCambriaPartition());
47     }
48
49     @Test
50     public void toString_should_return_valid_string_representation() {
51         JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(JSON_INPUT_BODY_STR);
52
53         dmaapOutgoingMessage.setVersion("test-version");
54         dmaapOutgoingMessage.setType("test-type");
55         dmaapOutgoingMessage.setCorrelationID("test-correlation-id");
56         dmaapOutgoingMessage.setCambriaPartition("test-cambria-partition");
57         dmaapOutgoingMessage.setRpcName("test-rpc-name");
58         dmaapOutgoingMessage.setBody(jsonNode);
59
60         assertEquals("DmaapOutgoingMessage{DmaapMessage{" +
61             "version='" + dmaapOutgoingMessage.getVersion() + '\'' +
62             ", type='" + dmaapOutgoingMessage.getType() + '\'' +
63             ", correlationId='" + dmaapOutgoingMessage.getCorrelationID() + '\'' +
64             ", cambriaPartition='" + dmaapOutgoingMessage.getCambriaPartition() + '\'' +
65             ", rpcName='" + dmaapOutgoingMessage.getRpcName() + '\'' +
66             ", body=" + dmaapOutgoingMessage.getBody() +
67             "}}", dmaapOutgoingMessage.toString());
68     }
69 }