blob: 71083624768a8af5d603329cb8cddf27fa3fb377 [file] [log] [blame]
Thomas Vachuskaf9c84362015-04-15 11:20:45 -07001/*
2 * Copyright 2015 Open Networking Laboratory
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 */
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 Vachuska4bfccd542015-05-30 00:35:25 -070039 parent = new Group("parent", null, null, null, null);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070040 }
41
42 @Test
43 public void basics() {
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070044 Step step = new Step(NAME, CMD, ENV, CWD, parent);
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());
50 }
51
52 @Test
53 public void equality() {
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070054 Step s1 = new Step(NAME, CMD, null, null, parent);
55 Step s2 = new Step(NAME, CMD, ENV, CWD, null);
56 Step s3 = new Step("foo", null, null, null, parent);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070057 new EqualsTester()
58 .addEqualityGroup(s1, s2)
59 .addEqualityGroup(s3)
60 .testEquals();
61 }
62}