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.rev161128.ServiceFlowDirection;
17 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161128.TosByte;
18 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161128.pcmm.qos.gate.spec.GateSpec;
19 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161128.pcmm.qos.gate.spec.GateSpecBuilder;
24 @Params.AlwaysUseParams
25 public class GateSpecValidatorTest {
28 public Params<Validator.Extent> extentParams = Params.of(Validator.Extent.class);
30 private final GateSpecValidator validator = new GateSpecValidator();
32 @Test(expected = ValidationException.class)
33 public void nullGateSpec() throws ValidationException {
34 validator.validate(null, extentParams.getCurrentParam());
37 @Params.DoNotUseParams
38 @Test(expected = NullPointerException.class)
39 public void nullExtent() throws ValidationException {
40 validator.validate(buildValidGateSpec(), null);
44 public void nullDirection() throws ValidationException {
45 // optional expect no exception
46 GateSpec gateSpec = new GateSpecBuilder(buildValidGateSpec())
49 validator.validate(gateSpec, extentParams.getCurrentParam());
53 public void nullDscpTosMask() throws ValidationException {
54 // optional expect no exception
55 GateSpec gateSpec = new GateSpecBuilder(buildValidGateSpec())
58 validator.validate(gateSpec, extentParams.getCurrentParam());
62 public void nullDscpTosOverwrite() throws ValidationException {
63 // optional expect no exception
64 GateSpec gateSpec = new GateSpecBuilder(buildValidGateSpec())
65 .setDscpTosOverwrite(null)
67 validator.validate(gateSpec, extentParams.getCurrentParam());
71 public void valid() throws ValidationException {
72 validator.validate(buildValidGateSpec(), extentParams.getCurrentParam());
75 public static GateSpec buildValidGateSpec() {
76 return new GateSpecBuilder()
77 .setDirection(ServiceFlowDirection.Us)
78 .setDscpTosMask(new TosByte((short) 0xff))
79 .setDscpTosOverwrite(new TosByte((short) 0xa0))
80 .setInactivityTimer(new Long(900))
81 .setSessionClassId(new Short((short)38))