blob: 0713afcc82fb5a0a831e7a6e6ae711bc0644b6fb [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.assertEquals;
24import static org.junit.Assert.assertSame;
25
26/**
27 * Test of the test step entity.
28 */
29public class StepTest {
30
31 protected static final String NAME = "step";
32 protected static final String CMD = "command";
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070033 protected static final String ENV = "environment";
34 protected static final String CWD = "directory";
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070035 protected Group parent;
36
37 @Before
38 public void setUp() throws ConfigurationException {
Thomas Vachuska664f29e2015-12-08 12:58:16 -080039 parent = new Group("parent", null, null, null, null, 0);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070040 }
41
42 @Test
43 public void basics() {
Thomas Vachuska664f29e2015-12-08 12:58:16 -080044 Step step = new Step(NAME, CMD, ENV, CWD, parent, 1);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070045 assertEquals("incorrect name", NAME, step.name());
46 assertEquals("incorrect command", CMD, step.command());
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070047 assertEquals("incorrect env", ENV, step.env());
48 assertEquals("incorrect cwd", CWD, step.cwd());
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070049 assertSame("incorrect group", parent, step.group());
Thomas Vachuska664f29e2015-12-08 12:58:16 -080050 assertEquals("incorrect delay", 1, step.delay());
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070051 }
52
53 @Test
54 public void equality() {
Thomas Vachuska664f29e2015-12-08 12:58:16 -080055 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 Vachuskaf9c84362015-04-15 11:20:45 -070058 new EqualsTester()
59 .addEqualityGroup(s1, s2)
60 .addEqualityGroup(s3)
61 .testEquals();
62 }
63}