SfcScfOfDataListener extends AbstractDataTreeChangeListener<ServiceFunctionClassifier> { @Override protected void add(ServiceFunctionClassifier serviceFunctionClassifier) { if (serviceFunctionClassifier != null) { LOG.debug("Created ServiceFunctionClassifier name: {}\n", serviceFunctionClassifier.getName()); this.sfcScfProcessor.createdServiceFunctionClassifier(serviceFunctionClassifier); } } SfcScfOfDataListener(final DataBroker dataBroker, SfcScfOfProcessor sfcScfProcessor); void init(); @Override void close();  }
@Test public void testOnSfcScfOfDataCreated() throws Exception { ServiceFunctionClassifier serviceFunctionClassifier = buildServiceFunctionClassifier(); when(dataTreeModification.getRootNode()).thenReturn(dataObjectModification); when(dataObjectModification.getModificationType()).thenReturn(ModificationType.WRITE); when(dataObjectModification.getDataBefore()).thenReturn(null); when(dataObjectModification.getDataAfter()).thenReturn(serviceFunctionClassifier); collection.add(dataTreeModification); sfcScfOfDataListener.onDataTreeChanged(collection); Thread.sleep(500); verify(sfcScfOfProcessor).createdServiceFunctionClassifier(serviceFunctionClassifier); }
@Test public void testOnSfcScfOfDataRemoved() throws Exception { ServiceFunctionClassifier serviceFunctionClassifier = buildServiceFunctionClassifier(); when(dataTreeModification.getRootNode()).thenReturn(dataObjectModification); when(dataObjectModification.getModificationType()).thenReturn(ModificationType.DELETE); when(dataObjectModification.getDataBefore()).thenReturn(serviceFunctionClassifier); collection.add(dataTreeModification); sfcScfOfDataListener.onDataTreeChanged(collection); Thread.sleep(500); verify(sfcScfOfProcessor).deletedServiceFunctionClassifier(serviceFunctionClassifier); }
@Test public void testOnSfcScfOfDataUpdated() throws Exception { ServiceFunctionClassifier originalServiceFunctionClassifier = buildServiceFunctionClassifier(); sfcScfOfProcessor.createdServiceFunctionClassifier(originalServiceFunctionClassifier); ServiceFunctionClassifierBuilder updatedServiceFunctionClassifierBuilder = new ServiceFunctionClassifierBuilder(originalServiceFunctionClassifier); AclBuilder aclBuilder2 = new AclBuilder(); aclBuilder2.setName(ACL_NAME2); aclBuilder2.setType(ACL_TYPE); Acl acl_dummy2 = aclBuilder2.build(); updatedServiceFunctionClassifierBuilder.setAcl(acl_dummy2); ServiceFunctionClassifier updatedServiceFunctionClassifier = updatedServiceFunctionClassifierBuilder.build(); when(dataTreeModification.getRootNode()).thenReturn(dataObjectModification); when(dataObjectModification.getModificationType()).thenReturn(ModificationType.SUBTREE_MODIFIED); when(dataObjectModification.getDataBefore()).thenReturn(originalServiceFunctionClassifier); when(dataObjectModification.getDataAfter()).thenReturn(updatedServiceFunctionClassifier); collection.add(dataTreeModification); sfcScfOfDataListener.onDataTreeChanged(collection); Thread.sleep(500); verify(sfcScfOfProcessor).deletedServiceFunctionClassifier(originalServiceFunctionClassifier); verify(sfcScfOfProcessor).createdServiceFunctionClassifier(updatedServiceFunctionClassifier); }