45eed6a0695a20ee0bcbc1d1eb9bb6314b96e808
[controller.git] / opendaylight / md-sal / sal-binding-broker / src / test / java / org / opendaylight / controller / sal / binding / test / AugmentationVerifier.java
1 /*
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.sal.binding.test;
9
10 import static org.junit.Assert.assertNotNull;
11
12 import org.opendaylight.yangtools.yang.binding.Augmentable;
13 import org.opendaylight.yangtools.yang.binding.Augmentation;
14
15 @Deprecated
16 public class AugmentationVerifier<T extends Augmentable<T>> {
17
18     private final T object;
19
20     public AugmentationVerifier(final T objectToVerify) {
21         this.object = objectToVerify;
22     }
23
24     public AugmentationVerifier<T> assertHasAugmentation(final Class<? extends Augmentation<T>> augmentation) {
25         assertHasAugmentation(object, augmentation);
26         return this;
27     }
28
29     public static <T extends Augmentable<T>> void assertHasAugmentation(final T object,
30             final Class<? extends Augmentation<T>> augmentation) {
31         assertNotNull(object);
32         assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.",
33                 object.augmentation(augmentation));
34     }
35
36     public static <T extends Augmentable<T>> AugmentationVerifier<T> from(final T obj) {
37         return new AugmentationVerifier<>(obj);
38     }
39 }