-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 'ui-improvements'
- Loading branch information
Showing
15 changed files
with
338 additions
and
215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
213 changes: 116 additions & 97 deletions
213
script/core/main/src/test/java/core/main/BoardTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,116 @@ | ||
// package core.main; | ||
|
||
// import static org.junit.jupiter.api.Assertions.assertEquals; | ||
// import static org.junit.jupiter.api.Assertions.assertFalse; | ||
// import static org.junit.jupiter.api.Assertions.assertThrows; | ||
// import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
// import org.junit.jupiter.api.Test; | ||
|
||
// import java.util.Arrays; | ||
// import java.util.List; | ||
// import java.util.stream.IntStream; | ||
|
||
// public class BoardTest { | ||
|
||
// @Test | ||
// public void testConstructor() { | ||
// Board newBoard = new Board("Name", "Description"); | ||
// assertEquals("Name", newBoard.getBoardName()); | ||
// assertEquals("Description", newBoard.getBoardDescription()); | ||
// } | ||
|
||
// @Test | ||
// public void testAddNote() { | ||
// // Tests that board is empty by default | ||
// Board board = new Board("Board", "Test"); | ||
// assertTrue(board.getBoardElements().isEmpty()); | ||
|
||
// // Tests that addBoardElement works as intended for a valid note | ||
// Note note = new Note("", ""); | ||
// board.addBoardElement(note); | ||
// assertFalse(board.getBoardElements().isEmpty()); | ||
// assertEquals(note, board.getBoardElements().get(0)); | ||
|
||
// // Tests for exception case: note == null | ||
// assertThrows(IllegalArgumentException.class, () -> { | ||
// board.addBoardElement(null); | ||
// }); | ||
|
||
// // Tests for exception case: Exceeded MAX_NOTES | ||
// // stream with 256 | ||
// List<Note> notes = Arrays.asList( | ||
// IntStream.range(1, 256).mapToObj(i -> new Note(String.format("Note %d", i), | ||
// "")).toArray(Note[]::new)); | ||
// notes.stream().forEach(n -> board.addBoardElement(n)); | ||
// assertThrows(IllegalArgumentException.class, () -> { | ||
// board.addBoardElement(new Note("", "")); | ||
// }); | ||
// } | ||
|
||
// @Test | ||
// public void testSetName() { | ||
// Board board = new Board("Name", "Description"); | ||
// assertEquals("Name", board.getBoardName()); | ||
// board.setBoardName("New Name"); | ||
// assertEquals("New Name", board.getBoardName()); | ||
// } | ||
|
||
// @Test | ||
// public void testSetDescription() { | ||
// Board board = new Board("Name", "Description"); | ||
// assertEquals("Description", board.getBoardDescription()); | ||
// board.setBoardDescription("New Description"); | ||
// assertEquals("New Description", board.getBoardDescription()); | ||
// } | ||
|
||
// @Test | ||
// public void testGetNote() { | ||
// Board board = new Board("Board", "Test"); | ||
// Note note1 = new Note("Title1", ""); | ||
// Note note2 = new Note("Title2", ""); | ||
// board.addBoardElement(note1); | ||
// board.addBoardElement(note2); | ||
// assertEquals(note1, board.getBoardElement("Title1")); | ||
// assertEquals(note2, board.getBoardElement("Title2")); | ||
// } | ||
|
||
// @Test | ||
// public void testRemoveNote() { | ||
// Board board = new Board("Board", "Test"); | ||
// Note note1 = new Note("Title1", ""); | ||
// Note note2 = new Note("Title2", ""); | ||
// board.addBoardElement(note1); | ||
// board.addBoardElement(note2); | ||
|
||
// // Tests that the board contains both notes | ||
// assertTrue(board.getBoardElements().contains(note1) && | ||
// board.getBoardElements().contains(note2)); | ||
|
||
// // Tests that removeNote() removed the intended note | ||
// board.removeNote("Title2"); | ||
// assertFalse(board.getBoardElements().contains(note2)); | ||
|
||
// // Tests that the other note is unaffected by removeNote() | ||
// assertTrue(board.getBoardElements().contains(note1)); | ||
// } | ||
// } | ||
package core.main; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertFalse; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import org.junit.jupiter.api.DisplayName; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.IntStream; | ||
|
||
public class BoardTest { | ||
|
||
@Test | ||
@DisplayName("Test constructor") | ||
public void testConstructor() { | ||
Board newBoard = new Board("Name", "Description"); | ||
assertEquals("Name", newBoard.getBoardName()); | ||
assertEquals("Description", newBoard.getBoardDescription()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test add note") | ||
public void testAddNote() { | ||
// Tests that board is empty by default | ||
Board board = new Board("Board", "Test"); | ||
assertTrue(board.getNotes().isEmpty() && board.getChecklists().isEmpty()); | ||
|
||
// Tests that addBoardElement works as intended for a valid note | ||
Note note = new Note(); | ||
board.addNote(note); | ||
assertFalse(board.getNotes().isEmpty() && !board.getChecklists().isEmpty()); | ||
assertEquals(note, board.getNotes().get(0)); | ||
|
||
// Tests for exception case: note == null | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
board.addNote(null); | ||
}); | ||
|
||
// Tests for exception case: Exceeded MAX_NOTES | ||
// stream with 256 | ||
List<Note> notes = Arrays.asList( | ||
IntStream.range(1, 256).mapToObj(i -> new Note()).toArray(Note[]::new)); | ||
notes.stream().forEach(n -> board.addNote(n)); | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
board.addNote(new Note()); | ||
}); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test set name") | ||
public void testSetName() { | ||
Board board = new Board("Name", "Description"); | ||
assertEquals("Name", board.getBoardName()); | ||
board.setBoardName("New Name"); | ||
assertEquals("New Name", board.getBoardName()); | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
board.setBoardName(""); | ||
}); | ||
assertThrows(NullPointerException.class, () -> { | ||
board.setBoardName(null); | ||
}); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test set desctription") | ||
public void testSetDescription() { | ||
Board board = new Board("Name", "Description"); | ||
assertEquals("Description", board.getBoardDescription()); | ||
board.setBoardDescription("New Description"); | ||
assertEquals("New Description", board.getBoardDescription()); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test get notes") | ||
public void testGetNotes() { | ||
Board board = new Board("Board", "Test"); | ||
Note note1 = new Note(); | ||
Note note2 = new Note(); | ||
board.addNote(note1); | ||
board.addNote(note2); | ||
assertEquals(note1, board.getNotes().get(0)); | ||
assertEquals(note2, board.getNotes().get(1)); | ||
} | ||
|
||
@Test | ||
@DisplayName("Test add checklists") | ||
public void testAddChecklists() { | ||
// Tests that board is empty by default | ||
Board board = new Board("Board", "Test"); | ||
assertTrue(board.getChecklists().isEmpty() && board.getChecklists().isEmpty()); | ||
|
||
// Tests that addBoardElement works as intended for a valid Checklist | ||
Checklist checklist = new Checklist(); | ||
board.addChecklist(checklist); | ||
assertFalse(board.getChecklists().isEmpty() && !board.getChecklists().isEmpty()); | ||
assertEquals(checklist, board.getChecklists().get(0)); | ||
|
||
// Tests for exception case: Checklist == null | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
board.addChecklist(null); | ||
}); | ||
|
||
// Tests for exception case: Exceeded MAX_ChecklistS | ||
// stream with 256 | ||
List<Checklist> checklists = Arrays.asList( | ||
IntStream.range(1, 256).mapToObj(i -> new Checklist()).toArray(Checklist[]::new)); | ||
checklists.stream().forEach(n -> board.addChecklist(n)); | ||
assertThrows(IllegalArgumentException.class, () -> { | ||
board.addChecklist(new Checklist()); | ||
}); | ||
} | ||
} |
Oops, something went wrong.