@Test public void testSetParentValidators_newValidatorHasParent_parentValidatorExists() { RendererName rendererFoo = new RendererName("Foo"); SupportedClassifierDefinition supportedIpProtoPort = new SupportedClassifierDefinitionBuilder() .setClassifierDefinitionId(IpProtoClassifierDefinition.ID).build(); ClassifierInstanceValidator rendererFooIpProtoParentValidator = new ClassifierInstanceValidator(supportedIpProtoPort, rendererFoo); listener.validatorByRendererAndCd.put(rendererFoo, IpProtoClassifierDefinition.ID, rendererFooIpProtoParentValidator); SupportedClassifierDefinition supportedL4SrcPort = new SupportedClassifierDefinitionBuilder().setClassifierDefinitionId(L4ClassifierDefinition.ID) .setParentClassifierDefinitionId(IpProtoClassifierDefinition.ID) .build(); ClassifierInstanceValidator rendererFooL4SrcPortNewValidator = new ClassifierInstanceValidator(supportedL4SrcPort, rendererFoo); listener.validatorByRendererAndCd.put(rendererFoo, L4ClassifierDefinition.ID, rendererFooL4SrcPortNewValidator); listener.setParentValidators(rendererFooL4SrcPortNewValidator, false); Assert.assertEquals(rendererFooIpProtoParentValidator, rendererFooL4SrcPortNewValidator.getParentValidator()); listener.setParentValidators(rendererFooL4SrcPortNewValidator, true); Assert.assertNull(rendererFooIpProtoParentValidator.getParentValidator()); }
@VisibleForTesting void setParentValidators(ClassifierInstanceValidator ciValidator, boolean setParentToNull) { if (ciValidator.getParentClassifierDefinitionId() != null && !setParentToNull) { ClassifierInstanceValidator parentCiValidator = validatorByRendererAndCd.get(ciValidator.getRendererName(), ciValidator.getParentClassifierDefinitionId()); if (parentCiValidator != null) { ciValidator.setParentValidator(parentCiValidator); } } for (ClassifierInstanceValidator existingCiValidator : getValidatorsWithParentCdForRenderer( ciValidator.getClassifierDefinitionId(), ciValidator.getRendererName())) { if (setParentToNull) { existingCiValidator.setParentValidator(null); } else { existingCiValidator.setParentValidator(ciValidator); } } }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void setParentValidators(ClassifierInstanceValidator ciValidator, boolean setParentToNull) { if (ciValidator.getParentClassifierDefinitionId() != null && !setParentToNull) { ClassifierInstanceValidator parentCiValidator = validatorByRendererAndCd.get(ciValidator.getRendererName(), ciValidator.getParentClassifierDefinitionId()); if (parentCiValidator != null) { ciValidator.setParentValidator(parentCiValidator); } } for (ClassifierInstanceValidator existingCiValidator : getValidatorsWithParentCdForRenderer( ciValidator.getClassifierDefinitionId(), ciValidator.getRendererName())) { if (setParentToNull) { existingCiValidator.setParentValidator(null); } else { existingCiValidator.setParentValidator(ciValidator); } } } }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void setParentValidators(ClassifierInstanceValidator ciValidator, boolean setParentToNull) { if (ciValidator.getParentClassifierDefinitionId() != null && !setParentToNull) { ClassifierInstanceValidator parentCiValidator = validatorByRendererAndCd.get(ciValidator.getRendererName(), ciValidator.getParentClassifierDefinitionId()); if (parentCiValidator != null) { ciValidator.setParentValidator(parentCiValidator); } } for (ClassifierInstanceValidator existingCiValidator : getValidatorsWithParentCdForRenderer( ciValidator.getClassifierDefinitionId(), ciValidator.getRendererName())) { if (setParentToNull) { existingCiValidator.setParentValidator(null); } else { existingCiValidator.setParentValidator(ciValidator); } } } SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry); }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void setParentValidators(ClassifierInstanceValidator ciValidator, boolean setParentToNull) { if (ciValidator.getParentClassifierDefinitionId() != null && !setParentToNull) { ClassifierInstanceValidator parentCiValidator = validatorByRendererAndCd.get(ciValidator.getRendererName(), ciValidator.getParentClassifierDefinitionId()); if (parentCiValidator != null) { ciValidator.setParentValidator(parentCiValidator); } } for (ClassifierInstanceValidator existingCiValidator : getValidatorsWithParentCdForRenderer( ciValidator.getClassifierDefinitionId(), ciValidator.getRendererName())) { if (setParentToNull) { existingCiValidator.setParentValidator(null); } else { existingCiValidator.setParentValidator(ciValidator); } } } SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry);  }
SupportedClassifierDefinitionListener extends DataTreeChangeHandler<SupportedClassifierDefinition> { @VisibleForTesting void setParentValidators(ClassifierInstanceValidator ciValidator, boolean setParentToNull) { if (ciValidator.getParentClassifierDefinitionId() != null && !setParentToNull) { ClassifierInstanceValidator parentCiValidator = validatorByRendererAndCd.get(ciValidator.getRendererName(), ciValidator.getParentClassifierDefinitionId()); if (parentCiValidator != null) { ciValidator.setParentValidator(parentCiValidator); } } for (ClassifierInstanceValidator existingCiValidator : getValidatorsWithParentCdForRenderer( ciValidator.getClassifierDefinitionId(), ciValidator.getRendererName())) { if (setParentToNull) { existingCiValidator.setParentValidator(null); } else { existingCiValidator.setParentValidator(ciValidator); } } } SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry);   }