Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.openelisglobal.notes;
- import java.sql.Date;
- import java.util.List;
- import org.junit.After;
- import org.junit.Assert;
- import org.junit.Before;
- import org.junit.Test;
- import org.openelisglobal.BaseWebContextSensitiveTest;
- import org.openelisglobal.note.service.NoteService;
- import org.openelisglobal.note.valueholder.Note;
- import org.springframework.beans.factory.annotation.Autowired;
- public class NoteServiceTest extends BaseWebContextSensitiveTest {
- @Autowired
- private NoteService noteService;
- @Before
- public void init() throws Exception {
- }
- @After
- public void tearDown() {
- noteService.deleteAll(noteService.getAll());
- }
- @Test
- public void createNote_shouldCreateNewNote() throws Exception {
- String noteText = "This is a test note.";
- String noteSubject = "Test Subject";
- Note note = createNote(noteText, noteSubject);
- // Save note to the DB
- String noteId = noteService.insert(note);
- Note savedNote = noteService.get(noteId);
- Assert.assertNotNull(savedNote);
- Assert.assertEquals(noteText, savedNote.getText());
- Assert.assertEquals(noteSubject, savedNote.getSubject());
- }
- private Note createNote(String text, String subject) {
- Note note = new Note();
- note.setText(text);
- note.setSubject(subject);
- // Set other necessary fields, such as referenceId and referenceTableId
- note.setReferenceId("1");
- note.setReferenceTableId("1");
- return note;
- }
- @Test
- public void getNoteByRefIdAndRefTableAndSubject_shouldReturnNotes() throws Exception {
- String noteText = "Reference note.";
- String noteSubject = "Ref Subject";
- Note note = createNote(noteText, noteSubject);
- // Save note to the DB
- noteService.insert(note);
- List<Note> notes = noteService.getNoteByRefIAndRefTableAndSubject(
- note.getReferenceId(), note.getReferenceTableId(), note.getSubject());
- Assert.assertNotNull(notes);
- Assert.assertTrue(notes.size() > 0);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment