Skip to content

Commit 87c1fb9

Browse files
committed
Fixed broken test
1 parent eb6d86c commit 87c1fb9

1 file changed

Lines changed: 15 additions & 4 deletions

File tree

src/test/java/controller/NoteControllerTest.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,14 @@
2121
import org.springframework.test.context.junit4.SpringRunner;
2222

2323
import edu.tamu.app.controller.NoteController;
24+
import edu.tamu.app.enums.NoteType;
25+
import edu.tamu.app.enums.Status;
2426
import edu.tamu.app.model.AppUser;
2527
import edu.tamu.app.model.Note;
28+
import edu.tamu.app.model.Service;
2629
import edu.tamu.app.model.repo.AppUserRepo;
2730
import edu.tamu.app.model.repo.NoteRepo;
31+
import edu.tamu.app.model.repo.ServiceRepo;
2832
import edu.tamu.framework.model.ApiResponse;
2933
import edu.tamu.framework.model.Credentials;
3034

@@ -39,25 +43,30 @@ public class NoteControllerTest {
3943
protected static final String TEST_NOTE_TITLE2 = "Test Note Title 2";
4044
protected static final String TEST_NOTE_TITLE3 = "Test Note Title 3";
4145
protected static final String TEST_MODIFIED_NOTE_TITLE = "Modified Note Title";
46+
protected static final String TEST_SERVICE_NAME = "Test Service";
4247

48+
protected static Service TEST_SERVICE = new Service(TEST_SERVICE_NAME, Status.UP, false, true, true, "", "");
4349
protected static Note TEST_NOTE1 = new Note(TEST_NOTE_TITLE1, TEST_USER1);
4450
protected static Note TEST_NOTE2 = new Note(TEST_NOTE_TITLE2, TEST_USER1);
4551
protected static Note TEST_NOTE3 = new Note(TEST_NOTE_TITLE3, TEST_USER1);
46-
protected static Note TEST_MODIFIED_NOTE = new Note(TEST_MODIFIED_NOTE_TITLE, TEST_USER2);
52+
protected static Note TEST_MODIFIED_NOTE = new Note(TEST_MODIFIED_NOTE_TITLE, TEST_USER2, NoteType.ISSUE, "", TEST_SERVICE);
4753
protected static List<Note> mockNoteList = new ArrayList<Note>(Arrays.asList(new Note[] { TEST_NOTE1, TEST_NOTE2, TEST_NOTE3 }));
4854

4955
protected static AppUser user = new AppUser("123456789");
5056

5157
protected static ApiResponse response;
5258

53-
@Mock
54-
protected static AppUserRepo userRepo;
55-
5659
@Mock
5760
protected static Credentials credentials;
5861

62+
@Mock
63+
protected static AppUserRepo userRepo;
64+
5965
@Mock
6066
protected NoteRepo noteRepo;
67+
68+
@Mock
69+
protected ServiceRepo serviceRepo;
6170

6271
@Mock
6372
protected SimpMessagingTemplate simpMessagingTemplate;
@@ -74,6 +83,8 @@ public void setUp() {
7483
when(noteRepo.findOne(any(Long.class))).thenReturn(TEST_NOTE1);
7584
when(noteRepo.create(any(Note.class), any(Credentials.class))).thenReturn(TEST_NOTE1);
7685
when(noteRepo.save(any(Note.class))).thenReturn(TEST_MODIFIED_NOTE);
86+
when(serviceRepo.getOne(any(Long.class))).thenReturn(TEST_SERVICE);
87+
doNothing().when(noteRepo).delete(any(Note.class));
7788
doNothing().when(noteRepo).delete(any(Note.class));
7889
}
7990

0 commit comments

Comments
 (0)