Skip to content

Commit

Permalink
Merge pull request #178 from aliciamichellew/alicia/add-test
Browse files Browse the repository at this point in the history
Add tests for Note model package
  • Loading branch information
aliciamichellew authored Nov 2, 2023
2 parents 1fc0733 + 439ed95 commit 2cf7565
Show file tree
Hide file tree
Showing 65 changed files with 539 additions and 104 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ task coverage(type: JacocoReport) {
}

dependencies {
testImplementation 'junit:junit:4.13.1'
String jUnitVersion = '5.4.0'
String javaFxVersion = '17.0.7'

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.address.logic.parser.Prefix;
import seedu.address.model.localcourse.LocalCourse;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.person.Person;
import seedu.address.model.university.University;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/SeplendidLogic.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import seedu.address.model.SeplendidModel;
import seedu.address.model.localcourse.LocalCourse;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.university.University;
import seedu.address.seplendidui.Ui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import seedu.address.model.SeplendidModel;
import seedu.address.model.localcourse.LocalCourse;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.university.University;
import seedu.address.seplendidui.Ui;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.address.logic.commands.note.NoteCommand;
import seedu.address.model.Model;
import seedu.address.model.SeplendidModel;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.seplendidui.UiUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.SeplendidModel;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.seplendidui.UiUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.SeplendidModel;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.seplendidui.UiUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.SeplendidModel;
import seedu.address.model.notes.NoteTagContainsKeywordsPredicate;
import seedu.address.model.note.NoteTagContainsKeywordsPredicate;
import seedu.address.seplendidui.UiUtil;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.SeplendidModel;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.model.tag.Tag;
import seedu.address.seplendidui.UiUtil;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import seedu.address.logic.commands.exceptions.CommandException;
import seedu.address.model.Model;
import seedu.address.model.SeplendidModel;
import seedu.address.model.notes.Content;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Content;
import seedu.address.model.note.Note;
import seedu.address.seplendidui.UiUtil;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/logic/parser/ParserUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import seedu.address.model.localcourse.LocalUnit;
import seedu.address.model.mapping.MappingAttributeEnum;
import seedu.address.model.mapping.MappingMiscInformation;
import seedu.address.model.notes.Content;
import seedu.address.model.note.Content;
import seedu.address.model.partnercourse.PartnerCode;
import seedu.address.model.partnercourse.PartnerCourseAttribute;
import seedu.address.model.partnercourse.PartnerDescription;
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/seedu/address/logic/parser/SeplendidParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,10 @@
import seedu.address.logic.parser.mapping.MappingSearchCommandParser;
import seedu.address.logic.parser.mapping.MappingSortCommandParser;
import seedu.address.logic.parser.note.NoteAddCommandParser;
import seedu.address.logic.parser.note.NoteDeleteCommandParser;
import seedu.address.logic.parser.note.NoteSearchCommandParser;
import seedu.address.logic.parser.note.NoteTagCommandParser;
import seedu.address.logic.parser.note.NoteUpdateCommandParser;
import seedu.address.logic.parser.partnercourse.PartnerCourseAddCommandParser;
import seedu.address.logic.parser.partnercourse.PartnerCourseDeleteCommandParser;
import seedu.address.logic.parser.partnercourse.PartnerCourseSearchCommandParser;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
import seedu.address.logic.parser.SeplendidArgumentMap;
import seedu.address.logic.parser.SeplendidArgumentTokenizer;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.notes.Content;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Content;
import seedu.address.model.note.Note;
import seedu.address.model.tag.Tag;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package seedu.address.logic.parser;
package seedu.address.logic.parser.note;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PARAMETER_INDEX;
import static seedu.address.logic.parser.ParserUtil.areValuesEnclosedAndNonEmpty;

import seedu.address.logic.commands.note.NoteDeleteCommand;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.SeplendidArgumentMap;
import seedu.address.logic.parser.SeplendidArgumentTokenizer;
import seedu.address.logic.parser.exceptions.ParseException;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import seedu.address.logic.parser.SeplendidArgumentMap;
import seedu.address.logic.parser.SeplendidArgumentTokenizer;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.notes.NoteTagContainsKeywordsPredicate;
import seedu.address.model.note.NoteTagContainsKeywordsPredicate;
import seedu.address.model.tag.Tag;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
package seedu.address.logic.parser;
package seedu.address.logic.parser.note;

import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
import static seedu.address.logic.parser.CliSyntax.PARAMETER_INDEX;
import static seedu.address.logic.parser.CliSyntax.PARAMETER_TAGS;
import static seedu.address.logic.parser.ParserUtil.areValuesEnclosedAndNonEmpty;

import seedu.address.logic.commands.note.NoteTagCommand;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.SeplendidArgumentMap;
import seedu.address.logic.parser.SeplendidArgumentTokenizer;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.tag.Tag;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.parser;
package seedu.address.logic.parser.note;


import static seedu.address.logic.Messages.MESSAGE_INVALID_COMMAND_FORMAT;
Expand All @@ -7,8 +7,12 @@
import static seedu.address.logic.parser.ParserUtil.areValuesEnclosedAndNonEmpty;

import seedu.address.logic.commands.note.NoteUpdateCommand;
import seedu.address.logic.parser.Parser;
import seedu.address.logic.parser.ParserUtil;
import seedu.address.logic.parser.SeplendidArgumentMap;
import seedu.address.logic.parser.SeplendidArgumentTokenizer;
import seedu.address.logic.parser.exceptions.ParseException;
import seedu.address.model.notes.Content;
import seedu.address.model.note.Content;

/**
* Parses the given {@code String} of arguments in the context of the UpdateCommand
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/NoteCatalogue.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

import javafx.collections.ObservableList;
import seedu.address.commons.util.ToStringBuilder;
import seedu.address.model.notes.Note;
import seedu.address.model.notes.UniqueNoteList;
import seedu.address.model.note.Note;
import seedu.address.model.note.UniqueNoteList;

/**
* Wraps note data at the catalogue level
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package seedu.address.model;

import javafx.collections.ObservableList;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;

/**
* Unmodifiable view of note catalogue.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/SeplendidModel.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
import seedu.address.model.localcourse.LocalCourseAttribute;
import seedu.address.model.localcourse.LocalCourseContainsKeywordsPredicate;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.notes.NoteTagContainsKeywordsPredicate;
import seedu.address.model.note.Note;
import seedu.address.model.note.NoteTagContainsKeywordsPredicate;
import seedu.address.model.partnercourse.PartnerCode;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.partnercourse.PartnerCourseAttribute;
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/SeplendidModelManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
import seedu.address.model.localcourse.LocalCourseAttribute;
import seedu.address.model.localcourse.LocalCourseContainsKeywordsPredicate;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.notes.NoteTagContainsKeywordsPredicate;
import seedu.address.model.note.Note;
import seedu.address.model.note.NoteTagContainsKeywordsPredicate;
import seedu.address.model.partnercourse.PartnerCode;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.partnercourse.PartnerCourseAttribute;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.model.notes;
package seedu.address.model.note;

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.AppUtil.checkArgument;
Expand All @@ -14,7 +14,7 @@ public class Content {
* The first character of the address must not be a whitespace,
* otherwise " " (a blank string) becomes a valid input.
*/
public static final String VALIDATION_REGEX = "^[\\p{Alnum} .,!?\"'():\\-–]+";
public static final String VALIDATION_REGEX = "[^\\s].*[^\\s]";

public final String content;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.model.notes;
package seedu.address.model.note;

import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;

Expand Down Expand Up @@ -93,8 +93,7 @@ public boolean isSameNote(Note otherNote) {
}

return otherNote != null
&& otherNote.getContent().equals(getContent())
&& otherNote.getIndex().equals(getIndex());
&& otherNote.getContent().equals(getContent());
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.model.notes;
package seedu.address.model.note;

import java.util.function.Predicate;

Expand Down Expand Up @@ -26,7 +26,7 @@ public boolean equals(Object other) {
}

// instanceof handles nulls
if (!(other instanceof seedu.address.model.notes.NoteTagContainsKeywordsPredicate)) {
if (!(other instanceof seedu.address.model.note.NoteTagContainsKeywordsPredicate)) {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.model.notes;
package seedu.address.model.note;

import static java.util.Objects.requireNonNull;
import static seedu.address.commons.util.CollectionUtil.requireAllNonNull;
Expand All @@ -8,8 +8,8 @@

import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import seedu.address.model.notes.exceptions.DuplicateNoteException;
import seedu.address.model.notes.exceptions.NoteNotFoundException;
import seedu.address.model.note.exceptions.DuplicateNoteException;
import seedu.address.model.note.exceptions.NoteNotFoundException;


/**
Expand Down Expand Up @@ -65,7 +65,7 @@ public void setNote(Note target, Note editedNote) {
* Removes the equivalent note from the list.
* The note must exist in the list.
*/
public Note remove(int toRemove) {
public Note remove(Integer toRemove) {
requireNonNull(toRemove);

for (int i = toRemove; i < internalList.size(); i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.model.notes.exceptions;
package seedu.address.model.note.exceptions;

/**
* Signals that the operation will result in duplicate Notes (Notes are considered duplicates if they have the same
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.model.notes.exceptions;
package seedu.address.model.note.exceptions;

/**
* Signals that the operation is unable to find the specified note.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/model/sampledata/SampleNotes.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

import java.util.Arrays;

import seedu.address.model.notes.Content;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Content;
import seedu.address.model.note.Note;
import seedu.address.model.tag.Tag;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/model/util/SampleDataUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import seedu.address.model.UniversityCatalogue;
import seedu.address.model.localcourse.LocalCourse;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.person.Person;
import seedu.address.model.sampledata.SampleLocalCourses;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import seedu.address.model.PartnerCourseCatalogue;
import seedu.address.model.localcourse.LocalCourse;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.university.University;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/seplendidui/ItemListPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import seedu.address.model.SeplendidDataType;
import seedu.address.model.localcourse.LocalCourse;
import seedu.address.model.mapping.Mapping;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;
import seedu.address.model.partnercourse.PartnerCourse;
import seedu.address.model.university.University;

Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/seplendidui/NoteDetail.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import javafx.scene.layout.Region;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;

/**
* A UI component that displays information of a {@code note}.
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/seedu/address/seplendidui/NoteItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;

/**
* An UI component that displays information of a {@code Note}.
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/seedu/address/storage/JsonAdaptedNote.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
import com.fasterxml.jackson.annotation.JsonProperty;

import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.notes.Content;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Content;
import seedu.address.model.note.Note;
import seedu.address.model.tag.Tag;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import seedu.address.commons.exceptions.IllegalValueException;
import seedu.address.model.NoteCatalogue;
import seedu.address.model.ReadOnlyNoteCatalogue;
import seedu.address.model.notes.Note;
import seedu.address.model.note.Note;

/**
* An Immutable NoteCatalogue that is serializable to JSON format.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package seedu.address.logic.commands;
package seedu.address.logic.commands.localcourse;

import static seedu.address.logic.commands.CommandTestUtil.assertSeplendidCommandFailure;
import static seedu.address.logic.commands.CommandTestUtil.assertSeplendidCommandSuccess;
Expand All @@ -12,7 +12,6 @@
import org.junit.jupiter.api.Test;

import seedu.address.logic.Messages;
import seedu.address.logic.commands.localcourse.LocalCourseAddCommand;
import seedu.address.model.SeplendidModel;
import seedu.address.model.SeplendidModelManager;
import seedu.address.model.UserPrefs;
Expand Down
Loading

0 comments on commit 2cf7565

Please sign in to comment.