Package: DataMessage

DataMessage

nameinstructionbranchcomplexitylinemethod
DataMessage()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
DataMessage(DataMessage.Builder)
M: 0 C: 51
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 14
100%
M: 0 C: 1
100%
droppedOn()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getConfirmedOn()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getCreatedOn()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getId()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPayload()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPriority()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPublishedMessageId()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPublishedOn()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getQos()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getSessionId()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getTopic()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
isRetain()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
setPublishedMessageId(int)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
toString()
M: 69 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011, 2016 Eurotech and/or its affiliates
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License v1.0
6: * which accompanies this distribution, and is available at
7: * http://www.eclipse.org/legal/epl-v10.html
8: *
9: * Contributors:
10: * Eurotech
11: *******************************************************************************/
12: package org.eclipse.kura.core.data;
13:
14: import java.util.Arrays;
15: import java.util.Date;
16:
17: /**
18: * DataMessage is a message that is currently transiting through the DataService.
19: * It is a wrapper class over the message payload as produced by the client application
20: * but it also capture all the state information of the message through its
21: * DataService life-cycle of: stored -> published -> confirmed.
22: */
23: public class DataMessage {
24:
25: private int id;
26: private String topic;
27: private int qos;
28: private boolean retain;
29: private Date createdOn;
30: private Date publishedOn;
31: private int publishedMessageId;
32: private Date confirmedOn;
33: private byte[] payload;
34: private int priority;
35: private String sessionId;
36: private Date droppedOn;
37:
38: public DataMessage() {
39: }
40:
41: public DataMessage(Builder b) {
42: this.id = b.id;
43: this.topic = b.topic;
44: this.qos = b.qos;
45: this.retain = b.retain;
46: this.createdOn = b.createdOn;
47: this.publishedOn = b.publishedOn;
48: this.publishedMessageId = b.publishedMessageId;
49: ;
50: this.confirmedOn = b.confirmedOn;
51: this.payload = b.payload;
52: this.priority = b.priority;
53: this.sessionId = b.sessionId;
54: this.droppedOn = b.droppedOn;
55: }
56:
57: public int getId() {
58: return this.id;
59: }
60:
61: public String getTopic() {
62: return this.topic;
63: }
64:
65: public int getQos() {
66: return this.qos;
67: }
68:
69: public boolean isRetain() {
70: return this.retain;
71: }
72:
73: public Date getCreatedOn() {
74: return this.createdOn;
75: }
76:
77: public Date getPublishedOn() {
78: return this.publishedOn;
79: }
80:
81: public int getPublishedMessageId() {
82: return this.publishedMessageId;
83: }
84:
85: public void setPublishedMessageId(int publishedMessageId) {
86: this.publishedMessageId = publishedMessageId;
87: }
88:
89: public Date getConfirmedOn() {
90: return this.confirmedOn;
91: }
92:
93: public byte[] getPayload() {
94: return this.payload;
95: }
96:
97: public int getPriority() {
98: return this.priority;
99: }
100:
101: public String getSessionId() {
102: return this.sessionId;
103: }
104:
105: public Date droppedOn() {
106: return this.droppedOn;
107: }
108:
109: @Override
110: public String toString() {
111: StringBuilder builder = new StringBuilder("DataMessage [id=").append(this.id).append(", topic=")
112: .append(this.topic).append(", qos=").append(this.qos).append(", retain=").append(this.retain)
113: .append(", createdOn=").append(this.createdOn).append(", publishedOn=").append(this.publishedOn)
114: .append(", publishedMessageId=").append(this.publishedMessageId).append(", confirmedOn=")
115: .append(this.confirmedOn).append(", payload=").append(Arrays.toString(this.payload))
116: .append(", priority=").append(this.priority).append(", sessionId=").append(this.sessionId)
117: .append(", droppedOn=").append(this.droppedOn).append("]");
118:
119: return builder.toString();
120: }
121:
122: public static class Builder {
123:
124: private final int id;
125: private String topic;
126: private int qos;
127: private boolean retain;
128: private Date createdOn;
129: private Date publishedOn;
130: private int publishedMessageId;
131: private Date confirmedOn;
132: private byte[] payload;
133: private int priority;
134: private String sessionId;
135: private Date droppedOn;
136:
137: public Builder(int id) {
138: this.id = id;
139: }
140:
141: public Builder withTopic(String topic) {
142: this.topic = topic;
143: return this;
144: }
145:
146: public Builder withQos(int qos) {
147: this.qos = qos;
148: return this;
149: }
150:
151: public Builder withRetain(boolean retain) {
152: this.retain = retain;
153: return this;
154: }
155:
156: public Builder withCreatedOn(Date createdOn) {
157: this.createdOn = createdOn;
158: return this;
159: }
160:
161: public Builder withPublishedOn(Date publishedOn) {
162: this.publishedOn = publishedOn;
163: return this;
164: }
165:
166: public Builder withPublishedMessageId(int publishedMessageId) {
167: this.publishedMessageId = publishedMessageId;
168: return this;
169: }
170:
171: public Builder withConfirmedOn(Date confirmedOn) {
172: this.confirmedOn = confirmedOn;
173: return this;
174: }
175:
176: public Builder withPayload(byte[] payload) {
177: this.payload = payload;
178: return this;
179: }
180:
181: public Builder withPriority(int priority) {
182: this.priority = priority;
183: return this;
184: }
185:
186: public Builder withSessionId(String sessionId) {
187: this.sessionId = sessionId;
188: return this;
189: }
190:
191: public Builder withDroppedOn(Date droppedOn) {
192: this.droppedOn = droppedOn;
193: return this;
194: }
195:
196: public int getId() {
197: return this.id;
198: }
199:
200: public String getTopic() {
201: return this.topic;
202: }
203:
204: public int getQos() {
205: return this.qos;
206: }
207:
208: public boolean getRetain() {
209: return this.retain;
210: }
211:
212: public Date getCreatedOn() {
213: return this.createdOn;
214: }
215:
216: public Date getPublishedOn() {
217: return this.publishedOn;
218: }
219:
220: public int getPublishedMessageId() {
221: return this.publishedMessageId;
222: }
223:
224: public Date getConfirmedOn() {
225: return this.confirmedOn;
226: }
227:
228: public byte[] getPayload() {
229: return this.payload;
230: }
231:
232: public int getPriority() {
233: return this.priority;
234: }
235:
236: public String getSessionId() {
237: return this.sessionId;
238: }
239:
240: public Date getDroppedOn() {
241: return this.droppedOn;
242: }
243:
244: public DataMessage build() {
245: return new DataMessage(this);
246: }
247: }
248: }