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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
/*******************************************************************************
* 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.framework.skynet.core.event.filter;
import static org.eclipse.osee.framework.core.enums.CoreBranches.COMMON;
import static org.eclipse.osee.framework.core.enums.CoreBranches.SYSTEM_ROOT;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.osee.framework.core.data.BranchId;
import org.eclipse.osee.framework.core.enums.CoreArtifactTypes;
import org.eclipse.osee.framework.core.enums.CoreRelationTypes;
import org.eclipse.osee.framework.core.model.event.IBasicGuidArtifact;
import org.eclipse.osee.framework.core.model.event.IBasicGuidRelation;
import org.eclipse.osee.framework.jdk.core.util.GUID;
import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidArtifact;
import org.eclipse.osee.framework.skynet.core.event.model.EventBasicGuidRelation;
import org.eclipse.osee.framework.skynet.core.event.model.EventModType;
import org.eclipse.osee.framework.skynet.core.relation.RelationEventType;
import org.junit.Assert;
import org.junit.Test;
/**
* Test case for {@link BranchUuidEventFilter}
*
* @author Donald G. Dunne
*/
public class BranchUuidEventFilterTest {
@Test
public void testIsMatch() {
BranchUuidEventFilter branchFilter = new BranchUuidEventFilter(COMMON);
Assert.assertTrue(branchFilter.isMatch(COMMON));
Assert.assertFalse(branchFilter.isMatch(SYSTEM_ROOT));
}
@Test
public void testIsMatchArtifacts() {
BranchUuidEventFilter branchFilter = new BranchUuidEventFilter(COMMON);
EventBasicGuidArtifact guidArtA = new EventBasicGuidArtifact(EventModType.Added, BranchId.create(),
CoreArtifactTypes.Requirement.getGuid(), GUID.create());
EventBasicGuidArtifact guidArtB = new EventBasicGuidArtifact(EventModType.Added, BranchId.create(),
CoreArtifactTypes.SoftwareRequirement.getGuid(), GUID.create());
List<IBasicGuidArtifact> arts = new ArrayList<>();
arts.add(guidArtB);
arts.add(guidArtA);
Assert.assertFalse(branchFilter.isMatchArtifacts(arts));
guidArtA =
new EventBasicGuidArtifact(EventModType.Added, COMMON, CoreArtifactTypes.Requirement.getGuid(), GUID.create());
arts.clear();
arts.add(guidArtB);
arts.add(guidArtA);
Assert.assertTrue(branchFilter.isMatchArtifacts(arts));
}
@Test
public void testIsMatchRelationArtifacts() {
BranchUuidEventFilter branchFilter = new BranchUuidEventFilter(COMMON);
EventBasicGuidArtifact guidArtA = new EventBasicGuidArtifact(EventModType.Added, BranchId.create(),
CoreArtifactTypes.Requirement.getGuid(), GUID.create());
EventBasicGuidArtifact guidArtB = new EventBasicGuidArtifact(EventModType.Added, BranchId.create(),
CoreArtifactTypes.SoftwareRequirement.getGuid(), GUID.create());
List<IBasicGuidRelation> relations = new ArrayList<>();
EventBasicGuidRelation relation = new EventBasicGuidRelation(RelationEventType.Added, BranchId.SENTINEL,
CoreRelationTypes.SupportingInfo_SupportedBy.getGuid(), 234, 123, 55, guidArtA, 66, guidArtB);
relations.add(relation);
// neither in relation matches common branch
Assert.assertFalse(branchFilter.isMatchRelationArtifacts(relations));
guidArtA =
new EventBasicGuidArtifact(EventModType.Added, COMMON, CoreArtifactTypes.Requirement.getGuid(), GUID.create());
guidArtB = new EventBasicGuidArtifact(EventModType.Added, COMMON, CoreArtifactTypes.SoftwareRequirement.getGuid(),
GUID.create());
relations.clear();
relation = new EventBasicGuidRelation(RelationEventType.Added, COMMON,
CoreRelationTypes.SupportingInfo_SupportedBy.getGuid(), 234, 123, 55, guidArtA, 66, guidArtB);
relations.add(relation);
// branch match
Assert.assertTrue(branchFilter.isMatchRelationArtifacts(relations));
}
}
|