Skip to content

Package: KuraNotifyPayload

KuraNotifyPayload

nameinstructionbranchcomplexitylinemethod
KuraNotifyPayload()
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%
getMessage()
M: 65 C: 0
0%
M: 14 C: 0
0%
M: 8 C: 0
0%
M: 16 C: 0
0%
M: 1 C: 0
0%
getOperationId()
M: 28 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
getProgress()
M: 33 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
getResource()
M: 26 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
getStatus()
M: 33 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2022 Eurotech and/or its affiliates and others
3: *
4: * This program and the accompanying materials are made
5: * available under the terms of the Eclipse Public License 2.0
6: * which is available at https://www.eclipse.org/legal/epl-2.0/
7: *
8: * SPDX-License-Identifier: EPL-2.0
9: *
10: * Contributors:
11: * Eurotech - initial API and implementation
12: * Red Hat Inc
13: *******************************************************************************/
14: package org.eclipse.kapua.service.device.call.message.kura.app.notification;
15:
16: import org.eclipse.kapua.service.device.call.message.app.notification.DeviceNotifyPayload;
17: import org.eclipse.kapua.service.device.call.message.kura.app.KuraAppPayload;
18:
19: /**
20: * {@link DeviceNotifyPayload} {@link org.eclipse.kapua.service.device.call.kura.Kura} implementation.
21: *
22: * @since 1.0.0
23: */
24: public class KuraNotifyPayload extends KuraAppPayload implements DeviceNotifyPayload {
25:
26: @Override
27: public Long getOperationId() {
28:• if (getMetrics().containsKey(KuraNotifyMetrics.OPERATION_ID.getName())) {
29: return (Long) getMetrics().get(KuraNotifyMetrics.OPERATION_ID.getName());
30: }
31:
32:• if (getMetrics().containsKey(KuraNotifyMetrics.OPERATION_ID_ALTERNATIVE.getName())) {
33: return (Long) getMetrics().get(KuraNotifyMetrics.OPERATION_ID_ALTERNATIVE.getName());
34: }
35:
36: return null;
37: }
38:
39: public String getResource() {
40:
41:• if (getMetrics().containsKey(KuraNotifyMetrics.DOWNLOAD_STATUS.getName())) {
42: return "download";
43: }
44:
45:• if (getMetrics().containsKey(KuraNotifyMetrics.INSTALL_STATUS.getName())) {
46: return "install";
47: }
48:
49:• if (getMetrics().containsKey(KuraNotifyMetrics.UNINSTALL_PROGRESS.getName())) {
50: return "uninstall";
51: }
52:
53: return null;
54: }
55:
56: @Override
57: public String getStatus() {
58: Object status = getMetrics().get(KuraNotifyMetrics.DOWNLOAD_STATUS.getName());
59:
60:• if (status == null) {
61: status = getMetrics().get(KuraNotifyMetrics.INSTALL_STATUS.getName());
62: }
63:
64:• if (status == null) {
65: status = getMetrics().get(KuraNotifyMetrics.UNINSTALL_STATUS.getName());
66: }
67:
68:• if (status == null) {
69: status = getMetrics().get(KuraNotifyMetrics.STATUS.getName());
70: }
71:
72: return (String) status;
73: }
74:
75: @Override
76: public Integer getProgress() {
77: Object progress = getMetrics().get(KuraNotifyMetrics.DOWNLOAD_PROGRESS.getName());
78:
79:• if (progress == null) {
80: progress = getMetrics().get(KuraNotifyMetrics.INSTALL_PROGRESS.getName());
81: }
82:
83:• if (progress == null) {
84: progress = getMetrics().get(KuraNotifyMetrics.UNINSTALL_PROGRESS.getName());
85: }
86:
87:• if (progress == null) {
88: progress = getMetrics().get(KuraNotifyMetrics.PROGRESS.getName());
89: }
90:
91: return (Integer) progress;
92: }
93:
94: @Override
95: public String getMessage() {
96: Object message = getMetrics().get(KuraNotifyMetrics.NOTIFY_MESSAGE.getName());
97:
98:• if (message == null) {
99: message = getMetrics().get(KuraNotifyMetrics.MESSAGE.getName());
100: }
101:
102:• if (message == null) {
103: message = getMetrics().get(KuraNotifyMetrics.DOWNLOAD_MESSAGE.getName());
104: }
105:
106:• if (message == null) {
107: message = getMetrics().get(KuraNotifyMetrics.DOWNLOAD_ERROR_MESSAGE.getName());
108: }
109:
110:• if (message == null) {
111: message = getMetrics().get(KuraNotifyMetrics.INSTALL_MESSAGE.getName());
112: }
113:
114:• if (message == null) {
115: message = getMetrics().get(KuraNotifyMetrics.INSTALL_ERROR_MESSAGE.getName());
116: }
117:
118:• if (message == null) {
119: message = getMetrics().get(KuraNotifyMetrics.UNINSTALL_MESSAGE.getName());
120: }
121:
122:• if (message == null) {
123: message = getMetrics().get(KuraNotifyMetrics.UNINSTALL_ERROR_MESSAGE.getName());
124: }
125:
126: return (String) message;
127: }
128: }