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