SfcProviderServicePathAPI { public static boolean addRenderedPathToServicePathState(SfpName servicePathName, RspName renderedPathName) { printTraceStart(LOG); InstanceIdentifier<SfpRenderedServicePath> rspIID; boolean ret = false; SfpRenderedServicePathBuilder sfpRenderedServicePathBuilder = new SfpRenderedServicePathBuilder(); SfpRenderedServicePathKey sfpRenderedServicePathKey = new SfpRenderedServicePathKey(renderedPathName); sfpRenderedServicePathBuilder.setKey(sfpRenderedServicePathKey).setName(renderedPathName); ServiceFunctionPathStateKey serviceFunctionPathStateKey = new ServiceFunctionPathStateKey(servicePathName); rspIID = InstanceIdentifier.builder(ServiceFunctionPathsState.class) .child(ServiceFunctionPathState.class, serviceFunctionPathStateKey) .child(SfpRenderedServicePath.class, sfpRenderedServicePathKey) .build(); if (SfcDataStoreAPI.writeMergeTransactionAPI(rspIID, sfpRenderedServicePathBuilder.build(), LogicalDatastoreType.OPERATIONAL)) { ret = true; } else { LOG.error("{}: Failed to create Service Function Path {} state. Rendered Service Path: {}", Thread.currentThread().getStackTrace()[1], servicePathName, renderedPathName); } printTraceStop(LOG); return ret; }  static List<SfpRenderedServicePath> readServicePathState(SfpName servicePathName); static boolean addRenderedPathToServicePathState(SfpName servicePathName, RspName renderedPathName); static ServiceFunctionPath readServiceFunctionPath(SfpName serviceFunctionPathName); static ServiceFunctionPaths readAllServiceFunctionPaths(); static boolean putServiceFunctionPath(ServiceFunctionPath sfp);  }
@Test public void testAddRenderedPathToServicePathState() { SfpName sfpKey = new SfpName("sfpKey"); RspName rspKey = new RspName("rspKey"); ServiceFunctionPathStateBuilder serviceFunctionPathStateBuilder = new ServiceFunctionPathStateBuilder(); serviceFunctionPathStateBuilder.setName(sfpKey).setKey(new ServiceFunctionPathStateKey(sfpKey)); boolean transactionSuccessful = SfcProviderServicePathAPI .addRenderedPathToServicePathState(serviceFunctionPathStateBuilder.build().getName(), rspKey); assertTrue("Must be true", transactionSuccessful); List<SfpRenderedServicePath> sfpList = SfcProviderServicePathAPI.readServicePathState(sfpKey); assertNotNull("Must be not null", sfpList); assertEquals("Must be equal", sfpList.get(0).getName(), rspKey); }