-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from ADORSYS-GIS/TellerAccess
feat: Create TellerAccess entity and add unit tests
- Loading branch information
Showing
3 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
16 changes: 16 additions & 0 deletions
16
...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,16 @@ | ||
package de.adorsys.ledgers.baam.db.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Entity | ||
@Data | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class TellerAccess extends BankAccountAccess { | ||
|
||
private double dailyLimit; | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
...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,11 @@ | ||
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; | ||
|
||
@Repository | ||
public interface TellerAccessRepository extends JpaRepository<TellerAccess, String> { | ||
|
||
} |
61 changes: 61 additions & 0 deletions
61
...itory/src/test/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepositoryTest.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,61 @@ | ||
package de.adorsys.ledgers.baam.db.repository; | ||
|
||
import com.github.springtestdbunit.DbUnitTestExecutionListener; | ||
import de.adorsys.ledgers.baam.db.domain.TellerAccess; | ||
import de.adorsys.ledgers.baam.db.test.BaamRepositoryApplication; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.test.context.TestExecutionListeners; | ||
import org.springframework.test.context.junit.jupiter.SpringExtension; | ||
import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; | ||
import org.springframework.test.context.transaction.TransactionalTestExecutionListener; | ||
|
||
import java.util.Optional; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@SpringBootTest(classes = BaamRepositoryApplication.class) | ||
@ExtendWith(SpringExtension.class) | ||
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class, | ||
TransactionalTestExecutionListener.class, | ||
DbUnitTestExecutionListener.class}) | ||
public class TellerAccessRepositoryTest { | ||
|
||
@Autowired | ||
private TellerAccessRepository tellerAccessRepository; | ||
|
||
@Test | ||
void testTellerAccessCreation() { | ||
|
||
TellerAccess tellerAccess = new TellerAccess(); | ||
|
||
tellerAccess.setId("123"); | ||
|
||
// Save to repository (persist) | ||
TellerAccess savedTellerAccess = tellerAccessRepository.save(tellerAccess); | ||
savedTellerAccess.setId("456"); | ||
assertNotEquals(savedTellerAccess.getId(), tellerAccess.getId()); | ||
|
||
} | ||
|
||
|
||
@Test | ||
void testSetDailyLimitInDatabase() { | ||
// Create and save an entity | ||
TellerAccess tellerAccess = new TellerAccess(); | ||
tellerAccess.setDailyLimit(3000.0); | ||
tellerAccess.setId("123"); | ||
|
||
TellerAccess savedTellerAccess = tellerAccessRepository.save(tellerAccess); | ||
|
||
// Update daily limit | ||
savedTellerAccess.setDailyLimit(3000.0); | ||
|
||
// Retrieve from DB and verify the daily limit change | ||
Optional<TellerAccess> retrievedTellerAccess = tellerAccessRepository.findById("123"); | ||
assertTrue(retrievedTellerAccess.isPresent()); | ||
assertEquals(3000.0, retrievedTellerAccess.get().getDailyLimit()); | ||
} | ||
} |