Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5366d072dac9da51949274226e7a43060b226cef (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
/*******************************************************************************
 * Copyright (c) 2012 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.world.search;

import java.util.Arrays;
import java.util.Collection;
import junit.framework.Assert;
import org.eclipse.osee.ats.api.data.AtsAttributeTypes;
import org.eclipse.osee.ats.core.client.AtsTestUtil;
import org.eclipse.osee.ats.core.client.team.TeamWorkFlowArtifact;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.skynet.core.artifact.Artifact;
import org.junit.Test;

/**
 * Test Case for {@link LegacyPcrIdQuickSearch}
 * 
 * @author Donald G. Dunne
 */
public class LegacyPcrIdQuickSearchTest {

   @Test
   public void testPerformSearch() throws OseeCoreException {
      AtsTestUtil.cleanupAndReset(getClass().getSimpleName() + ".testPerformSearch");
      TeamWorkFlowArtifact teamWf = AtsTestUtil.getTeamWf();
      teamWf.persist(getClass().getSimpleName());

      TeamWorkFlowArtifact teamWf2 = AtsTestUtil.getTeamWf2();
      teamWf2.persist(getClass().getSimpleName());

      LegacyPcrIdQuickSearch srch = new LegacyPcrIdQuickSearch(Arrays.asList("67676"));
      Assert.assertTrue("No results should be found", srch.performSearch().isEmpty());

      teamWf.setSoleAttributeValue(AtsAttributeTypes.LegacyPcrId, "67676");
      teamWf.persist(getClass().getSimpleName());

      srch = new LegacyPcrIdQuickSearch(Arrays.asList("67676"));
      Assert.assertEquals("Should return teamWf", teamWf, srch.performSearch().iterator().next());

      teamWf2.setSoleAttributeValue(AtsAttributeTypes.LegacyPcrId, "32323");
      teamWf2.persist(getClass().getSimpleName());

      srch = new LegacyPcrIdQuickSearch(Arrays.asList("67676", "32323"));
      Collection<Artifact> results = srch.performSearch();
      Assert.assertTrue(results.contains(teamWf));
      Assert.assertTrue(results.contains(teamWf2));

      teamWf.setSoleAttributeValue(AtsAttributeTypes.LegacyPcrId, "RPCR_67676");
      teamWf.persist(getClass().getSimpleName());

      // As single string, neither should be found if exactMatch == true
      srch = new LegacyPcrIdQuickSearch(Arrays.asList("RPCR 67676"));
      results = srch.performSearch(true);
      Assert.assertTrue("No results should be found", results.isEmpty());

      // As single string, both should be found if exactMatch == false
      srch = new LegacyPcrIdQuickSearch(Arrays.asList("RPCR 67676"));
      results = srch.performSearch(false);
      Assert.assertTrue(results.contains(teamWf));

   }

}

Back to the top