@Test public void testPutOrRemoveClassifierDefinitionInOperDs_cdIsInConfDs_emptySupportedParams() throws Exception { WriteTransaction wTx = getDataBroker().newWriteOnlyTransaction(); wTx.put(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierDefinitionIid(EtherTypeClassifierDefinition.ID), EtherTypeClassifierDefinition.DEFINITION, true); wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(EtherTypeClassifierDefinition.ID), EtherTypeClassifierDefinition.DEFINITION, true); wTx.submit().get(); List<ParameterName> supportedParams = ImmutableList.of(); listener.putOrRemoveClassifierDefinitionInOperDs(EtherTypeClassifierDefinition.ID, supportedParams); Optional<ClassifierDefinition> potentialCd = getDataBroker().newReadOnlyTransaction() .read(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(EtherTypeClassifierDefinition.ID)) .get(); Assert.assertFalse(potentialCd.isPresent()); }
@VisibleForTesting void putOrRemoveClassifierDefinitionInOperDs(ClassifierDefinitionId cdId, List<ParameterName> supportedParams) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Optional<ClassifierDefinition> potentialCdFromConfDs = DataStoreHelper .readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierDefinitionIid(cdId), rwTx); if (!potentialCdFromConfDs.isPresent()) { LOG.error("Classifier-definition with ID {} does not exist in CONF datastore.", cdId); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); DataStoreHelper.submitToDs(rwTx); return; } ClassifierDefinition cd = createClassifierDefinitionWithUnionOfParams(potentialCdFromConfDs.get(), supportedParams); if (cd != null) { rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), cd); } else { DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); } DataStoreHelper.submitToDs(rwTx); }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void putOrRemoveClassifierDefinitionInOperDs(ClassifierDefinitionId cdId, List<ParameterName> supportedParams) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Optional<ClassifierDefinition> potentialCdFromConfDs = DataStoreHelper .readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierDefinitionIid(cdId), rwTx); if (!potentialCdFromConfDs.isPresent()) { LOG.error("Classifier-definition with ID {} does not exist in CONF datastore.", cdId); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); DataStoreHelper.submitToDs(rwTx); return; } ClassifierDefinition cd = createClassifierDefinitionWithUnionOfParams(potentialCdFromConfDs.get(), supportedParams); if (cd != null) { rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), cd); } else { DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); } DataStoreHelper.submitToDs(rwTx); } }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void putOrRemoveClassifierDefinitionInOperDs(ClassifierDefinitionId cdId, List<ParameterName> supportedParams) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Optional<ClassifierDefinition> potentialCdFromConfDs = DataStoreHelper .readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierDefinitionIid(cdId), rwTx); if (!potentialCdFromConfDs.isPresent()) { LOG.error("Classifier-definition with ID {} does not exist in CONF datastore.", cdId); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); DataStoreHelper.submitToDs(rwTx); return; } ClassifierDefinition cd = createClassifierDefinitionWithUnionOfParams(potentialCdFromConfDs.get(), supportedParams); if (cd != null) { rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), cd); } else { DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); } DataStoreHelper.submitToDs(rwTx); } SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry); }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void putOrRemoveClassifierDefinitionInOperDs(ClassifierDefinitionId cdId, List<ParameterName> supportedParams) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Optional<ClassifierDefinition> potentialCdFromConfDs = DataStoreHelper .readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierDefinitionIid(cdId), rwTx); if (!potentialCdFromConfDs.isPresent()) { LOG.error("Classifier-definition with ID {} does not exist in CONF datastore.", cdId); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); DataStoreHelper.submitToDs(rwTx); return; } ClassifierDefinition cd = createClassifierDefinitionWithUnionOfParams(potentialCdFromConfDs.get(), supportedParams); if (cd != null) { rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), cd); } else { DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); } DataStoreHelper.submitToDs(rwTx); } SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry);  }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void putOrRemoveClassifierDefinitionInOperDs(ClassifierDefinitionId cdId, List<ParameterName> supportedParams) { ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction(); Optional<ClassifierDefinition> potentialCdFromConfDs = DataStoreHelper .readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.classifierDefinitionIid(cdId), rwTx); if (!potentialCdFromConfDs.isPresent()) { LOG.error("Classifier-definition with ID {} does not exist in CONF datastore.", cdId); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); DataStoreHelper.submitToDs(rwTx); return; } ClassifierDefinition cd = createClassifierDefinitionWithUnionOfParams(potentialCdFromConfDs.get(), supportedParams); if (cd != null) { rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), cd); } else { DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, IidFactory.classifierDefinitionIid(cdId), rwTx); } DataStoreHelper.submitToDs(rwTx); } SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry);   }