|
|
|
@ -27,9 +27,7 @@ import org.springframework.web.context.WebApplicationContext; |
|
|
|
|
|
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
|
import java.io.FileReader; |
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
import java.nio.charset.Charset; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Random; |
|
|
|
@ -87,14 +85,15 @@ class DemoApplicationTests { |
|
|
|
|
LOG.info(String.join(",", s)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void loadData() throws FileNotFoundException { |
|
|
|
|
// 初始化垃圾数据
|
|
|
|
|
@Test |
|
|
|
|
void loadData() throws FileNotFoundException { |
|
|
|
|
Gson gson = new Gson(); |
|
|
|
|
MyGarbage g = gson.fromJson(new InputStreamReader(new FileInputStream("src/main/resources/garbage.json"), StandardCharsets.UTF_8), MyGarbage.class); |
|
|
|
|
for (Garbage garbage : g.getList()) { |
|
|
|
|
garbageDao.save(garbage); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
void loadPriceData() { |
|
|
|
@ -165,4 +164,12 @@ class DemoApplicationTests { |
|
|
|
|
.param("password", "123456") |
|
|
|
|
).andDo(MockMvcResultHandlers.print()).andReturn(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//测试垃圾分类查询
|
|
|
|
|
@Test |
|
|
|
|
void queryGarbage() throws Exception { |
|
|
|
|
mockMvc.perform(MockMvcRequestBuilders.get("/garbage/sorting") |
|
|
|
|
.param("name", "安") |
|
|
|
|
).andDo(MockMvcResultHandlers.print()).andReturn(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|