mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-14 20:58:35 +00:00
fix: Video.toString() outputs an illegal json string (#3032)
refactor: json string concat add an extra line at EOF
This commit is contained in:
@@ -63,7 +63,7 @@ class VideoResourceTest {
|
||||
var actualDetails = resource.getDetails(1);
|
||||
|
||||
var expectedDetails = "{\"id\": 1,\"title\": \"Avatar\",\"length\": 178,\"description\": "
|
||||
+ "\"epic science fiction film\",\"director\": \"James Cameron\",\"language\": \"English\",}";
|
||||
+ "\"epic science fiction film\",\"director\": \"James Cameron\",\"language\": \"English\"}";
|
||||
Assertions.assertEquals(expectedDetails, actualDetails);
|
||||
}
|
||||
|
||||
@@ -78,4 +78,17 @@ class VideoResourceTest {
|
||||
|
||||
Assertions.assertEquals(expectedDetails, actualFieldsDetails);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void shouldAllSpecifiedFieldsInformationOfVideo() throws Exception {
|
||||
var fields = new String[]{"id", "title", "length", "description", "director", "language"};
|
||||
|
||||
var expectedDetails = "{\"id\": 1,\"title\": \"Avatar\",\"length\": 178,\"description\": "
|
||||
+ "\"epic science fiction film\",\"director\": \"James Cameron\",\"language\": \"English\"}";
|
||||
Mockito.when(fieldJsonMapper.toJson(any(Video.class), eq(fields))).thenReturn(expectedDetails);
|
||||
|
||||
var actualFieldsDetails = resource.getDetails(1, fields);
|
||||
|
||||
Assertions.assertEquals(expectedDetails, actualFieldsDetails);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user