blob: 3533d8482bc5ef16f068887acb698fea6589e527 [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.junit.Test;
20
21import static org.junit.Assert.assertEquals;
22import static org.junit.Assert.assertSame;
23
24/**
25 * Test of the test scenario entity.
26 */
27public class GroupTest extends StepTest {
28
29 @Test
30 public void basics() {
Thomas Vachuska664f29e2015-12-08 12:58:16 -080031 Group group = new Group(NAME, CMD, ENV, CWD, parent, 1);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070032 assertEquals("incorrect name", NAME, group.name());
33 assertEquals("incorrect command", CMD, group.command());
Thomas Vachuska4bfccd542015-05-30 00:35:25 -070034 assertEquals("incorrect env", ENV, group.env());
35 assertEquals("incorrect cwd", CWD, group.cwd());
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070036 assertSame("incorrect group", parent, group.group());
Thomas Vachuska664f29e2015-12-08 12:58:16 -080037 assertEquals("incorrect delay", 1, group.delay());
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070038
Thomas Vachuska664f29e2015-12-08 12:58:16 -080039 Step step = new Step("step", null, null, null, group, 0);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070040 group.addChild(step);
41 assertSame("incorrect child", step, group.children().iterator().next());
42 }
43
44 @Test
45 public void equality() {
Thomas Vachuska664f29e2015-12-08 12:58:16 -080046 Group g1 = new Group(NAME, CMD, null, null, parent, 0);
47 Group g2 = new Group(NAME, CMD, ENV, CWD, null, 0);
48 Group g3 = new Group("foo", null, null, null, parent, 0);
Thomas Vachuskaf9c84362015-04-15 11:20:45 -070049 new EqualsTester()
50 .addEqualityGroup(g1, g2)
51 .addEqualityGroup(g3)
52 .testEquals();
53 }
54
55}