SfcProviderServiceFunctionGroupAPI { public static List<String> getSfgNameList(ServiceFunctionChain serviceFunctionChain) { List<String> ret = new ArrayList<>(); List<SfcServiceFunction> sfcServiceFunction = serviceFunctionChain.getSfcServiceFunction(); LOG.debug("searching groups for chain {} which has the elements {}", serviceFunctionChain.getName(), serviceFunctionChain.getSfcServiceFunction()); if (sfcServiceFunction != null) { for (SfcServiceFunction sf : sfcServiceFunction) { ServiceFunctionGroup sfg = SfcProviderServiceFunctionGroupAPI.getServiceFunctionGroupByType(sf.getType()); LOG.debug("look for service function group of type {} and found {}", sf.getType(), sfg); if (sfg != null) { ret.add(sfg.getName()); } else { return null; } } } return ret; }  static List<String> getSfgNameList(ServiceFunctionChain serviceFunctionChain); static ServiceFunctionGroup readServiceFunctionGroup(String serviceFunctionGroupName); static boolean putServiceFunctionGroup(ServiceFunctionGroup sfg);  }
@Test public void testGetSfgNameList() { ServiceFunctionGroupsBuilder serviceFunctionGroupsBuilder = new ServiceFunctionGroupsBuilder(); serviceFunctionGroupsBuilder.setServiceFunctionGroup(createServiceFunctionGroupList()); InstanceIdentifier<ServiceFunctionGroups> sfgIID = InstanceIdentifier.builder(ServiceFunctionGroups.class).build(); boolean transactionSuccessful = SfcDataStoreAPI.writePutTransactionAPI(sfgIID, serviceFunctionGroupsBuilder.build(), LogicalDatastoreType.CONFIGURATION); assertTrue("Must be true", transactionSuccessful); ServiceFunctionChainBuilder serviceFunctionChainBuilder = new ServiceFunctionChainBuilder(); serviceFunctionChainBuilder.setSfcServiceFunction(createSfcServiceFunctionList()); List<String> sfgNameList = SfcProviderServiceFunctionGroupAPI.getSfgNameList(serviceFunctionChainBuilder.build()); assertNotNull("Must be not null", sfgNameList); assertEquals("Must be equal", sfgNameList.toString(), "[" + SFG_NAME + 1 + ", " + SFG_NAME + 2 + "]"); }