diff --git a/src/main/java/hs/fulda/de/ci/exam/project/Account.java b/src/main/java/hs/fulda/de/ci/exam/project/Account.java new file mode 100644 index 0000000..ed2736c --- /dev/null +++ b/src/main/java/hs/fulda/de/ci/exam/project/Account.java @@ -0,0 +1,55 @@ +package hs.fulda.de.ci.exam.project; + +public class Account { + public Account(String id, String password, AccountStatus status) { + this.id = id; + this.password = password; + this.status = status; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public AccountStatus getStatus() { + return status; + } + + public void setStatus(AccountStatus status) { + this.status = status; + } + + public enum AccountStatus { + ACTIVE, + CLOSED, + CANCELED, + BLACKLISTED, + BLOCKED + } + + private String id; + private String password; + private AccountStatus status; + + public boolean resetPassword(String new_password){ + if(status == AccountStatus.ACTIVE){ + this.password = new_password; + } + return false; + } + + +} + diff --git a/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java b/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java new file mode 100644 index 0000000..e020cb8 --- /dev/null +++ b/src/test/java/hs/fulda/de/ci/exam/project/AccountTest.java @@ -0,0 +1,20 @@ +package hs.fulda.de.ci.exam.project; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class AccountTest { + @Test + void test_resetPassword(){ + Account account1 = new Account("123", "password", Account.AccountStatus.ACTIVE); + Account account2 = new Account("453", "notactive", Account.AccountStatus.CANCELED); + + account1.resetPassword("newpass"); + account2.resetPassword("notgood"); + + assertEquals("newpass", account1.getPassword(),"Password successfully changed."); + assertEquals("notactive", account2.getPassword(),"Activate your account to change your password"); + + } +}