Add junit coverage to TimedOutException class
[appc.git] / appc-adapters / appc-dmaap-adapter / appc-message-adapter-api / src / main / java / org / onap / appc / adapter / message / event / EventMessage.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP : APPC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Copyright (C) 2017 Amdocs
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
25 package org.onap.appc.adapter.message.event;
26
27 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
28 import com.fasterxml.jackson.annotation.JsonProperty;
29 import com.fasterxml.jackson.databind.ObjectMapper;
30 import com.fasterxml.jackson.databind.annotation.JsonSerialize;
31 import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
32
33 import java.io.IOException;
34 import java.io.Serializable;
35
36 /*
37     {
38         "EventHeader": {
39         "eventTime": "2016-03-15T10:59:33.79Z",
40         "apiVer": "1.01",
41         "EventId": "<ECOMP_EVENT_ID>",
42     },
43         "EventStatus": {
44             "code": "NNN",
45             "reason": "A reason"
46         }
47     }
48 */
49
50
51 @JsonSerialize(include = Inclusion.NON_NULL)
52 @JsonIgnoreProperties(ignoreUnknown = true)
53 public class EventMessage implements Serializable {
54
55     private static final long serialVersionUID = 1L;
56
57     private static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
58
59     @JsonProperty("eventHeader")
60     private EventHeader eventHeader;
61     @JsonProperty("eventStatus")
62     private EventStatus eventStatus;
63
64     public EventMessage(EventHeader eventHeader, EventStatus eventStatus) {
65         this.eventHeader = eventHeader;
66         this.eventStatus = eventStatus;
67     }
68
69     public EventHeader getEventHeader() {
70         return eventHeader;
71     }
72
73     public void setEventHeader(EventHeader eventHeader) {
74         this.eventHeader = eventHeader;
75     }
76
77     public EventStatus getEventStatus() {
78         return eventStatus;
79     }
80
81     public void setEventStatus(EventStatus eventStatus) {
82         this.eventStatus = eventStatus;
83     }
84
85     public String toJson() {
86         try {
87             return OBJECT_MAPPER.writeValueAsString(this);
88         } catch (IOException e) {
89             throw new RuntimeException(e);
90         }
91     }
92
93     @Override
94     public String toString() {
95         return "EventMessage{" +
96                 "eventHeader=" + eventHeader +
97                 ", eventStatus=" + eventStatus +
98                 '}';
99     }
100 }