diff --git a/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/main/java/de/adorsys/ledgers/baam/db/domain/TellerAccess.java b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/main/java/de/adorsys/ledgers/baam/db/domain/TellerAccess.java new file mode 100644 index 000000000..07068d907 --- /dev/null +++ b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/main/java/de/adorsys/ledgers/baam/db/domain/TellerAccess.java @@ -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; + +} diff --git a/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/main/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepository.java b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/main/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepository.java new file mode 100644 index 000000000..9f1977131 --- /dev/null +++ b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/main/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepository.java @@ -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 { + +} diff --git a/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/test/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepositoryTest.java b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/test/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepositoryTest.java new file mode 100644 index 000000000..5a14a3a17 --- /dev/null +++ b/ledgers-bank-account-access-management/ledgers-bank-account-access-repository/src/test/java/de/adorsys/ledgers/baam/db/repository/TellerAccessRepositoryTest.java @@ -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 retrievedTellerAccess = tellerAccessRepository.findById("123"); + assertTrue(retrievedTellerAccess.isPresent()); + assertEquals(3000.0, retrievedTellerAccess.get().getDailyLimit()); + } +}