2 * Copyright (c) 2015 CableLabs and others. All rights reserved.
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
9 package org.opendaylight.controller.packetcable.provider.validation.impl.validators.qos;
11 import org.junit.Rule;
12 import org.junit.Test;
13 import org.opendaylight.controller.packetcable.provider.test.rules.Params;
14 import org.opendaylight.controller.packetcable.provider.validation.ValidationException;
15 import org.opendaylight.controller.packetcable.provider.validation.Validator;
16 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.pcmm.qos.gates.apps.app.subscribers.Subscriber;
17 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161017.pcmm.qos.gates.apps.app.subscribers.SubscriberBuilder;
22 @Params.AlwaysUseParams
23 public class SubscriberValidatorTest {
27 public Params<Validator.Extent> extentParams = Params.of(Validator.Extent.class);
29 private final SubscriberValidator validator = new SubscriberValidator();
31 @Test(expected = ValidationException.class)
32 public void nullSubscriber() throws ValidationException {
33 validator.validate(null, extentParams.getCurrentParam());
36 @Params.DoNotUseParams
37 @Test(expected = NullPointerException.class)
38 public void nullExtent() throws ValidationException {
39 validator.validate(buildValidSubscriber(), null);
42 @Test(expected = ValidationException.class)
43 public void nullSubscriberId() throws ValidationException {
44 final Subscriber subscriber = new SubscriberBuilder(buildValidSubscriber())
45 .setSubscriberId(null).setKey(null)
47 validator.validate(subscriber, extentParams.getCurrentParam());
50 @Test(expected = ValidationException.class)
51 public void nullGates() throws ValidationException {
52 final Subscriber subscriber = new SubscriberBuilder(buildValidSubscriber())
55 validator.validate(subscriber, extentParams.getCurrentParam());
59 public void valid() throws ValidationException {
60 validator.validate(buildValidSubscriber(), extentParams.getCurrentParam());
63 public static Subscriber buildValidSubscriber() {
64 return new SubscriberBuilder()
65 .setSubscriberId("76.76.76.76")
66 .setGates(GatesValidatorTest.buildValidGates())