-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
13 define entity seniormanageraccess #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/* | ||
* Copyright (c) 2018-2023 adorsys GmbH and Co. KG | ||
* All rights are reserved. | ||
*/ | ||
|
||
package de.adorsys.ledgers.baam.db.domain; | ||
|
||
import jakarta.persistence.*; | ||
import lombok.Data; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
@Entity | ||
@Data | ||
public class SeniorManagerAccess { | ||
|
||
@Id | ||
@GeneratedValue(strategy = GenerationType.IDENTITY) | ||
private String id; | ||
|
||
private String name; | ||
|
||
@Enumerated(EnumType.STRING) | ||
private AccessStatus status; | ||
|
||
@ElementCollection | ||
private Map<String, String> managerRoles = new HashMap<>(); | ||
|
||
// Constructor | ||
public SeniorManagerAccess(String name, AccessStatus status) { | ||
this.name = name; | ||
this.status = status.ACTIVE; | ||
} | ||
|
||
// Default constructor for JPA | ||
public SeniorManagerAccess() {} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. perfect... doing these will make more sense:
|
||
|
||
// Getters and Setters | ||
//... | ||
Comment on lines
+38
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PLease remove these comment, it's not needed |
||
|
||
// Methods | ||
public void createManagerRole(String managerId, String permissions) { | ||
if (this.status != AccessStatus.ACTIVE) { | ||
throw new IllegalStateException("Cannot create roles when status is not active."); | ||
} | ||
managerRoles.put(managerId, permissions); | ||
} | ||
|
||
public void modifyManagerRole(String managerId, String newPermissions) { | ||
if (managerRoles.containsKey(managerId)) { | ||
managerRoles.put(managerId, newPermissions); | ||
} else { | ||
throw new IllegalArgumentException("Manager role not found."); | ||
} | ||
} | ||
|
||
public void revokeManagerRole(String managerId) { | ||
if (managerRoles.containsKey(managerId)) { | ||
managerRoles.remove(managerId); | ||
} else { | ||
throw new IllegalArgumentException("Manager role not found."); | ||
} | ||
} | ||
|
||
public void suspendAccess() { | ||
this.status = AccessStatus.SUSPENDED; | ||
} | ||
|
||
public void activateAccess() { | ||
this.status = AccessStatus.ACTIVE; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2018-2023 adorsys GmbH and Co. KG | ||
* All rights are reserved. | ||
*/ | ||
|
||
package de.adorsys.ledgers.baam.db.repository; | ||
import de.adorsys.ledgers.baam.db.domain.SeniorManagerAccess; | ||
import org.springframework.data.jpa.repository.JpaRepository; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public interface SeniorManagerAccessRepository extends JpaRepository<SeniorManagerAccess, Long> { | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright (c) 2018-2023 adorsys GmbH and Co. KG | ||
* All rights are reserved. | ||
*/ | ||
|
||
package de.adorsys.ledgers.baam.db.domain; | ||
|
||
import org.junit.jupiter.api.Test; | ||
class SeniorManagerAccessTest { | ||
|
||
@Test | ||
void createManagerRole() { | ||
} | ||
|
||
@Test | ||
void modifyManagerRole() { | ||
} | ||
|
||
@Test | ||
void revokeManagerRole() { | ||
} | ||
|
||
@Test | ||
void suspendAccess() { | ||
} | ||
|
||
@Test | ||
void activateAccess() { | ||
} | ||
Comment on lines
+1
to
+29
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PLease right a full test for these entity.. use you can use an h2 database which acts as an in memory DB for the test.. these is to ensure that the entire logic is working perfectly fine and everything is actually stored in a database. Also please ensure to do a git pull so as to see recent changes, these will help you see the new recent project structure for our module. |
||
} | ||
Comment on lines
+1
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hello @Koufan-De-King please implememt the various test cases .. Also since the seniormanageraccess is an entity, it needs to be included into the ledgers DB.. to verify, executed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're trying to access the ACTIVE value in the wrong way.
In your constructor, you're passing status as a parameter, and then you use status.ACTIVE. This confuses Java, because it thinks you're trying to get ACTIVE from the status parameter, which doesn't make sense.
The Fix:
Instead of using status.ACTIVE, you should directly use the enum name AccessStatus.ACTIVE to get the ACTIVE value.
The constructor sets this.status to AccessStatus.ACTIVE regardless of the input.
Correction: Change the constructor to accept the status parameter.(
this.status=status
)