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.controller.packetcable.provider.validation.impl.validators.qos.classifier.ClassifiersValidatorTest;
17 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.Gate;
18 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gates.apps.app.subscribers.subscriber.gates.GateBuilder;
23 @Params.AlwaysUseParams
24 public class GateValidatorTest {
27 public Params<Validator.Extent> extentParams = Params.of(Validator.Extent.class);
29 private final GateValidator validator = new GateValidator();
31 @Test(expected = ValidationException.class)
32 public void nullGate() 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(buildValidGate(), null);
42 @Test(expected = ValidationException.class)
43 public void nullGateId() throws ValidationException {
44 Gate gate = new GateBuilder(buildValidGate()).setKey(null).setGateId(null).build();
45 validator.validate(gate, extentParams.getCurrentParam());
49 public void nullGateSpec() throws ValidationException {
50 // gate spec is all optional, no exception expected
51 Gate gate = new GateBuilder(buildValidGate()).setGateSpec(null).build();
52 validator.validate(gate, extentParams.getCurrentParam());
55 @Test(expected = ValidationException.class)
56 public void nullTrafficProfile() throws ValidationException {
57 Gate gate = new GateBuilder(buildValidGate()).setTrafficProfile(null).build();
58 validator.validate(gate, extentParams.getCurrentParam());
61 @Test(expected = ValidationException.class)
62 public void nullClassifiers() throws ValidationException {
63 Gate gate = new GateBuilder(buildValidGate()).setClassifiers(null).build();
64 validator.validate(gate, extentParams.getCurrentParam());
68 public void valid() throws ValidationException {
69 validator.validate(buildValidGate(), extentParams.getCurrentParam());
73 public static Gate buildValidGate() {
74 return new GateBuilder()
75 .setGateId("unit-test-gate-id")
76 .setGateSpec(GateSpecValidatorTest.buildValidGateSpec())
77 .setTrafficProfile(TrafficProfileValidatorTest.buildValidTrafficProfile())
78 .setClassifiers(ClassifiersValidatorTest.buildValidClassifiers())