bff77bec182d552b836878f411b67e9814392642
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / sal / binding / test / AugmentationVerifier.java
1 package org.opendaylight.controller.sal.binding.test;
2
3 import junit.framework.Assert;
4
5
6 import org.opendaylight.yangtools.yang.binding.Augmentable;
7 import org.opendaylight.yangtools.yang.binding.Augmentation;
8
9 public class AugmentationVerifier<T extends Augmentable<T>> {
10
11     private T object;
12
13     public AugmentationVerifier(T objectToVerify) {
14         this.object = objectToVerify;
15     }
16
17     public AugmentationVerifier<T> assertHasAugmentation(Class<? extends Augmentation<T>> augmentation) {
18         assertHasAugmentation(object, augmentation);
19         return (AugmentationVerifier<T>) this;
20     }
21
22     public static <T extends Augmentable<T>> void assertHasAugmentation(T object,
23             Class<? extends Augmentation<T>> augmentation) {
24         Assert.assertNotNull(object);
25         Assert.assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.", object.getAugmentation(augmentation));
26     }
27
28     public static <T extends Augmentable<T>> AugmentationVerifier<T> from(T obj) {
29         return new AugmentationVerifier<T>(obj);
30     }
31
32 }