Skip to content

Commit

Permalink
Tweak tests
Browse files Browse the repository at this point in the history
  • Loading branch information
merusso committed Apr 26, 2022
1 parent 5373e2e commit 4294ba1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/test/java/com/example/noteapi/api/NoteControllerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4294ba1

Please sign in to comment.