@Test public void testFindServicePathFromParameterValues_noPathFound() { final ParameterValueBuilder parameterValueBuilder = new ParameterValueBuilder(); parameterValueBuilder.setName(new ParameterName(SFC_CHAIN_NAME)) .setStringValue(SFC_CHAIN_NAME); final List<ParameterValue> parameterValues = Collections.singletonList(parameterValueBuilder.build()); final ServiceFunctionPathsBuilder serviceFunctionPathsBuilder = new ServiceFunctionPathsBuilder(); final ServiceFunctionPaths serviceFunctionPaths = serviceFunctionPathsBuilder.build(); stub(method(SfcProviderServicePathAPI.class, "readAllServiceFunctionPaths")).toReturn(serviceFunctionPaths); final ServiceFunctionPath result = ServiceChainingUtil.findServicePathFromParameterValues(parameterValues); assertNull(result); }
@Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } private  ServiceChainingUtil(); }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } private  ServiceChainingUtil(); static boolean resolveRemoteSfcComponents(final RenderedServicePath renderedServicePath,
                                                      final PolicyConfigurationContext context); static RenderedServicePath resolveReversedRenderedServicePath(final ServiceFunctionPath sfp, final TenantId tenantId,
                                                                          final DataBroker dataBroker, final Sgt sourceSgt,
                                                                          final Sgt destinationSgt, final PolicyConfigurationContext context); @VisibleForTesting static void setTimeout(long value); }
ServiceChainingUtil { @Nullable static ServiceFunctionPath findServicePathFromParameterValues(final List<ParameterValue> params) { if (params == null || params.isEmpty()) { LOG.error("Cannot found service path, parameter value is null"); return null; } final Map<String, Object> paramsMap = new HashMap<>(); for (ParameterValue value : params) { if (value.getName() == null) continue; if (value.getIntValue() != null) { paramsMap.put(value.getName().getValue(), value.getIntValue()); } else if (value.getStringValue() != null) { paramsMap.put(value.getName().getValue(), value.getStringValue()); } } String chainName = null; for (String name : paramsMap.keySet()) { if (name.equals(ChainActionDefinition.SFC_CHAIN_NAME)) { chainName = (String) paramsMap.get(name); } } if (chainName == null) { LOG.error("Cannot found service path, chain name is null"); return null; } final ServiceFunctionPath serviceFunctionPath = findServiceFunctionPathFromServiceChainName(new SfcName(chainName)); if (serviceFunctionPath == null) { LOG.error("Service function path not found for name {}", chainName); return null; } return serviceFunctionPath; } private  ServiceChainingUtil(); static boolean resolveRemoteSfcComponents(final RenderedServicePath renderedServicePath,
                                                      final PolicyConfigurationContext context); static RenderedServicePath resolveReversedRenderedServicePath(final ServiceFunctionPath sfp, final TenantId tenantId,
                                                                          final DataBroker dataBroker, final Sgt sourceSgt,
                                                                          final Sgt destinationSgt, final PolicyConfigurationContext context); @VisibleForTesting static void setTimeout(long value);  }