SfcProviderServiceTypeAPI { public static boolean deleteServiceFunctionTypeEntry(ServiceFunction serviceFunction) { printTraceStart(LOG); boolean ret = false; ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(serviceFunction.getType()); InstanceIdentifier<SftServiceFunctionName> sftentryIID; SfName sfName = new SfName(serviceFunction.getName().getValue()); SftServiceFunctionNameKey sftServiceFunctionNameKey = new SftServiceFunctionNameKey(sfName); sftentryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class) .child(ServiceFunctionType.class, serviceFunctionTypeKey) .child(SftServiceFunctionName.class, sftServiceFunctionNameKey) .build(); if (SfcDataStoreAPI.deleteTransactionAPI(sftentryIID, LogicalDatastoreType.CONFIGURATION)) { ret = true; } else { LOG.error("Failed to delete Service Function Type: {}, for Service Function: {}", serviceFunction.getType(), serviceFunction.getName()); } List<SftServiceFunctionName> sftServiceFunctionNameList = readServiceFunctionType(serviceFunction.getType()).getSftServiceFunctionName(); if (sftServiceFunctionNameList != null) { LOG.debug("List size for service type {} is: {}", serviceFunction.getType(), sftServiceFunctionNameList.size()); if (sftServiceFunctionNameList.size() == 0) { deleteServiceFunctionType(serviceFunction.getType()); } } printTraceStop(LOG); return ret; }  static boolean createServiceFunctionTypeEntry(ServiceFunction serviceFunction); static boolean putServiceFunctionType(ServiceFunctionType sft); static ServiceFunctionType readServiceFunctionType(SftTypeName serviceFunctionType); static boolean deleteServiceFunctionTypeEntry(ServiceFunction serviceFunction); static boolean deleteServiceFunctionType(SftTypeName sftType); static boolean deleteServiceFunctionType(ServiceFunctionType serviceFunctionType); static SftServiceFunctionName readServiceFunctionTypeEntry(ServiceFunction serviceFunction);  }
@Test public void testDeleteServiceFunctionTypeEntryExecutor() { SfName sfName = new SfName("SF1"); ServiceFunctionBuilder serviceFunctionBuilder = new ServiceFunctionBuilder(); serviceFunctionBuilder.setName(sfName).setKey(new ServiceFunctionKey(sfName)).setType(new SftTypeName("firewall")); ServiceFunction serviceFunction = serviceFunctionBuilder.build(); SftServiceFunctionNameKey sftServiceFunctionNameKey = new SftServiceFunctionNameKey(sfName); ServiceFunctionTypeKey serviceFunctionTypeKey = new ServiceFunctionTypeKey(new ServiceFunctionTypeKey(new SftTypeName("firewall"))); InstanceIdentifier<SftServiceFunctionName> sftentryIID = InstanceIdentifier.builder(ServiceFunctionTypes.class) .child(ServiceFunctionType.class, serviceFunctionTypeKey) .child(SftServiceFunctionName.class, sftServiceFunctionNameKey) .build(); SftServiceFunctionNameBuilder sftServiceFunctionNameBuilder = new SftServiceFunctionNameBuilder(); sftServiceFunctionNameBuilder.setName(sfName) .setKey(new SftServiceFunctionNameKey(sfName)); SftServiceFunctionName sftServiceFunctionName = sftServiceFunctionNameBuilder.build(); SfcDataStoreAPI.writePutTransactionAPI(sftentryIID, sftServiceFunctionName, LogicalDatastoreType.CONFIGURATION); assertTrue(SfcProviderServiceTypeAPI.deleteServiceFunctionTypeEntry(serviceFunction)); assertNull(SfcDataStoreAPI.readTransactionAPI(sftentryIID, LogicalDatastoreType.CONFIGURATION)); }