227354c41e1f50bfbd62b8edbd82c2928d83d0b3
[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 junit.framework.Assert;
11
12
13 import org.opendaylight.yangtools.yang.binding.Augmentable;
14 import org.opendaylight.yangtools.yang.binding.Augmentation;
15
16 public class AugmentationVerifier<T extends Augmentable<T>> {
17
18     private T object;
19
20     public AugmentationVerifier(T objectToVerify) {
21         this.object = objectToVerify;
22     }
23
24     public AugmentationVerifier<T> assertHasAugmentation(Class<? extends Augmentation<T>> augmentation) {
25         assertHasAugmentation(object, augmentation);
26         return (AugmentationVerifier<T>) this;
27     }
28
29     public static <T extends Augmentable<T>> void assertHasAugmentation(T object,
30             Class<? extends Augmentation<T>> augmentation) {
31         Assert.assertNotNull(object);
32         Assert.assertNotNull("Augmentation " + augmentation.getSimpleName() + " is not present.", object.getAugmentation(augmentation));
33     }
34
35     public static <T extends Augmentable<T>> AugmentationVerifier<T> from(T obj) {
36         return new AugmentationVerifier<T>(obj);
37     }
38
39 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.