-
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 #27 from ADORSYS-GIS/25-define-entity-agentaccess
chore: created and tested agent access entity
- Loading branch information
Showing
5 changed files
with
88 additions
and
5 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -11,4 +11,5 @@ public enum AccessScope { | |
WRITE, | ||
EXECUTE, | ||
DELETE; | ||
|
||
} |
13 changes: 13 additions & 0 deletions
13
...ccount-access-repository/src/main/java/de/adorsys/ledgers/baam/db/domain/AgentAccess.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.domain; | ||
|
||
import jakarta.persistence.Entity; | ||
import jakarta.persistence.Table; | ||
|
||
@Entity | ||
@Table(name = "agent_access") | ||
public class AgentAccess extends BankAccountAccess { | ||
|
||
public AgentAccess() { | ||
super(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...repository/src/main/java/de/adorsys/ledgers/baam/db/repository/AgentAccessRepository.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.AgentAccess; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface AgentAccessRepository extends JpaRepository<AgentAccess, String> { | ||
|
||
} | ||
|
51 changes: 51 additions & 0 deletions
51
...pository/src/test/java/de/adorsys/ledgers/baam/db/repository/AgentAccessRepositoryIT.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,51 @@ | ||
package de.adorsys.ledgers.baam.db.repository; | ||
|
||
import com.github.springtestdbunit.DbUnitTestExecutionListener; | ||
import de.adorsys.ledgers.baam.db.domain.*; | ||
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 static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
@SpringBootTest(classes = BaamRepositoryApplication.class) | ||
@ExtendWith(SpringExtension.class) | ||
@TestExecutionListeners({DependencyInjectionTestExecutionListener.class, | ||
TransactionalTestExecutionListener.class, | ||
DbUnitTestExecutionListener.class}) | ||
|
||
public class AgentAccessRepositoryIT { | ||
|
||
@Autowired | ||
private AgentAccessRepository agentAccessRepository; | ||
|
||
@Test | ||
void test_create_ok() { | ||
// Given | ||
agentAccessRepository.deleteAll(); // Clean up any existing records | ||
AgentAccess agentAccess = new AgentAccess(); | ||
agentAccess.setId("1"); | ||
agentAccess.setAccountId("1L"); | ||
agentAccess.setEntityId("2L"); | ||
agentAccess.setScope(AccessScope.EXECUTE); // Example action scope | ||
agentAccess.setWeight(0.5); // Partial authority | ||
agentAccess.setConditions(AccessCondition.AMOUNT_RESTRICTED); // Example condition | ||
agentAccess.setStatus(AccessStatus.ACTIVE); // Agent is active | ||
agentAccess.setPolicies("Payment-Only Policy"); // Example policy | ||
|
||
// When | ||
AgentAccess savedAccess = agentAccessRepository.save(agentAccess); | ||
|
||
// Retrieve the saved object | ||
AgentAccess result = agentAccessRepository.findById(savedAccess.getId()).orElse(null); | ||
|
||
// Then | ||
assertNotNull(result); | ||
} | ||
} |
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