• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mybatis / jpetstore-6 / #1229

pending completion
#1229

push

github

web-flow
Merge pull request #710 from mybatis/renovate/org.apache.maven.plugins-maven-failsafe-plugin-3.x

chore(deps): update dependency org.apache.maven.plugins:maven-failsafe-plugin to v3.1.2

421 of 612 relevant lines covered (68.79%)

0.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/main/java/org/mybatis/jpetstore/domain/LineItem.java
1
/*
2
 *    Copyright 2010-2022 the original author or authors.
3
 *
4
 *    Licensed under the Apache License, Version 2.0 (the "License");
5
 *    you may not use this file except in compliance with the License.
6
 *    You may obtain a copy of the License at
7
 *
8
 *       https://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 *    Unless required by applicable law or agreed to in writing, software
11
 *    distributed under the License is distributed on an "AS IS" BASIS,
12
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 *    See the License for the specific language governing permissions and
14
 *    limitations under the License.
15
 */
16
package org.mybatis.jpetstore.domain;
17

18
import java.io.Serializable;
19
import java.math.BigDecimal;
20
import java.util.Optional;
21

22
/**
23
 * The Class LineItem.
24
 *
25
 * @author Eduardo Macarron
26
 */
27
public class LineItem implements Serializable {
28

29
  private static final long serialVersionUID = 6804536240033522156L;
30

31
  private int orderId;
32
  private int lineNumber;
33
  private int quantity;
34
  private String itemId;
35
  private BigDecimal unitPrice;
36
  private Item item;
37
  private BigDecimal total;
38

39
  public LineItem() {
1✔
40
  }
1✔
41

42
  /**
43
   * Instantiates a new line item.
44
   *
45
   * @param lineNumber
46
   *          the line number
47
   * @param cartItem
48
   *          the cart item
49
   */
50
  public LineItem(int lineNumber, CartItem cartItem) {
1✔
51
    this.lineNumber = lineNumber;
1✔
52
    this.quantity = cartItem.getQuantity();
1✔
53
    this.itemId = cartItem.getItem().getItemId();
1✔
54
    this.unitPrice = cartItem.getItem().getListPrice();
1✔
55
    this.item = cartItem.getItem();
1✔
56
    calculateTotal();
1✔
57
  }
1✔
58

59
  public int getOrderId() {
60
    return orderId;
1✔
61
  }
62

63
  public void setOrderId(int orderId) {
64
    this.orderId = orderId;
1✔
65
  }
1✔
66

67
  public int getLineNumber() {
68
    return lineNumber;
1✔
69
  }
70

71
  public void setLineNumber(int lineNumber) {
72
    this.lineNumber = lineNumber;
1✔
73
  }
1✔
74

75
  public String getItemId() {
76
    return itemId;
1✔
77
  }
78

79
  public void setItemId(String itemId) {
80
    this.itemId = itemId;
1✔
81
  }
1✔
82

83
  public BigDecimal getUnitPrice() {
84
    return unitPrice;
1✔
85
  }
86

87
  public void setUnitPrice(BigDecimal unitprice) {
88
    this.unitPrice = unitprice;
1✔
89
  }
1✔
90

91
  public BigDecimal getTotal() {
92
    return total;
1✔
93
  }
94

95
  public Item getItem() {
96
    return item;
1✔
97
  }
98

99
  public void setItem(Item item) {
100
    this.item = item;
1✔
101
    calculateTotal();
1✔
102
  }
1✔
103

104
  public int getQuantity() {
105
    return quantity;
1✔
106
  }
107

108
  public void setQuantity(int quantity) {
109
    this.quantity = quantity;
1✔
110
    calculateTotal();
1✔
111
  }
1✔
112

113
  private void calculateTotal() {
114
    total = Optional.ofNullable(item).map(Item::getListPrice).map(v -> v.multiply(new BigDecimal(quantity)))
1✔
115
        .orElse(null);
1✔
116
  }
1✔
117

118
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc