Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cloudbank-v4/customer-helidon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,29 @@
<artifactId>hamcrest-all</artifactId>
<scope>test</scope>
</dependency>
<!-- Minimal test dependencies for pure unit testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>5.5.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package com.example;

import java.util.Date;

import org.hibernate.annotations.CreationTimestamp;

import jakarta.persistence.Access;
import jakarta.persistence.AccessType;
import jakarta.persistence.Column;
Expand All @@ -18,13 +16,13 @@
@Access(AccessType.PROPERTY)
@NamedQueries({
@NamedQuery(name = "getCustomers",
query = "select c from Customer c"),
query = "SELECT c FROM Customer c"),
@NamedQuery(name = "getCustomerById",
query = "select c from Customer c where c.customerId = :id"),
query = "SELECT c FROM Customer c WHERE c.customerId = :id"),
@NamedQuery(name = "getCustomerByCustomerNameContaining",
query = "select c from Customer c where c.customerName like '%'||:name||'%'"),
query = "SELECT c FROM Customer c WHERE c.customerName LIKE :customerName"),
@NamedQuery(name = "getCustomerByCustomerEmailContaining",
query = "select c from Customer c where c.customerEmail like '%'||:email||'%'")
query = "SELECT c FROM Customer c WHERE c.customerEmail LIKE :customerEmail")
})
public class Customer {

Expand All @@ -34,11 +32,12 @@ public class Customer {
private Date dateBecameCustomer;
private String customerOtherDetails;
private String customerPassword;


// Default constructor required by JPA
public Customer() {}

/**
* Creates a Customers object.
* Creates a Customer object.
* @param customerId The Customer ID
* @param customerName The Customer Name
* @param customerEmail The Customer Email
Expand All @@ -50,61 +49,101 @@ public Customer(String customerId, String customerName, String customerEmail, St
this.customerEmail = customerEmail;
this.customerOtherDetails = customerOtherDetails;
}


/**
* Full constructor including password
* @param customerId The Customer ID
* @param customerName The Customer Name
* @param customerEmail The Customer Email
* @param customerOtherDetails Other details about the customer
* @param customerPassword The Customer Password
*/
public Customer(String customerId, String customerName, String customerEmail,
String customerOtherDetails, String customerPassword) {
this.customerId = customerId;
this.customerName = customerName;
this.customerEmail = customerEmail;
this.customerOtherDetails = customerOtherDetails;
this.customerPassword = customerPassword;
}

@Id
@Column(name = "CUSTOMER_ID", nullable = false, updatable = false)
public String getCustomerId() {
return customerId;
}

public void setCustomerId(String customerId) {
this.customerId = customerId;
}

@Column(name = "CUSTOMER_NAME")
public String getCustomerName() {
return customerName;
}

public void setCustomerName(String customerName) {
this.customerName = customerName;
}

@Column(name = "CUSTOMER_EMAIL")
public String getCustomerEmail() {
return customerEmail;
}

public void setCustomerEmail(String customerEmail) {
this.customerEmail = customerEmail;
}

@CreationTimestamp
@Column(name = "DATE_BECAME_CUSTOMER", updatable = false, insertable = false)
public Date getDateBecameCustomer() {
return dateBecameCustomer;
}

public void setDateBecameCustomer(Date dateBecameCustomer) {
this.dateBecameCustomer = dateBecameCustomer;
}

@Column(name = "CUSTOMER_OTHER_DETAILS")
public String getCustomerOtherDetails() {
return customerOtherDetails;
}

public void setCustomerOtherDetails(String customerOtherDetails) {
this.customerOtherDetails = customerOtherDetails;
}

@Column(name = "PASSWORD")
public String getCustomerPassword() {
return customerPassword;
}

public void setCustomerPassword(String customerPassword) {
this.customerPassword = customerPassword;
}

}

@Override
public String toString() {
return "Customer{" +
"customerId='" + customerId + '\'' +
", customerName='" + customerName + '\'' +
", customerEmail='" + customerEmail + '\'' +
", dateBecameCustomer=" + dateBecameCustomer +
", customerOtherDetails='" + customerOtherDetails + '\'' +
'}';
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Customer customer = (Customer) o;
return customerId != null ? customerId.equals(customer.customerId) : customer.customerId == null;
}

@Override
public int hashCode() {
return customerId != null ? customerId.hashCode() : 0;
}
}
Loading