-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create TellerAccess entity and add unit tests
- Loading branch information
1 parent
4736e14
commit 39834c3
Showing
3 changed files
with
136 additions
and
0 deletions.
There are no files selected for viewing
42 changes: 42 additions & 0 deletions
42
...count-access-repository/src/main/java/de/adorsys/ledgers/baam/db/domain/TellerAccess.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package de.adorsys.ledgers.baam.db.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.GeneratedValue; | ||
import jakarta.persistence.GenerationType; | ||
import jakarta.persistence.Id; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import jakarta.persistence.*; | ||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
@Entity | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class TellerAccess { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.UUID) | ||
private UUID id; | ||
|
||
private String name; | ||
private String tellerId; | ||
|
||
|
||
@Enumerated(EnumType.STRING) | ||
private AccessStatus status; | ||
|
||
private double dailyLimit; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
private Date createdDate; | ||
|
||
@Temporal(TemporalType.TIMESTAMP) | ||
private Date lastModifiedDate; | ||
|
||
|
||
private String accessType = "TELLER_ACCESS"; | ||
} |
13 changes: 13 additions & 0 deletions
13
...epository/src/main/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package de.adorsys.ledgers.baam.db.repository; | ||
|
||
|
||
import de.adorsys.ledgers.baam.db.domain.TellerAccess; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
import java.util.UUID; | ||
|
||
@Repository | ||
public interface TellerAccessRepository extends JpaRepository<TellerAccess, UUID> { | ||
|
||
} |
81 changes: 81 additions & 0 deletions
81
...ository/src/test/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepositoryIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package de.adorsys.ledgers.baam.db.repository; | ||
|
||
import de.adorsys.ledgers.baam.db.domain.AccessStatus; | ||
import de.adorsys.ledgers.baam.db.domain.TellerAccess; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Date; | ||
import java.util.UUID; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
class TellerAccessTest { | ||
|
||
private TellerAccess tellerAccess; | ||
|
||
@BeforeEach | ||
void setUp() { | ||
tellerAccess = new TellerAccess(); | ||
} | ||
|
||
@Test | ||
void testTellerAccessCreation() { | ||
// Create UUID | ||
UUID id = UUID.randomUUID(); | ||
String tellerName = "John Doe"; | ||
String tellerId = "TELLER123"; | ||
AccessStatus status = AccessStatus.ACTIVE; | ||
double dailyLimit = 5000.0; | ||
Date createdDate = new Date(); | ||
Date lastModifiedDate = new Date(); | ||
|
||
// Set values using constructor | ||
TellerAccess tellerAccess = new TellerAccess(id, tellerName, tellerId, status, dailyLimit, createdDate, lastModifiedDate, "TELLER_ACCESS"); | ||
|
||
// Assert that the values have been set correctly | ||
assertEquals(id, tellerAccess.getId()); | ||
assertEquals(tellerName, tellerAccess.getName()); | ||
assertEquals(tellerId, tellerAccess.getTellerId()); | ||
assertEquals(status, tellerAccess.getStatus()); | ||
assertEquals(dailyLimit, tellerAccess.getDailyLimit()); | ||
assertEquals(createdDate, tellerAccess.getCreatedDate()); | ||
assertEquals(lastModifiedDate, tellerAccess.getLastModifiedDate()); | ||
assertEquals("TELLER_ACCESS", tellerAccess.getAccessType()); | ||
} | ||
|
||
@Test | ||
void testStatusUpdate() { | ||
// Initial status | ||
tellerAccess.setStatus(AccessStatus.ACTIVE); | ||
assertEquals(AccessStatus.ACTIVE, tellerAccess.getStatus()); | ||
|
||
// Change status to SUSPENDED | ||
tellerAccess.setStatus(AccessStatus.SUSPENDED); | ||
assertEquals(AccessStatus.SUSPENDED, tellerAccess.getStatus()); | ||
} | ||
|
||
@Test | ||
void testSetDailyLimit() { | ||
tellerAccess.setDailyLimit(2000.0); | ||
assertEquals(2000.0, tellerAccess.getDailyLimit()); | ||
|
||
// Update daily limit | ||
tellerAccess.setDailyLimit(3000.0); | ||
assertEquals(3000.0, tellerAccess.getDailyLimit()); | ||
} | ||
|
||
@Test | ||
void testSetCreatedDate() { | ||
Date now = new Date(); | ||
tellerAccess.setCreatedDate(now); | ||
assertEquals(now, tellerAccess.getCreatedDate()); | ||
} | ||
|
||
@Test | ||
void testSetLastModifiedDate() { | ||
Date now = new Date(); | ||
tellerAccess.setLastModifiedDate(now); | ||
assertEquals(now, tellerAccess.getLastModifiedDate()); | ||
} | ||
} |