Skip to content

Package: CucConnection

CucConnection

nameinstructionbranchcomplexitylinemethod
CucConnection()
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%
getAllowUserChange()
M: 28 C: 0
0%
M: 5 C: 0
0%
M: 4 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getClientId()
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%
getClientIp()
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%
getProtocol()
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%
getReservedUser()
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%
getReservedUserId()
M: 14 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
getScope()
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%
getScopeId()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getServerIp()
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%
getStatus()
M: 28 C: 0
0%
M: 6 C: 0
0%
M: 5 C: 0
0%
M: 10 C: 0
0%
M: 1 C: 0
0%
getUser()
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%
getUserCouplingMode()
M: 29 C: 0
0%
M: 6 C: 0
0%
M: 5 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
getUserId()
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
lambda$getReservedUserId$2()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
lambda$getScopeId$0()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
lambda$getUserId$1()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
setAllowUserChange(String)
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%
setClientId(String)
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%
setClientIp(String)
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%
setProtocol(String)
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%
setReservedUser(String)
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%
setScope(String)
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%
setServerIp(String)
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%
setStatus(String)
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%
setUser(String)
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%
setUserCouplingMode(String)
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%
static {...}
M: 11 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2017, 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
12: *******************************************************************************/
13: package org.eclipse.kapua.qa.common.cucumber;
14:
15: import org.eclipse.kapua.KapuaException;
16: import org.eclipse.kapua.commons.security.KapuaSecurityUtils;
17: import org.eclipse.kapua.locator.KapuaLocator;
18: import org.eclipse.kapua.model.id.KapuaId;
19: import org.eclipse.kapua.service.account.AccountService;
20: import org.eclipse.kapua.service.device.registry.ConnectionUserCouplingMode;
21: import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionStatus;
22: import org.eclipse.kapua.service.user.UserService;
23:
24: /**
25: * Data object used in Gherkin to input Device Connection parameters.
26: * The data setters intentionally use only cucumber-friendly data types and
27: * generate the resulting Kapua types internally.
28: */
29: public class CucConnection {
30:
31: String scope;
32: KapuaId scopeId;
33: String status;
34: String clientId;
35: String user;
36: KapuaId userId;
37: String allowUserChange;
38: String userCouplingMode;
39: String reservedUser;
40: KapuaId reservedUserId;
41: String protocol;
42: String clientIp;
43: String serverIp;
44:
45: private static UserService userService = KapuaLocator.getInstance().getService(UserService.class);
46: private static AccountService accountService = KapuaLocator.getInstance().getService(AccountService.class);
47:
48: public String getScope() {
49: return scope;
50: }
51:
52: public void setScope(String scope) {
53: this.scope = scope;
54: }
55:
56: public KapuaId getScopeId() throws KapuaException {
57: return KapuaSecurityUtils.doPrivileged(() -> accountService.findByName(scope).getId());
58: }
59:
60: public DeviceConnectionStatus getStatus() {
61: DeviceConnectionStatus tmpStatus = null;
62:• if (status == null) {
63: return null;
64: }
65:• switch (status.trim().toUpperCase()) {
66: case "CONNECTED":
67: tmpStatus = DeviceConnectionStatus.CONNECTED;
68: break;
69: case "DISCONNECTED":
70: tmpStatus = DeviceConnectionStatus.DISCONNECTED;
71: break;
72: case "MISSING":
73: tmpStatus = DeviceConnectionStatus.MISSING;
74: break;
75: }
76: return tmpStatus;
77: }
78:
79: public void setStatus(String status) {
80: this.status = status;
81: }
82:
83: public String getClientId() {
84: return clientId;
85: }
86:
87: public void setClientId(String clientId) {
88: this.clientId = clientId;
89: }
90:
91: public String getUser() {
92: return user;
93: }
94:
95: public void setUser(String user) {
96: this.user = user;
97: }
98:
99: public KapuaId getUserId() throws KapuaException {
100: return KapuaSecurityUtils.doPrivileged(() -> userService.findByName(user).getId());
101: }
102:
103: public boolean getAllowUserChange() {
104: boolean allowChng = false;
105:• if (allowUserChange == null) {
106: return false;
107: }
108:• switch (allowUserChange.trim().toLowerCase()) {
109: case "true":
110: allowChng = true;
111: break;
112: case "false":
113: allowChng = false;
114: break;
115: default:
116: allowChng = false;
117: }
118: return allowChng;
119: }
120:
121: public void setAllowUserChange(String allowUserChange) {
122: this.allowUserChange = allowUserChange;
123: }
124:
125: public ConnectionUserCouplingMode getUserCouplingMode() {
126: ConnectionUserCouplingMode mode;
127:
128:• if (userCouplingMode == null) {
129: return ConnectionUserCouplingMode.INHERITED;
130: }
131:• switch (userCouplingMode.toUpperCase().trim()) {
132: case "INHERITED":
133: mode = ConnectionUserCouplingMode.INHERITED;
134: break;
135: case "LOOSE":
136: mode = ConnectionUserCouplingMode.LOOSE;
137: break;
138: case "STRICT":
139: mode = ConnectionUserCouplingMode.STRICT;
140: break;
141: default:
142: mode = ConnectionUserCouplingMode.INHERITED;
143: }
144: return mode;
145: }
146:
147: public void setUserCouplingMode(String userCouplingMode) {
148: this.userCouplingMode = userCouplingMode;
149: }
150:
151: public String getReservedUser() {
152: return reservedUser;
153: }
154:
155: public void setReservedUser(String reservedUser) {
156: this.reservedUser = reservedUser;
157: }
158:
159: public KapuaId getReservedUserId() throws KapuaException {
160:• if ((reservedUser == null) || reservedUser.isEmpty()) {
161: return null;
162: } else {
163: return KapuaSecurityUtils.doPrivileged(() -> userService.findByName(reservedUser).getId());
164: }
165: }
166:
167: public String getProtocol() {
168: return protocol;
169: }
170:
171: public void setProtocol(String protocol) {
172: this.protocol = protocol;
173: }
174:
175: public String getClientIp() {
176: return clientIp;
177: }
178:
179: public void setClientIp(String clientIp) {
180: this.clientIp = clientIp;
181: }
182:
183: public String getServerIp() {
184: return serverIp;
185: }
186:
187: public void setServerIp(String serverIp) {
188: this.serverIp = serverIp;
189: }
190: }