Package: CucConnection
CucConnection
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
CucConnection() |
|
|
|
|
|
||||||||||||||||||||
getAllowUserChange() |
|
|
|
|
|
||||||||||||||||||||
getClientId() |
|
|
|
|
|
||||||||||||||||||||
getClientIp() |
|
|
|
|
|
||||||||||||||||||||
getProtocol() |
|
|
|
|
|
||||||||||||||||||||
getReservedUser() |
|
|
|
|
|
||||||||||||||||||||
getReservedUserId() |
|
|
|
|
|
||||||||||||||||||||
getScope() |
|
|
|
|
|
||||||||||||||||||||
getScopeId() |
|
|
|
|
|
||||||||||||||||||||
getServerIp() |
|
|
|
|
|
||||||||||||||||||||
getStatus() |
|
|
|
|
|
||||||||||||||||||||
getUser() |
|
|
|
|
|
||||||||||||||||||||
getUserCouplingMode() |
|
|
|
|
|
||||||||||||||||||||
getUserId() |
|
|
|
|
|
||||||||||||||||||||
lambda$getReservedUserId$2() |
|
|
|
|
|
||||||||||||||||||||
lambda$getScopeId$0() |
|
|
|
|
|
||||||||||||||||||||
lambda$getUserId$1() |
|
|
|
|
|
||||||||||||||||||||
setAllowUserChange(String) |
|
|
|
|
|
||||||||||||||||||||
setClientId(String) |
|
|
|
|
|
||||||||||||||||||||
setClientIp(String) |
|
|
|
|
|
||||||||||||||||||||
setProtocol(String) |
|
|
|
|
|
||||||||||||||||||||
setReservedUser(String) |
|
|
|
|
|
||||||||||||||||||||
setScope(String) |
|
|
|
|
|
||||||||||||||||||||
setServerIp(String) |
|
|
|
|
|
||||||||||||||||||||
setStatus(String) |
|
|
|
|
|
||||||||||||||||||||
setUser(String) |
|
|
|
|
|
||||||||||||||||||||
setUserCouplingMode(String) |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
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: }