Browse Source

图表Controller测试

chenw 6 years ago
parent
commit
c587eb570a

+ 9 - 0
bi-core/src/main/java/com/usoftchina/bi/core/base/RepEntity.java

@@ -19,6 +19,15 @@ public class RepEntity<T> implements Serializable {
      */
     private T data;
 
+    public RepEntity() {
+    }
+
+    public RepEntity(int code, String msg, T data) {
+        this.code = code;
+        this.msg = msg;
+        this.data = data;
+    }
+
     public RepEntity(RepCode repCode) {
         this.code = repCode.getCode();
         this.msg = repCode.getMsg();

+ 16 - 16
bi-server/src/main/java/com/usoftchina/bi/server/dao/chart/ChartsConfigMapper.java

@@ -138,19 +138,19 @@ public interface ChartsConfigMapper {
     @Update("<script>" +
             "UPDATE bi_charts set "  +
             "CHART_NAME = #{chartName}" +
-            "<if com.usoftchina.bi.starter.test=\"chartType != null\"> , CHART_TYPE = #{chartType} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"createBy != null\"> , CREATE_BY = #{createBy} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"groupBy != null\"> , GROUP_BY = #{groupBy} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"chartConfig != null\"> , CHART_CONFIG = #{chartConfig} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"describes != null\"> , CHART_DESCRIBES = #{describes} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"filters != null\"> , BC_FILTERS = #{filters} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"accessAuthority != null\"> , ACCESS_AUTHORITY = #{accessAuthority} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"updateAuthority != null\"> , UPDATE_AUTHORITY = #{updateAuthority} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"style != null\"> , BC_CHART_STYLE = #{style} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"chartsGroup !=null\">, BC_CHARTS_GROUP = #{chartsGroup}</if>"+
-            "<if com.usoftchina.bi.starter.test=\"chartOption !=null\">, bc_charts_option = #{chartOption}</if>"+
-            "<if com.usoftchina.bi.starter.test=\"fetchConfig !=null\">, BC_FETCHCONFIG = #{fetchConfig}</if>"+
-            "<if com.usoftchina.bi.starter.test=\"updateDate != null\"> , UPDATE_DATE = to_date(#{updateDate},'YYYY-MM-DD hh24:mi:ss') </if>" +
+            "<if test=\"chartType != null\"> , CHART_TYPE = #{chartType} </if>" +
+            "<if test=\"createBy != null\"> , CREATE_BY = #{createBy} </if>" +
+            "<if test=\"groupBy != null\"> , GROUP_BY = #{groupBy} </if>" +
+            "<if test=\"chartConfig != null\"> , CHART_CONFIG = #{chartConfig} </if>" +
+            "<if test=\"describes != null\"> , CHART_DESCRIBES = #{describes} </if>" +
+            "<if test=\"filters != null\"> , BC_FILTERS = #{filters} </if>" +
+            "<if test=\"accessAuthority != null\"> , ACCESS_AUTHORITY = #{accessAuthority} </if>" +
+            "<if test=\"updateAuthority != null\"> , UPDATE_AUTHORITY = #{updateAuthority} </if>" +
+            "<if test=\"style != null\"> , BC_CHART_STYLE = #{style} </if>" +
+            "<if test=\"chartsGroup !=null\">, BC_CHARTS_GROUP = #{chartsGroup}</if>"+
+            "<if test=\"chartOption !=null\">, bc_charts_option = #{chartOption}</if>"+
+            "<if test=\"fetchConfig !=null\">, BC_FETCHCONFIG = #{fetchConfig}</if>"+
+            "<if test=\"updateDate != null\"> , UPDATE_DATE = to_date(#{updateDate},'YYYY-MM-DD hh24:mi:ss') </if>" +
             "where id = #{chartId}" +
             "</script>")
     void updateChartConfig(ChartConfig chartConfig);
@@ -181,9 +181,9 @@ public interface ChartsConfigMapper {
     @Update("<script>"+
             "UPDATE bi_charts_group set "+
             "bc_group_name = #{groupName}" +
-            "<if com.usoftchina.bi.starter.test=\"groupIndex != null\"> , bc_index = #{groupIndex} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"fatherId != null\"> , bc_father_id = #{fatherId} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"createBy != null\"> , create_by = #{createBy} </if>" +
+            "<if test=\"groupIndex != null\"> , bc_index = #{groupIndex} </if>" +
+            "<if test=\"fatherId != null\"> , bc_father_id = #{fatherId} </if>" +
+            "<if test=\"createBy != null\"> , create_by = #{createBy} </if>" +
             ",updata_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') "+
             " where bc_id = #{id}" +
             "</script>")

+ 5 - 5
bi-server/src/main/java/com/usoftchina/bi/server/dao/dashboard/DashboardsMapper.java

@@ -29,11 +29,11 @@ public interface DashboardsMapper {
     @Update("<script>" +
             "UPDATE BI_DASHBOARDS set "  +
             "BD_NAME = #{bdName}" +
-            "<if com.usoftchina.bi.starter.test=\"bdNote != null\"> , BD_NOTE = #{bdNote} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"bdConfiguration != null\"> , CONFIGURATION = #{bdConfiguration} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"thumbnail != null\"> , BD_THUMBNAIL = #{thumbnail} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"relationColumns != null\">, relation_columns = #{relationColumns} </if>"+
-            "<if com.usoftchina.bi.starter.test=\"filters != null\">, filters = #{filters} </if>"+
+            "<if test=\"bdNote != null\"> , BD_NOTE = #{bdNote} </if>" +
+            "<if test=\"bdConfiguration != null\"> , CONFIGURATION = #{bdConfiguration} </if>" +
+            "<if test=\"thumbnail != null\"> , BD_THUMBNAIL = #{thumbnail} </if>" +
+            "<if test=\"relationColumns != null\">, relation_columns = #{relationColumns} </if>"+
+            "<if test=\"filters != null\">, filters = #{filters} </if>"+
             " ,UPDATE_DATE = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') " +
             "where id = #{id}" +
             "</script>")

+ 20 - 20
bi-server/src/main/java/com/usoftchina/bi/server/dao/dataSource/DataConnectorMapper.java

@@ -72,17 +72,17 @@ public interface DataConnectorMapper {
     @Update("<script>" +
             "UPDATE bi_data_connectors set "  +
             "data_name = #{dataName}" +
-            "<if com.usoftchina.bi.starter.test=\"dataTag != null\"> , data_tag = #{dataTag} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"loadObject != null\"> , LOAD_OBJECT = #{loadObject} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"columnConfig != null\"> , columns_config = #{columnConfig} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"dbConfig != null\"> , DB_CONFIG = #{dbConfig} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"usedNumber != null\"> , used_number = #{usedNumber} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"createBy != null\"> , create_by = #{createBy} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"type != null\"> , con_TYPE = #{type} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"note != null\"> , DATA_NOTE = #{note} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"tableName != null\"> , table_name = #{tableName} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"connectorGroup != null\"> , BD_GROUP = #{connectorGroup} </if>"+
-            "<if com.usoftchina.bi.starter.test=\"updateDate != null\"> , UPDATE_DATE = to_date(#{updateDate},'YYYY-MM-DD hh24:mi:ss') </if>" +
+            "<if test=\"dataTag != null\"> , data_tag = #{dataTag} </if>" +
+            "<if test=\"loadObject != null\"> , LOAD_OBJECT = #{loadObject} </if>" +
+            "<if test=\"columnConfig != null\"> , columns_config = #{columnConfig} </if>" +
+            "<if test=\"dbConfig != null\"> , DB_CONFIG = #{dbConfig} </if>" +
+            "<if test=\"usedNumber != null\"> , used_number = #{usedNumber} </if>" +
+            "<if test=\"createBy != null\"> , create_by = #{createBy} </if>" +
+            "<if test=\"type != null\"> , con_TYPE = #{type} </if>" +
+            "<if test=\"note != null\"> , DATA_NOTE = #{note} </if>" +
+            "<if test=\"tableName != null\"> , table_name = #{tableName} </if>" +
+            "<if test=\"connectorGroup != null\"> , BD_GROUP = #{connectorGroup} </if>"+
+            "<if test=\"updateDate != null\"> , UPDATE_DATE = to_date(#{updateDate},'YYYY-MM-DD hh24:mi:ss') </if>" +
             "where id = #{dataId}" +
             "</script>")
     void updateData(DataConnector dataConnector);
@@ -140,13 +140,13 @@ public interface DataConnectorMapper {
     @Update("<script>"+
             "UPDATE BI_DATABASES set "  +
             "BASES_NAME = #{name}" +
-            "<if com.usoftchina.bi.starter.test=\"addrass != null\"> , ADDRASS = #{addrass} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"port != null\"> , PORT = #{port} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"databaseType != null\"> , DATABASE_TYPE = #{databaseType} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"dataName != null\"> , DATA_NAME = #{dataName} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"userName != null\"> , USER_NAME = #{userName} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"passWord != null\"> , PASS_WORD = #{passWord} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"note != null\"> , NOTE = #{note} </if>" +
+            "<if test=\"addrass != null\"> , ADDRASS = #{addrass} </if>" +
+            "<if test=\"port != null\"> , PORT = #{port} </if>" +
+            "<if test=\"databaseType != null\"> , DATABASE_TYPE = #{databaseType} </if>" +
+            "<if test=\"dataName != null\"> , DATA_NAME = #{dataName} </if>" +
+            "<if test=\"userName != null\"> , USER_NAME = #{userName} </if>" +
+            "<if test=\"passWord != null\"> , PASS_WORD = #{passWord} </if>" +
+            "<if test=\"note != null\"> , NOTE = #{note} </if>" +
             "where id = #{id}" +
             "</script>")
     void updatabases(Databases databases);
@@ -191,8 +191,8 @@ public interface DataConnectorMapper {
     @Update("<script>"+
             "UPDATE bi_base_group_by set "+
             "bb_group_name = #{groupName}" +
-            "<if com.usoftchina.bi.starter.test=\"groupIndex != null\"> , bb_index = #{groupIndex} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"fatherId != null\"> , bb_father_id = #{fatherId} </if>" +
+            "<if test=\"groupIndex != null\"> , bb_index = #{groupIndex} </if>" +
+            "<if test=\"fatherId != null\"> , bb_father_id = #{fatherId} </if>" +
             ",updata_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') "+
             " where bb_id = #{id}" +
             "</script>")

+ 5 - 5
bi-server/src/main/java/com/usoftchina/bi/server/dao/strategy/StrategysBdMapper.java

@@ -26,11 +26,11 @@ public interface StrategysBdMapper {
     @Update("<script>"+
             "UPDATE bi_db_strategys set "+
             "BS_DB_ID = #{tarId}" +
-            "<if com.usoftchina.bi.starter.test=\"rule != null\"> , BS_RULE = #{rule} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"ruleStr != null\">, RULE_STR = #{ruleStr} </if> "+
-            "<if com.usoftchina.bi.starter.test=\"name != null\"> , BS_NAME = #{name} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"createBy != null\"> , createBy = #{createBy} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"isOpen != null\"> , IS_OPEN = #{isOpen} </if>" +
+            "<if test=\"rule != null\"> , BS_RULE = #{rule} </if>" +
+            "<if test=\"ruleStr != null\">, RULE_STR = #{ruleStr} </if> "+
+            "<if test=\"name != null\"> , BS_NAME = #{name} </if>" +
+            "<if test=\"createBy != null\"> , createBy = #{createBy} </if>" +
+            "<if test=\"isOpen != null\"> , IS_OPEN = #{isOpen} </if>" +
             ",updata_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') "+
             " where bs_id = #{id}" +
             "</script>")

+ 5 - 5
bi-server/src/main/java/com/usoftchina/bi/server/dao/strategy/StrategysChartMapper.java

@@ -26,11 +26,11 @@ public interface StrategysChartMapper {
     @Update("<script>"+
             "UPDATE bi_chart_strategys set "+
             "bc_chart_id = #{tarId}" +
-            "<if com.usoftchina.bi.starter.test=\"rule != null\"> , BC_RULE = #{rule} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"ruleStr != null\"> , rule_str = #{ruleStr} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"name != null\"> , BC_NAME = #{name} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"createBy != null\"> , createBy = #{createBy} </if>" +
-            "<if com.usoftchina.bi.starter.test=\"isOpen != null\"> , IS_OPEN = #{isOpen} </if>" +
+            "<if test=\"rule != null\"> , BC_RULE = #{rule} </if>" +
+            "<if test=\"ruleStr != null\"> , rule_str = #{ruleStr} </if>" +
+            "<if test=\"name != null\"> , BC_NAME = #{name} </if>" +
+            "<if test=\"createBy != null\"> , createBy = #{createBy} </if>" +
+            "<if test=\"isOpen != null\"> , IS_OPEN = #{isOpen} </if>" +
             ",updata_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') "+
             " where bc_id = #{id}" +
             "</script>")

+ 6 - 6
bi-server/src/main/java/com/usoftchina/bi/server/dao/user/UserMapper.java

@@ -25,11 +25,11 @@ public interface UserMapper {
     @Update("<script>" +
             "UPDATE bi_users set " +
             "USER_NAME = #{userName}" +
-            "<if com.usoftchina.bi.starter.test=\"passWord != null\"> , PASS_WORD = #{passWord} </if>" +
-            " <if com.usoftchina.bi.starter.test=\"name != null\"> , bu_name = #{name} </if>" +
-            " <if com.usoftchina.bi.starter.test=\"post != null\"> , BU_POST = #{post} </if>" +
-            " <if com.usoftchina.bi.starter.test=\"department != null\"> , BU_DEPARTMENT = #{department} </if>" +
-            " <if com.usoftchina.bi.starter.test=\"role != null\"> , BU_ROLE = #{role} </if>" +
+            "<if test=\"passWord != null\"> , PASS_WORD = #{passWord} </if>" +
+            " <if test=\"name != null\"> , bu_name = #{name} </if>" +
+            " <if test=\"post != null\"> , BU_POST = #{post} </if>" +
+            " <if test=\"department != null\"> , BU_DEPARTMENT = #{department} </if>" +
+            " <if test=\"role != null\"> , BU_ROLE = #{role} </if>" +
             " ,updata_date = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss')" +
             "  where bu_id = #{id}" +
             " </script>")
@@ -109,7 +109,7 @@ public interface UserMapper {
     @Update("<script>" +
             "UPDATE bi_user_groups set "  +
             "bg_name = #{userGroupName}" +
-            "<if com.usoftchina.bi.starter.test=\"userGroupNote != null\"> , bg_note = #{userGroupNote} </if>" +
+            "<if test=\"userGroupNote != null\"> , bg_note = #{userGroupNote} </if>" +
             ",UPDATA_DATE = to_date(to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),'YYYY-MM-DD hh24:mi:ss') " +
             "where bg_id = #{id}" +
             "</script>")

+ 1 - 1
bi-server/src/test/java/com/usoftchina/bi/server/test/TestDataSource.java → bi-server/src/test/java/com/usoftchina/bi/test/server/TestDataSource.java

@@ -1,4 +1,4 @@
-package com.usoftchina.bi.server.test;
+package com.usoftchina.bi.test.server;
 
 import com.usoftchina.bi.core.jdbc.DynamicDataSource;
 import com.usoftchina.bi.core.jdbc.DynamicDataSourceContextHolder;

+ 118 - 0
bi-server/src/test/java/com/usoftchina/bi/test/server/controller/ChartsConfigControllerTest.java

@@ -0,0 +1,118 @@
+package com.usoftchina.bi.test.server.controller;
+
+import com.github.pagehelper.PageInfo;
+import com.usoftchina.bi.core.base.RepEntity;
+import com.usoftchina.bi.core.base.TestPage;
+import com.usoftchina.bi.core.utils.JsonUtils;
+import com.usoftchina.bi.server.Application;
+import com.usoftchina.bi.server.model.po.ChartConfig;
+import com.usoftchina.bi.server.model.po.TokenData;
+import com.usoftchina.bi.server.model.vo.configVo.ChartConfigInfo;
+import com.usoftchina.bi.server.model.vo.configVo.LoginInfo;
+import com.usoftchina.bi.server.service.user.UserService;
+import com.usoftchina.bi.starter.test.BaseControllerTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.springframework.test.context.web.WebAppConfiguration;
+import org.springframework.test.web.servlet.MvcResult;
+
+import java.util.List;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@SpringBootTest( classes = Application.class)
+@WebAppConfiguration
+public class ChartsConfigControllerTest extends BaseControllerTest {
+
+    @Autowired
+    private UserService userService;
+
+    private static String token = null;
+    private static final Logger logger = LoggerFactory.getLogger(ChartsConfigControllerTest.class);
+
+    @Before
+    public void init(){
+        if (token == null) {
+            LoginInfo loginInfo = new LoginInfo();
+            loginInfo.setUserName("U0818");
+            loginInfo.setPassWord("cw111111");
+            RepEntity<TokenData> repEntity = userService.login(loginInfo);
+            token = repEntity.getData().getToken();
+            logger.info("token={}", token);
+        }
+    }
+
+    @Test
+    public void testA_inputCharts() throws Exception {
+        ChartConfigInfo chartConfigInfo = new ChartConfigInfo();
+        mockMvc.perform(requestBody("/inputCharts", chartConfigInfo)
+                        .header("token", token))
+                .andReturn();
+    }
+
+    @Test
+    public void testB_updateCharts() throws Exception {
+    }
+
+    @Test
+    public void testC_changeChartOrder() throws Exception {
+    }
+
+    @Test
+    public void testD_updateConfigGroup() throws Exception {
+    }
+
+    @Test
+    public void testE_delChartsConfig() throws Exception {
+    }
+
+    @Test
+    public void testF_getListCharts() throws Exception {
+        TestPage page = new TestPage();
+        MvcResult result = mockMvc.perform(requestBody("/getListCharts", page)
+                        .header("token", token))
+                .andReturn();
+        RepEntity<PageInfo> repEntity = result(result, PageInfo.class);
+        logger.info("result={}", JsonUtils.toJsonString(repEntity.getData()));
+    }
+
+    @Test
+    public void testG_getChartsConfig() throws Exception {
+        MvcResult result = mockMvc.perform(requestBody("/getListCharts", 1)
+                .header("token", token))
+                .andReturn();
+        RepEntity<ChartConfig> repEntity = result(result, ChartConfig.class);
+        logger.info("result={}", JsonUtils.toJsonString(repEntity.getData()));
+    }
+
+    @Test
+    public void testH_setChartsGroup() throws Exception {
+    }
+
+    @Test
+    public void testI_updataChartsGroup() throws Exception {
+    }
+
+    @Test
+    public void testJ_updataListGroup() throws Exception {
+    }
+
+    @Test
+    public void testK_delChartsGroup() throws Exception {
+    }
+
+    @Test
+    public void testL_getChartsGroup() throws Exception {
+        MvcResult result = mockMvc.perform(post("/getListCharts")
+                .header("token", token))
+                .andReturn();
+        RepEntity<List> repEntity = result(result, List.class);
+        logger.info("result={}", JsonUtils.toJsonString(repEntity.getData()));
+    }
+
+}