修改测试程序支持maat回调类配置下发到redis中

This commit is contained in:
renkaige
2018-10-11 15:29:04 +08:00
parent 7208e1d830
commit bbf10f2438
2 changed files with 91 additions and 77 deletions

View File

@@ -84,11 +84,13 @@ public class MaatTestController {
FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "开始删除业务类型" + serviceType + "下的maat配置" + configId + "\n", FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "开始删除业务类型" + serviceType + "下的maat配置" + configId + "\n",
Configurations.getStringProperty("maatTestLogPath", ""), true); Configurations.getStringProperty("maatTestLogPath", ""), true);
// Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>(); // Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer,
// Map<Integer, List<Long>>>();
// Iterator<Integer> serviceIterator = compileMap.keySet().iterator(); // Iterator<Integer> serviceIterator = compileMap.keySet().iterator();
// while (serviceIterator.hasNext()) { // while (serviceIterator.hasNext()) {
// Integer service = Integer.valueOf(serviceIterator.next().toString()); // Integer service = Integer.valueOf(serviceIterator.next().toString());
// List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service); // List<Integer> dbIndexList =
// ServiceAndRDBIndexReal.getRedisDBByService(service);
// if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) { // if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
// for (Integer dbIndex : dbIndexList) { // for (Integer dbIndex : dbIndexList) {
// if (restMap.containsKey(dbIndex)) { // if (restMap.containsKey(dbIndex)) {
@@ -100,7 +102,8 @@ public class MaatTestController {
// } // }
// } // }
// } else { // } else {
// FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "error:获取业务类型" + service + "对应的redisDb失败\n", // FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "error:获取业务类型" +
// service + "对应的redisDb失败\n",
// Configurations.getStringProperty("maatTestLogPath", ""), true); // Configurations.getStringProperty("maatTestLogPath", ""), true);
// return "error"; // return "error";
// } // }
@@ -522,6 +525,7 @@ public class MaatTestController {
/** /**
* 组装json串,然后下发配置,在验证配置是否正确,然后删除配置 * 组装json串,然后下发配置,在验证配置是否正确,然后删除配置
*
* @param service * @param service
* @param saveCount * @param saveCount
* @param map * @param map
@@ -536,20 +540,25 @@ public class MaatTestController {
jsonString.append("["); jsonString.append("[");
for (int i = 0; i < saveCount; i++) { for (int i = 0; i < saveCount; i++) {
jsonString.append("{"); jsonString.append("{");
List<String> srcList = new ArrayList<String>();
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) { for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
String fieldType = commonSourceFieldCfg.getFieldType(); String fieldType = commonSourceFieldCfg.getFieldType();
String srcName = commonSourceFieldCfg.getSrcName(); String srcName = commonSourceFieldCfg.getSrcName();
String dstName = commonSourceFieldCfg.getDstName();
if (!srcList.contains(srcName)) {
jsonString.append("\""); jsonString.append("\"");
jsonString.append(srcName); jsonString.append(srcName);
jsonString.append("\":"); jsonString.append("\":");
if (fieldType.equals("String")) { if (fieldType.equals("String")) {
if (srcName.toLowerCase().equals("service")) { if (srcName.toLowerCase().equals("service")) {
jsonString.append("\"" + service + "\""); jsonString.append("\"" + service + "\"");
} else if (srcName.toLowerCase().equals("dstfile")) { // } else if (dstName.toLowerCase().contains("redisfile")) {
jsonString.append( // jsonString.append(
"\"http://10.0.6.249/group1/M00/00/02/CgAG-VtziqWAIzafAAITEbfJ8Zw992.jpg\""); // "\"http://192.168.10.205:9000/maat-redis/201810284141049-212b64ca-5b5d-4b13-873e-c57868b4b46b.jpg\"");
} else { } else {
jsonString.append("\"" + UUID.randomUUID() + "\""); // jsonString.append("\"" + UUID.randomUUID() + "\"");
jsonString.append(
"\"http://192.168.10.205:9000/maat-redis/201810284141049-212b64ca-5b5d-4b13-873e-c57868b4b46b.jpg\"");
} }
} else if (fieldType.equals("Number")) { } else if (fieldType.equals("Number")) {
if (srcName.toLowerCase().equals("addrtype")) { if (srcName.toLowerCase().equals("addrtype")) {
@@ -564,7 +573,9 @@ public class MaatTestController {
jsonString.append("1"); jsonString.append("1");
} else if (srcName.toLowerCase().equals("isvalid")) { } else if (srcName.toLowerCase().equals("isvalid")) {
jsonString.append("1"); jsonString.append("1");
} else if (srcName.toLowerCase().equals("cfgid")||srcName.toLowerCase().equals("keyringid")||srcName.toLowerCase().equals("fileid")) { } else if (srcName.toLowerCase().equals("cfgid")
|| srcName.toLowerCase().equals("keyringid")
|| srcName.toLowerCase().equals("fileid")) {
Long incrId = configRedisService.getIncrId("seq_compileid"); Long incrId = configRedisService.getIncrId("seq_compileid");
compileIdList.add(incrId); compileIdList.add(incrId);
jsonString.append(incrId); jsonString.append(incrId);
@@ -588,10 +599,13 @@ public class MaatTestController {
} }
jsonString.append(","); jsonString.append(",");
} }
srcList.add(srcName);
}
String str = jsonString.substring(0, jsonString.lastIndexOf(",")); String str = jsonString.substring(0, jsonString.lastIndexOf(","));
jsonString.setLength(0); jsonString.setLength(0);
jsonString.append(str); jsonString.append(str);
jsonString.append("},"); jsonString.append("},");
} }
String jsonStr = jsonString.substring(0, jsonString.lastIndexOf(",")); String jsonStr = jsonString.substring(0, jsonString.lastIndexOf(","));
jsonStr += "]"; jsonStr += "]";

View File

@@ -386,7 +386,7 @@ public class MaatTestServiceimpl {
maatTableName.substring(maatTableName.lastIndexOf("_") + 1)); maatTableName.substring(maatTableName.lastIndexOf("_") + 1));
dstStr = dstPath.replace("{fileName}", dstStr.substring(dstStr.lastIndexOf("/") + 1)); dstStr = dstPath.replace("{fileName}", dstStr.substring(dstStr.lastIndexOf("/") + 1));
} else if ("file_id".equals(commonSourceFieldCfg.getDstName())) { } else if ("file_id".equals(commonSourceFieldCfg.getDstName())) {
dstStr = dstStr.substring(dstStr.indexOf("group")); // dstStr = dstStr.substring(dstStr.indexOf("group"));
} }
} }
switch (commonSourceFieldCfg.getFieldType()) { switch (commonSourceFieldCfg.getFieldType()) {
@@ -562,7 +562,7 @@ public class MaatTestServiceimpl {
if (!isNum(attrName)) { if (!isNum(attrName)) {
String beanVal = map.get(attrName); String beanVal = map.get(attrName);
String redisVal = valArr[i]; String redisVal = valArr[i];
if (beanVal == null || redisVal == null || !beanVal.trim().equals(redisVal.trim())) { if (!attrName.contains("redisFile")&&(beanVal == null || redisVal == null || !beanVal.trim().equals(redisVal.trim()))) {
FileUtils.addStrToFile( FileUtils.addStrToFile(
"\t" + sdf.format(new Date()) + " error:" + redisDb + "号redis库中key=" + key + "的值第" + i "\t" + sdf.format(new Date()) + " error:" + redisDb + "号redis库中key=" + key + "的值第" + i
+ "" + attrName + "的值:" + redisVal + "与实际传的值不一样,实际值是:{}\n", + "" + attrName + "的值:" + redisVal + "与实际传的值不一样,实际值是:{}\n",