2 * ============LICENSE_START=======================================================
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
13 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 * ECOMP is a trademark and service mark of AT&T Intellectual Property.
22 * ============LICENSE_END=========================================================
24 package org.onap.appc.listener.LCM.model;
26 import static org.junit.Assert.assertEquals;
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;
33 public class DmaapOutgoingMessageTest {
35 private static final String jsonInputBodyStr =
36 "{\"input\":{ \"common-header\": { \"timestamp\": \"2016-08-03T08:50:18.97Z\", "
37 + "\"api-ver\": \"1\", \"originator-id\": \"1\", \"request-id\": \"123\", \"sub-request-id\": \"1\", "
38 + "\"flags\": { \"force\":\"TRUE\", \"ttl\":\"9900\" } }, \"action\": \"Stop\", "
39 + "\"action-identifiers\": { \"vnf-id\": \"TEST\" } }}";
41 private DmaapOutgoingMessage dmaapOutgoingMessage;
45 dmaapOutgoingMessage = new DmaapOutgoingMessage();
49 public void should_set_default_cambria_partition_when_initialized() {
51 assertEquals("MSO", dmaapOutgoingMessage.getCambriaPartition());
55 public void toString_should_return_valid_string_representation() {
56 JsonNode jsonNode = Mapper.toJsonNodeFromJsonString(jsonInputBodyStr);
58 dmaapOutgoingMessage.setVersion("test-version");
59 dmaapOutgoingMessage.setType("test-type");
60 dmaapOutgoingMessage.setCorrelationID("test-correlation-id");
61 dmaapOutgoingMessage.setCambriaPartition("test-cambria-partition");
62 dmaapOutgoingMessage.setRpcName("test-rpc-name");
63 dmaapOutgoingMessage.setBody(jsonNode);
65 assertEquals("DmaapOutgoingMessage{DmaapMessage{" +
66 "version='" + dmaapOutgoingMessage.getVersion() + '\'' +
67 ", type='" + dmaapOutgoingMessage.getType() + '\'' +
68 ", correlationId='" + dmaapOutgoingMessage.getCorrelationID() + '\'' +
69 ", cambriaPartition='" + dmaapOutgoingMessage.getCambriaPartition() + '\'' +
70 ", rpcName='" + dmaapOutgoingMessage.getRpcName() + '\'' +
71 ", body=" + dmaapOutgoingMessage.getBody() +
72 "}}", dmaapOutgoingMessage.toString());