Skip to content

Package: CucAccount

CucAccount

nameinstructionbranchcomplexitylinemethod
CucAccount()
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: 53 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%
getScopeId()
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%
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%
setScopeId(BigInteger)
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, 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 java.math.BigInteger;
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 Account data.
25: */
26: public class CucAccount {
27:
28: private String name;
29:
30: private BigInteger scopeId;
31:
32: private String expirationDate;
33:
34: public String getName() {
35: return name;
36: }
37:
38: public void setName(String name) {
39: this.name = name;
40: }
41:
42: public BigInteger getScopeId() {
43: return scopeId;
44: }
45:
46: public void setScopeId(BigInteger scopeId) {
47: this.scopeId = scopeId;
48: }
49:
50: public void setExpirationDate(String date) {
51: this.expirationDate = date;
52: }
53:
54: public Date getExpirationDate() {
55: DateFormat df = new SimpleDateFormat("dd/mm/yyyy");
56: Date expDate = null;
57: Instant now = Instant.now();
58:
59:• if (expirationDate == null) {
60: return null;
61: }
62: // Special keywords for date
63:• switch (expirationDate.trim().toLowerCase()) {
64: case "yesterday":
65: expDate = Date.from(now.minus(Duration.ofDays(1)));
66: break;
67: case "today":
68: expDate = Date.from(now);
69: break;
70: case "tomorrow":
71: expDate = Date.from(now.plus(Duration.ofDays(1)));
72: break;
73: }
74: // Just parse date
75: try {
76: expDate = df.parse(expirationDate.trim().toLowerCase());
77: } catch (ParseException | NullPointerException e) {
78: // skip, leave date null
79: }
80:
81: return expDate;
82: }
83: }