Added FlowSpec Traffic Profile feature
[packetcable.git] / packetcable-policy-server / src / test / java / org / opendaylight / controller / packetcable / provider / validation / impl / validators / qos / AppsValidatorTest.java
1 /*
2  * Copyright (c) 2015 CableLabs 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
9 package org.opendaylight.controller.packetcable.provider.validation.impl.validators.qos;
10
11 import java.util.Collections;
12 import org.junit.Rule;
13 import org.junit.Test;
14 import org.opendaylight.controller.packetcable.provider.test.rules.Params;
15 import org.opendaylight.controller.packetcable.provider.validation.ValidationException;
16 import org.opendaylight.controller.packetcable.provider.validation.Validator;
17 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gates.Apps;
18 import org.opendaylight.yang.gen.v1.urn.packetcable.rev161219.pcmm.qos.gates.AppsBuilder;
19
20 /**
21  * @author rvail
22  */
23 @Params.AlwaysUseParams
24 public class AppsValidatorTest {
25
26     @Rule
27     public Params<Validator.Extent> extentParams = Params.of(Validator.Extent.class);
28
29     private final AppsValidator validator = new AppsValidator();
30
31     @Test(expected = ValidationException.class)
32     public void nullApps() throws ValidationException {
33         validator.validate(null, extentParams.getCurrentParam());
34     }
35
36     @Params.DoNotUseParams
37     @Test(expected = NullPointerException.class)
38     public void nullExtent() throws ValidationException {
39         validator.validate(buildValidApps(), null);
40     }
41
42     @Test
43     public void valid() throws ValidationException {
44         validator.validate(buildValidApps(), extentParams.getCurrentParam());
45     }
46
47     public static Apps buildValidApps() {
48         return new AppsBuilder()
49                 .setApp(Collections.singletonList(AppValidatorTest.buildValidApp()))
50                 .build();
51     }
52 }