From 4294ba157a5ec822ed15f552da70c07ab9dbcd28 Mon Sep 17 00:00:00 2001 From: Michael Russo Date: Mon, 25 Apr 2022 21:56:25 -0500 Subject: [PATCH] Tweak tests --- .../com/example/noteapi/api/NoteControllerTest.java | 10 +++++++--- .../service/NoteServiceImplIntegrationTest.java | 4 ++-- .../service/UserServiceImplIntegrationTest.java | 4 ++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/test/java/com/example/noteapi/api/NoteControllerTest.java b/src/test/java/com/example/noteapi/api/NoteControllerTest.java index 0da86a8..4e18ed0 100644 --- a/src/test/java/com/example/noteapi/api/NoteControllerTest.java +++ b/src/test/java/com/example/noteapi/api/NoteControllerTest.java @@ -186,21 +186,25 @@ void updateNote() throws Exception { void patchNote() throws Exception { Note note = note(); note.setTitle("2022 New York"); + note.setLabels(List.of()); + note.setContent(null); when(noteService.patch(eq("621a80c50f239c6d37c6313b"), any())).thenReturn(note); String requestJson = """ { - "title": "2022 New York" + "title": "2022 New York", + "labels": [], + "content": null }"""; String responseJson = """ { "id": "621a80c50f239c6d37c6313b", "userId": "621e25d546ca105d43d1d073", "title": "2022 New York", - "content": "Content", + "content": null, "createdDate": "2022-02-18T18:00:00Z", "updatedDate": "2022-02-18T18:00:00Z", - "labels": ["favorites", "vacations"] + "labels": [] }"""; mockMvc.perform(patch("/notes/621a80c50f239c6d37c6313b") .contentType(MediaType.APPLICATION_JSON) diff --git a/src/test/java/com/example/noteapi/service/NoteServiceImplIntegrationTest.java b/src/test/java/com/example/noteapi/service/NoteServiceImplIntegrationTest.java index 75adc84..2805614 100644 --- a/src/test/java/com/example/noteapi/service/NoteServiceImplIntegrationTest.java +++ b/src/test/java/com/example/noteapi/service/NoteServiceImplIntegrationTest.java @@ -135,11 +135,11 @@ void update() { @Order(5) void patch() { ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("title", "2022 New York"); + objectNode.put("title", "patch-test"); Note note = service.patch(createdNoteId, objectNode); - assertThat(note.getTitle()).isEqualTo("2022 New York"); + assertThat(note.getTitle()).isEqualTo("patch-test"); } @Test diff --git a/src/test/java/com/example/noteapi/service/UserServiceImplIntegrationTest.java b/src/test/java/com/example/noteapi/service/UserServiceImplIntegrationTest.java index abda6a2..bdfc530 100644 --- a/src/test/java/com/example/noteapi/service/UserServiceImplIntegrationTest.java +++ b/src/test/java/com/example/noteapi/service/UserServiceImplIntegrationTest.java @@ -98,11 +98,11 @@ void update() { @Order(3) void patch() { ObjectNode objectNode = objectMapper.createObjectNode(); - objectNode.put("name", "vsullivan"); + objectNode.put("name", "patch-test"); User user = service.patch(createdUserId, objectNode); - assertThat(user.getName()).isEqualTo("vsullivan"); + assertThat(user.getName()).isEqualTo("patch-test"); } @Test