Skip to content

Commit

Permalink
Merge pull request #27 from ADORSYS-GIS/25-define-entity-agentaccess
Browse files Browse the repository at this point in the history
chore: created and tested agent access entity
  • Loading branch information
Koufan-De-King authored Oct 4, 2024
2 parents 4f4dbd9 + 10143c3 commit b3bc4dd
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ public enum AccessScope {
WRITE,
EXECUTE,
DELETE;

}
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();
}
}
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> {

}

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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@

//NOPMD

import de.adorsys.ledgers.um.api.domain.*;
import org.springframework.data.domain.*;

import java.time.*;
import java.util.*;
import de.adorsys.ledgers.um.api.domain.UserBO;
import de.adorsys.ledgers.um.api.domain.ScaUserDataBO;
import de.adorsys.ledgers.um.api.domain.AccountAccessBO;
import de.adorsys.ledgers.um.api.domain.AisConsentBO;
import de.adorsys.ledgers.um.api.domain.UserExtendedBO;
import de.adorsys.ledgers.um.api.domain.UserRoleBO;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

public interface UserService {

Expand Down

0 comments on commit b3bc4dd

Please sign in to comment.