Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 3 | * |
| 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 | */ |
| 16 | package org.onlab.stc; |
| 17 | |
| 18 | import com.google.common.testing.EqualsTester; |
| 19 | import org.apache.commons.configuration.ConfigurationException; |
| 20 | import org.junit.Before; |
| 21 | import org.junit.Test; |
| 22 | |
| 23 | import static org.junit.Assert.*; |
| 24 | |
| 25 | /** |
| 26 | * Test of the test step dependency. |
| 27 | */ |
| 28 | public class DependencyTest extends StepTest { |
| 29 | |
| 30 | protected Step step1, step2; |
| 31 | |
HIGUCHI Yuta | d9c6117 | 2016-01-04 23:31:13 -0800 | [diff] [blame] | 32 | @Override |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 33 | @Before |
| 34 | public void setUp() throws ConfigurationException { |
| 35 | super.setUp(); |
Thomas Vachuska | 664f29e | 2015-12-08 12:58:16 -0800 | [diff] [blame] | 36 | step1 = new Step("step1", CMD, null, null, null, 0); |
| 37 | step2 = new Step("step2", CMD, null, null, null, 0); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 38 | } |
| 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 Yuta | d9c6117 | 2016-01-04 23:31:13 -0800 | [diff] [blame] | 56 | @Override |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 57 | @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 | } |