Skip to content

Package: CucCredentials

CucCredentials

nameinstructionbranchcomplexitylinemethod
CucCredentials()
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%
getExpirationDate()
M: 49 C: 0
0%
M: 6 C: 0
0%
M: 5 C: 0
0%
M: 15 C: 0
0%
M: 1 C: 0
0%
getName()
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%
getPassword()
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: 7 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
isEnabled()
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%
setEnabled(boolean)
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%
setExpirationDate(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%
setName(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%
setPassword(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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2016, 2020 Eurotech and/or its affiliates and others
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.kapua.qa.common.cucumber;
13:
14: import org.eclipse.kapua.service.authentication.credential.CredentialStatus;
15:
16: import java.text.DateFormat;
17: import java.text.ParseException;
18: import java.text.SimpleDateFormat;
19: import java.time.Duration;
20: import java.time.Instant;
21: import java.util.Date;
22:
23: /**
24: * Data object used in Gherkin to transfer Credentials data.
25: */
26: public class CucCredentials {
27:
28: private String name;
29:
30: private String password;
31:
32: private boolean enabled;
33:
34: private String expirationDate;
35:
36: public String getName() {
37: return name;
38: }
39:
40: public void setName(String name) {
41: this.name = name;
42: }
43:
44: public String getPassword() {
45: return password;
46: }
47:
48: public void setPassword(String password) {
49: this.password = password;
50: }
51:
52: public boolean isEnabled() {
53: return enabled;
54: }
55:
56: public void setEnabled(boolean enabled) {
57: this.enabled = enabled;
58: }
59:
60: public CredentialStatus getStatus() {
61:• if (isEnabled()) {
62: return CredentialStatus.ENABLED;
63: } else {
64: return CredentialStatus.DISABLED;
65: }
66: }
67:
68: public Date getExpirationDate() {
69: DateFormat df = new SimpleDateFormat("dd/mm/yyyy");
70: Date expDate = null;
71: Instant now = Instant.now();
72:
73:• if (expirationDate == null) {
74: return null;
75: }
76: // Special keywords for date
77:• switch (expirationDate) {
78: case "yesterday":
79: expDate = Date.from(now.minus(Duration.ofDays(1)));
80: break;
81: case "today":
82: expDate = Date.from(now);
83: break;
84: case "tomorrow":
85: expDate = Date.from(now.plus(Duration.ofDays(1)));
86: break;
87: }
88: // Just parse date
89: try {
90: expDate = df.parse(expirationDate);
91: } catch (ParseException | NullPointerException e) {
92: // skip, leave date null
93: }
94:
95: return expDate;
96: }
97:
98: public void setExpirationDate(String expirationDate) {
99: this.expirationDate = expirationDate;
100: }
101: }