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
Binary file added class-diagramm-user.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions domain_model.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
| Classes | Methods | Variables | Scenario | Results |
|-----------|---------------------------------------------|------------------------------------|---------------------------------------------------------|------------------------|
| `User` | `createUser(String email, String password)` | `HashMap<String, String> userlist` | 1. | |
| | | (key is email, value is password) | Create user if email and password is not empty or null | Output success message |
| | | | or if user exists | Update the userlist |
| | | | | Return true |
| | | | 2. | |
| | | | If password is empty, null or invalid or if user exists | Output failure message |
| | | | | Don't update userlist |
| | | | | Return false |
| | | | 3. | |
| | | | If email is empty, null or invalid or if user exists | Output failure message |
| | | | | Don't update userlist |
| | | | | Return false |
| `Account` | `setStatus(User user)` | `HashMap<User, String> accounts` | 4. | |
| | | (key is user, value is status) | Set the status of the new user if status is disabled | Output success message |
| | | | | Update the userlist |
| | | | | Return true |
| | `canLog(User user)` | | 5. | |
| | | | user can log if status is enabled | Output success message |
| | | | | Don't update userlist |
| | | | | Return true |
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;
}
}
71 changes: 71 additions & 0 deletions src/test/java/com/booleanuk/core/TodoItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,75 @@

class TodoItemTest {

@Test
public void setStatus() {
TodoItem todoItem = new TodoItem("Wash the car", "It's dirty", "");
todoItem.setStatus("incomplete");

Assertions.assertEquals("incomplete", todoItem.getStatus());

TodoItem todoItem2 = new TodoItem("Read a book", "It relaxes me", "");
todoItem2.setStatus("complete");

Assertions.assertNotEquals("incomplete", todoItem2.getStatus());
}

@Test
public void setTitle() {
TodoItem todoItem = new TodoItem("", "It's dirty", "incomplete");
todoItem.setTitle("Wash the car");

Assertions.assertEquals("Wash the car", todoItem.getTitle());

TodoItem todoItem2 = new TodoItem("", "It relaxes me", "complete");
todoItem2.setTitle("Read a book");

Assertions.assertNotEquals("Wash the car", todoItem2.getTitle());
}

@Test
public void setDetail() {
TodoItem todoItem = new TodoItem("Wash the car", "", "incomplete");
todoItem.setDetail("It's dirty");

Assertions.assertEquals("It's dirty", todoItem.getDetail());

TodoItem todoItem2 = new TodoItem("Read a book", "", "complete");
todoItem2.setDetail("It relaxes me");

Assertions.assertNotEquals("It's dirty", todoItem2.getDetail());
}

@Test
public void getStatus() {
TodoItem todoItem = new TodoItem("Wash the car", "It's dirty", "incomplete");

Assertions.assertEquals("incomplete", todoItem.getStatus());

TodoItem todoItem2 = new TodoItem("Read a book", "It relaxes me", "complete");

Assertions.assertNotEquals("incomplete", todoItem2.getStatus());
}

@Test
public void getTitle() {
TodoItem todoItem = new TodoItem("Wash the car", "It's dirty", "incomplete");

Assertions.assertEquals("Wash the car", todoItem.getTitle());

TodoItem todoItem2 = new TodoItem("Read a book", "It relaxes me", "complete");

Assertions.assertNotEquals("Wash the car", todoItem2.getTitle());
}

@Test
public void getDetail() {
TodoItem todoItem = new TodoItem("Wash the car", "It's dirty", "incomplete");

Assertions.assertEquals("It's dirty", todoItem.getDetail());

TodoItem todoItem2 = new TodoItem("Read a book", "It relaxes me", "complete");

Assertions.assertNotEquals("It's dirty", todoItem2.getDetail());
}
}