Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions src/main/java/com/booleanuk/core/TodoItem.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.booleanuk.core;

public class TodoItem {
public String title;
public String detail;
public String status;
private String title;
private String detail;
private String status;

public TodoItem(String title, String detail, String status) {
this.title = title;
Expand All @@ -18,4 +18,20 @@ public void setStatus(String status) {
public String getStatus() {
return this.status;
}

public String getTitle() {
return title;
}

public void setTitle(String title) {
this.title = title;
}

public String getDetail() {
return detail;
}

public void setDetail(String detail) {
this.detail = detail;
}
}
53 changes: 53 additions & 0 deletions src/main/java/com/booleanuk/core/User.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.booleanuk.core;

public class User {
private String email;
private String password;
private boolean enabled;

public User() {
this.enabled = false;
}

public String getEmail() {
return email;
}

public String setEmail(String email) {
if (email.contains("@")) {
this.email = email;
return "Email registered";
} else {
return "Invalid Email";
}
}

public String getPassword() {
return password;
}

public String setPassword(String password) {
if (password.length() <= 8) {
this.password = password;
return "Password Registered";
} else {
return "Invalid Password";
}
}

public void setEnabled(boolean status) {
this.enabled=status;
}

public boolean getEnabled() {
return enabled;
}

public boolean logIn() {
if (this.enabled) {
return true;
} else {
return false;
}
}
}
31 changes: 31 additions & 0 deletions src/test/java/com/booleanuk/core/Ex2Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.booleanuk.core;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class Ex2Test {
@Test
public void TestNewUser() {
User panos = new User();
Assertions.assertEquals(panos.setEmail("panagiotis_karapiperis@hotmail.com"),"Email registered");
Assertions.assertEquals(panos.setPassword("12345"),"Password Registered");
Assertions.assertEquals(panos.setEmail("panos"),"Invalid Email");
Assertions.assertEquals(panos.setPassword("kdsjflaskjdflksdj"),"Invalid Password");
}

@Test
public void TestStatus() {
User user = new User();
Assertions.assertFalse(user.getEnabled());
user.setEnabled(true);
Assertions.assertTrue(user.getEnabled());
}

@Test
public void checkLogin() {
User user = new User();
Assertions.assertFalse(user.logIn());
user.setEnabled(true);
Assertions.assertTrue(user.logIn());
}
}
11 changes: 10 additions & 1 deletion src/test/java/com/booleanuk/core/TodoItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,14 @@
import org.junit.jupiter.api.Test;

class TodoItemTest {

@Test
public void testAbstraction(){
TodoItem todo = new TodoItem("Wash the clothes", "seperate colours","not completed");
todo.setTitle("clean the floor");
todo.setDetail("attention to the corners");
todo.setStatus("completed");
Assertions.assertEquals(todo.getTitle(),"clean the floor");
Assertions.assertEquals(todo.getDetail(),"attention to the corners");
Assertions.assertEquals(todo.getStatus(),"completed");
}
}