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.assertEquals; |
| 24 | import static org.junit.Assert.assertSame; |
| 25 | |
| 26 | /** |
| 27 | * Test of the test step entity. |
| 28 | */ |
| 29 | public class StepTest { |
| 30 | |
| 31 | protected static final String NAME = "step"; |
| 32 | protected static final String CMD = "command"; |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame] | 33 | protected static final String ENV = "environment"; |
| 34 | protected static final String CWD = "directory"; |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 35 | protected Group parent; |
| 36 | |
| 37 | @Before |
| 38 | public void setUp() throws ConfigurationException { |
Thomas Vachuska | 664f29e | 2015-12-08 12:58:16 -0800 | [diff] [blame] | 39 | parent = new Group("parent", null, null, null, null, 0); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 40 | } |
| 41 | |
| 42 | @Test |
| 43 | public void basics() { |
Thomas Vachuska | 664f29e | 2015-12-08 12:58:16 -0800 | [diff] [blame] | 44 | Step step = new Step(NAME, CMD, ENV, CWD, parent, 1); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 45 | assertEquals("incorrect name", NAME, step.name()); |
| 46 | assertEquals("incorrect command", CMD, step.command()); |
Thomas Vachuska | 4bfccd54 | 2015-05-30 00:35:25 -0700 | [diff] [blame] | 47 | assertEquals("incorrect env", ENV, step.env()); |
| 48 | assertEquals("incorrect cwd", CWD, step.cwd()); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 49 | assertSame("incorrect group", parent, step.group()); |
Thomas Vachuska | 664f29e | 2015-12-08 12:58:16 -0800 | [diff] [blame] | 50 | assertEquals("incorrect delay", 1, step.delay()); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | @Test |
| 54 | public void equality() { |
Thomas Vachuska | 664f29e | 2015-12-08 12:58:16 -0800 | [diff] [blame] | 55 | Step s1 = new Step(NAME, CMD, null, null, parent, 0); |
| 56 | Step s2 = new Step(NAME, CMD, ENV, CWD, null, 0); |
| 57 | Step s3 = new Step("foo", null, null, null, parent, 0); |
Thomas Vachuska | f9c8436 | 2015-04-15 11:20:45 -0700 | [diff] [blame] | 58 | new EqualsTester() |
| 59 | .addEqualityGroup(s1, s2) |
| 60 | .addEqualityGroup(s3) |
| 61 | .testEquals(); |
| 62 | } |
| 63 | } |