SfcProviderServiceChainAPI { public static ServiceFunctionChain readServiceFunctionChain(SfcName serviceFunctionChainName) { printTraceStart(LOG); ServiceFunctionChain sfc; InstanceIdentifier<ServiceFunctionChain> sfcIID; ServiceFunctionChainKey serviceFunctionChainKey = new ServiceFunctionChainKey(serviceFunctionChainName); sfcIID = InstanceIdentifier.builder(ServiceFunctionChains.class) .child(ServiceFunctionChain.class, serviceFunctionChainKey) .build(); sfc = SfcDataStoreAPI.readTransactionAPI(sfcIID, LogicalDatastoreType.CONFIGURATION); printTraceStop(LOG); return sfc; }  static ServiceFunctionChain readServiceFunctionChain(SfcName serviceFunctionChainName); static boolean putServiceFunctionChain(ServiceFunctionChain serviceFunctionChain);  }
@Test public void testCreateReadServiceFunctionChains() { List<SfcServiceFunction> sfcAllServiceFunctionList = new ArrayList<>(); for (ServiceFunction serviceFunction : sfList) { SfcServiceFunctionBuilder sfcServiceFunctionBuilder = new SfcServiceFunctionBuilder(); SfcServiceFunction sfcServiceFunction = sfcServiceFunctionBuilder.setName(serviceFunction.getName().getValue()) .setKey(new SfcServiceFunctionKey(serviceFunction.getName().getValue())) .setType(serviceFunction.getType()) .build(); sfcAllServiceFunctionList.add(sfcServiceFunction); } List<SfcName> sfcName = new ArrayList<>(); sfcName.add(new SfcName("unittest-sfc-1")); sfcName.add(new SfcName("unittest-sfc-2")); sfcName.add(new SfcName("unittest-sfc-3")); ServiceFunctionChain[] sfcArray = new ServiceFunctionChain[3]; List<ServiceFunctionChain> sfcList = new ArrayList<>(); int i = 0; for (SfcName name : sfcName) { List<SfcServiceFunction> sfcServiceFunctionList = new ArrayList<>(); int j = 0; for (SfcServiceFunction sf : sfcAllServiceFunctionList) { if (i != j) { sfcServiceFunctionList.add(sf); } j++; } ServiceFunctionChainBuilder sfcBuilder = new ServiceFunctionChainBuilder(); sfcArray[i] = sfcBuilder.setName(name) .setKey(new ServiceFunctionChainKey(name)) .setSfcServiceFunction(sfcServiceFunctionList) .setSymmetric(false) .build(); sfcList.add(sfcArray[i]); i++; } ServiceFunctionChainsBuilder sfcsBuilder = new ServiceFunctionChainsBuilder(); sfcsBuilder.setServiceFunctionChain(sfcList); InstanceIdentifier<ServiceFunctionChains> sfcsIID = InstanceIdentifier.builder(ServiceFunctionChains.class).build(); SfcDataStoreAPI.writePutTransactionAPI(sfcsIID, sfcsBuilder.build(), LogicalDatastoreType.CONFIGURATION); final int INDEX_TO_READ = 1; ServiceFunctionChain sfc2 = SfcProviderServiceChainAPI.readServiceFunctionChain(sfcName.get(INDEX_TO_READ)); assertNotNull("Must be not null", sfc2); assertEquals("Must be equal", sfc2, sfcArray[INDEX_TO_READ]); }