fix(接口测试): 修复interface重复bug

This commit is contained in:
q4speed 2020-07-22 12:22:29 +08:00
parent be21158f60
commit 7365355d8e
1 changed files with 17 additions and 12 deletions

View File

@ -263,7 +263,7 @@ public class APITestService {
ApiImportParser apiImportParser = ApiImportParserFactory.getApiImportParser(request.getPlatform()); ApiImportParser apiImportParser = ApiImportParserFactory.getApiImportParser(request.getPlatform());
ApiImport apiImport = null; ApiImport apiImport = null;
try { try {
apiImport = apiImportParser.parse(file.getInputStream(), request); apiImport = Objects.requireNonNull(apiImportParser).parse(file.getInputStream(), request);
} catch (Exception e) { } catch (Exception e) {
LogUtil.error(e.getMessage(), e); LogUtil.error(e.getMessage(), e);
MSException.throwException(Translator.get("parse_data_error")); MSException.throwException(Translator.get("parse_data_error"));
@ -290,21 +290,26 @@ public class APITestService {
} }
public List<DubboProvider> getProviders(RegistryCenter registry) { public List<DubboProvider> getProviders(RegistryCenter registry) {
ProviderService providerService = ProviderService.get("provider"); ProviderService providerService = ProviderService.get(registry.getAddress());
List<String> providers = providerService.getProviders(registry.getProtocol(), registry.getAddress(), registry.getGroup()); List<String> providers = providerService.getProviders(registry.getProtocol(), registry.getAddress(), registry.getGroup());
List<DubboProvider> providerList = new ArrayList<>(); List<DubboProvider> list = new ArrayList<>();
providers.forEach(p -> { providers.forEach(p -> {
Map<String, URL> services = providerService.findByService(p);
services.forEach((k, v) -> {
DubboProvider provider = new DubboProvider(); DubboProvider provider = new DubboProvider();
provider.setVersion(v.getParameter("version")); String[] info = p.split(":");
provider.setService(v.getServiceKey()); if (info.length > 1) {
provider.setServiceInterface(v.getServiceInterface()); provider.setVersion(info[1]);
String[] methods = v.getParameter("methods").split(","); }
provider.setService(info[0]);
provider.setServiceInterface(p);
Map<String, URL> services = providerService.findByService(p);
if (services != null && !services.isEmpty()) {
String[] methods = services.values().stream().findFirst().get().getParameter("methods").split(",");
provider.setMethods(Arrays.asList(methods)); provider.setMethods(Arrays.asList(methods));
providerList.add(provider); } else {
provider.setMethods(new ArrayList<>());
}
list.add(provider);
}); });
}); return list;
return providerList;
} }
} }