Skip to content

Commit

Permalink
🎨 代码格式化
Browse files Browse the repository at this point in the history
  • Loading branch information
lingting committed Dec 14, 2023
1 parent 3b6d043 commit bada05d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public List<DemoData> ignoreEmptyRow(@RequestExcel(ignoreEmptyRow = true) List<D
return list;
}

@PostMapping(value= "/ignore-empty-row-disabled")
@PostMapping(value = "/ignore-empty-row-disabled")
public List<DemoData> notIgnoreEmptyRow(@RequestExcel(ignoreEmptyRow = false) List<DemoData> list) {
return list;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@

/**
* Excel 导入测试类
*
* @author Hccake
*/
@Slf4j
Expand Down Expand Up @@ -104,15 +105,15 @@ void ignoreEmptyRowTest() throws Exception {
ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
MockMultipartFile multipartFile = new MockMultipartFile("file", bis);
MvcResult mvcResult = mockMvc
.perform(MockMvcRequestBuilders.multipart("/import/ignore-empty-row-disabled")
.file(multipartFile)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andReturn();
.perform(MockMvcRequestBuilders.multipart("/import/ignore-empty-row-disabled")
.file(multipartFile)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andReturn();

String contentAsString = mvcResult.getResponse().getContentAsString();
List<DemoData> demoDataList = objectMapper.readValue(contentAsString,
new TypeReference<List<DemoData>>() {});
List<DemoData> demoDataList = objectMapper.readValue(contentAsString, new TypeReference<List<DemoData>>() {
});

Assertions.assertEquals(3, demoDataList.size());
Assertions.assertEquals("username0", demoDataList.get(0).getUsername());
Expand All @@ -121,13 +122,15 @@ void ignoreEmptyRowTest() throws Exception {
Assertions.assertNull(demoDataList.get(1).getPassword());

// 忽略空行
mvcResult = mockMvc.perform(
MockMvcRequestBuilders.multipart("/import/ignore-empty-row-enabled").file(multipartFile)
.accept(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
.andReturn();
mvcResult = mockMvc
.perform(MockMvcRequestBuilders.multipart("/import/ignore-empty-row-enabled")
.file(multipartFile)
.accept(MediaType.APPLICATION_JSON))
.andExpect(status().isOk())
.andReturn();
contentAsString = mvcResult.getResponse().getContentAsString();
demoDataList = objectMapper.readValue(contentAsString,
new TypeReference<List<DemoData>>() {});
demoDataList = objectMapper.readValue(contentAsString, new TypeReference<List<DemoData>>() {
});

Assertions.assertEquals(2, demoDataList.size());
Assertions.assertEquals("username0", demoDataList.get(0).getUsername());
Expand Down

0 comments on commit bada05d

Please sign in to comment.