Skip to content

Commit

Permalink
Refactore BankAccountAcces and HolderAccess
Browse files Browse the repository at this point in the history
  • Loading branch information
nancymuyeh committed Oct 4, 2024
1 parent 42f3cae commit b2f6273
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ public abstract class BankAccountAccess {
@NotNull
private String entityId;

public BankAccountAccess(String accountId, String entityId) {
this.accountId = accountId;
this.entityId = entityId;
}

@Enumerated(EnumType.STRING)
private AccessScope scope; // Allowed actions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,46 +10,10 @@
@NoArgsConstructor(force = true)
public class HolderAccess extends BankAccountAccess {


// @Column(name = "holder_id")
@Column(name = "holder_id")
private String holderId; // ID of the account holder

@Column(name = "user_id", nullable = false)
private String userId;



// Constructor for creating HolderAccess with full access
public HolderAccess(String holderId) {
super(); // Call to the superclass constructor
this.holderId = holderId;
this.userId = userId;
}

// Method to suspend access
public void suspendAccess() {
this.setStatus(AccessStatus.SUSPENDED);
}

// Method to reactivate access
public void reactivateAccess() {
this.setStatus(AccessStatus.ACTIVE);
}

public void restrictAccess() {
this.setStatus(AccessStatus.RESTRICTED);
}

// Method to modify permissions for other roles
public void modifyPermissions(String newPermissions) {
this.setPolicies(newPermissions);
}

// Override toString for better debugging
@Override
public String toString() {
return String.format("HolderAccess{id='%s', accountId='%s', holderId='%s', status='%s'}",
getId(), getAccountId(), holderId, getStatus());
public HolderAccess(String entityId, String accountId) {
super();
this.setEntityId(entityId);
this.setAccountId(accountId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ void mockTest() {
repository.deleteAll();
HolderAccess access = new HolderAccess();
access.setId("1");
access.setUserId("1");
access.setHolderId("1");
access.setAccountId("1");
access.setEntityId("1");
access.setWeight(1);
Expand Down

0 comments on commit b2f6273

Please sign in to comment.