blob: bb5d1ccc5ec23731e50919fafa314643255e489f [file] [log] [blame]
Thomas Vachuskaf9c84362015-04-15 11:20:45 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thomas Vachuskaf9c84362015-04-15 11:20:45 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onlab.stc;
17
18import com.google.common.testing.EqualsTester;
19import org.apache.commons.configuration.ConfigurationException;
20import org.junit.Before;
21import org.junit.Test;
22
23import static org.junit.Assert.*;
24
25/**
26 * Test of the test step dependency.
27 */
28public class DependencyTest extends StepTest {
29
30 protected Step step1, step2;
31
HIGUCHI Yutad9c61172016-01-04 23:31:13 -080032 @Override
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070033 @Before
34 public void setUp() throws ConfigurationException {
35 super.setUp();
Thomas Vachuska664f29e2015-12-08 12:58:16 -080036 step1 = new Step("step1", CMD, null, null, null, 0);
37 step2 = new Step("step2", CMD, null, null, null, 0);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070038 }
39
40 @Test
41 public void hard() {
42 Dependency hard = new Dependency(step1, step2, false);
43 assertSame("incorrect src", step1, hard.src());
44 assertSame("incorrect dst", step2, hard.dst());
45 assertFalse("incorrect isSoft", hard.isSoft());
46 }
47
48 @Test
49 public void soft() {
50 Dependency soft = new Dependency(step2, step1, true);
51 assertSame("incorrect src", step2, soft.src());
52 assertSame("incorrect dst", step1, soft.dst());
53 assertTrue("incorrect isSoft", soft.isSoft());
54 }
55
HIGUCHI Yutad9c61172016-01-04 23:31:13 -080056 @Override
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070057 @Test
58 public void equality() {
59 Dependency d1 = new Dependency(step1, step2, false);
60 Dependency d2 = new Dependency(step1, step2, false);
61 Dependency d3 = new Dependency(step1, step2, true);
62 Dependency d4 = new Dependency(step2, step1, true);
63 new EqualsTester()
64 .addEqualityGroup(d1, d2)
65 .addEqualityGroup(d3)
66 .addEqualityGroup(d4)
67 .testEquals();
68 }
69
70}