Skip to main content
summaryrefslogtreecommitdiffstats
blob: 1b59979a96fd0f890071d9735d5bbfaabf4be728 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/*******************************************************************************
 * Copyright (c) 2013 Boeing.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Boeing - initial API and implementation
 *******************************************************************************/
package org.eclipse.osee.ats.core.workdef;

import org.eclipse.osee.ats.api.workdef.IAtsWorkDefinition;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.MockitoAnnotations;

/**
 * Test case for {@link WorkDefinitionMatch}
 *
 * @author Donald G. Dunne
 */
public class WorkDefinitionMatchTest {

   // @formatter:off
   @Mock private IAtsWorkDefinition workDef;
   // @formatter:on

   @Before
   public void setup() {
      MockitoAnnotations.initMocks(this);
      Mockito.when(workDef.getName()).thenReturn("mine");
   }

   @Test
   public void testWorkDefinitionMatch() {
      WorkDefinitionMatch match = new WorkDefinitionMatch();
      Assert.assertNull(match.getWorkDefinition());
      Assert.assertTrue(match.getTrace().isEmpty());
   }

   @Test
   public void testWorkDefinitionMatchWorkDefinitionString() {
      WorkDefinitionMatch match = new WorkDefinitionMatch(workDef.getName(), "trace");
      match.setWorkDefinition(workDef);
      Assert.assertNotNull(match.getWorkDefinition());
      Assert.assertFalse(match.getTrace().isEmpty());
   }

   @Test
   public void testAddTrace() {
      WorkDefinitionMatch match = new WorkDefinitionMatch();
      Assert.assertTrue(match.getTrace().isEmpty());
      match.addTrace("trace 1");
      Assert.assertEquals("trace 1", match.getTrace().iterator().next());
      match.addTrace("trace 1");
      Assert.assertEquals(1, match.getTrace().size());
      Assert.assertEquals("trace 1", match.getTrace().iterator().next());
      match.addTrace("trace 2");
      Assert.assertEquals("trace 1", match.getTrace().iterator().next());
      Assert.assertEquals(2, match.getTrace().size());
   }

   @Test
   public void testIsMatched() {
      WorkDefinitionMatch match = new WorkDefinitionMatch(workDef.getName(), "trace");
      match.setWorkDefinition(workDef);
      Assert.assertTrue(match.isMatched());
      match.setWorkDefinition(null);
      Assert.assertFalse(match.isMatched());
   }

   @Test
   public void testToString() {
      WorkDefinitionMatch match = new WorkDefinitionMatch(workDef.getName(), "trace");
      match.setWorkDefinition(workDef);
      Assert.assertEquals("mine", match.toString());
   }

}

Back to the top