|
|
@@ -1,9 +1,14 @@
|
|
|
package cn.iselab.mooctest.site.web.ctrl.fromDev;
|
|
|
|
|
|
import cn.iselab.mooctest.site.Application;
|
|
|
+import cn.iselab.mooctest.site.models.Weight;
|
|
|
import cn.iselab.mooctest.site.rpc.dev.DevService;
|
|
|
import cn.iselab.mooctest.site.rpc.dev.data.*;
|
|
|
+import cn.iselab.mooctest.site.service.fromDev.AnalysisService;
|
|
|
+import cn.iselab.mooctest.site.service.worker.WeightService;
|
|
|
import cn.iselab.mooctest.site.web.data.fromDev.StResponse;
|
|
|
+import net.sf.json.test.JSONAssert;
|
|
|
+import org.json.JSONArray;
|
|
|
import org.json.JSONObject;
|
|
|
import org.junit.Assert;
|
|
|
import org.junit.Before;
|
|
|
@@ -43,14 +48,23 @@ public class AnalysisControllerTest {
|
|
|
@InjectMocks
|
|
|
AnalysisController analysisController=new AnalysisController();
|
|
|
|
|
|
-
|
|
|
@Mock
|
|
|
DevService devService;
|
|
|
+ @Mock
|
|
|
+ WeightService weightService;
|
|
|
+ @Mock
|
|
|
+ AnalysisService analysisService;
|
|
|
+
|
|
|
+ private List<MutationDTO> mutationDTOS=new ArrayList<>();
|
|
|
+ private MutationDTO mutationDTO=new MutationDTO();
|
|
|
|
|
|
@Before
|
|
|
public void setupMockMvc() throws Exception {
|
|
|
initMocks(this);
|
|
|
mockMvc= MockMvcBuilders.standaloneSetup(analysisController).build();
|
|
|
+
|
|
|
+ mutationDTO.setTotal(100);
|
|
|
+ mutationDTOS.add(mutationDTO);
|
|
|
}
|
|
|
|
|
|
@Test
|
|
|
@@ -126,13 +140,16 @@ public class AnalysisControllerTest {
|
|
|
jsonObject.put("endTime","1");
|
|
|
jsonObject.put("workerID",list);
|
|
|
|
|
|
- when(devService.mutationAllAnalyze(anyLong(),anyLong(),anyList(),anyLong())).thenReturn(true);
|
|
|
+ Weight weight=new Weight();
|
|
|
+ weight.setMutation(1);
|
|
|
+ when(weightService.getWeightByTidAndCid(anyLong(),anyLong())).thenReturn(weight);
|
|
|
+ when(analysisService.mutationAllAnalyze(anyLong(),anyList(),anyLong())).thenReturn(mutationDTOS);
|
|
|
|
|
|
MvcResult result=mockMvc.perform(
|
|
|
post("/api/dev/mutation/all").contentType(MediaType.APPLICATION_JSON).content(jsonObject.toString())
|
|
|
).andDo(print()).andExpect(status().isOk()).andReturn();
|
|
|
|
|
|
- Assert.assertEquals(true,new JSONObject(result.getResponse().getContentAsString()).getBoolean("data"));
|
|
|
+ Assert.assertEquals(mutationDTO.getTotal(),new JSONObject(result.getResponse().getContentAsString()).getJSONArray("data").getJSONObject(0).getLong("total"));
|
|
|
}
|
|
|
|
|
|
@Test
|