blob: 32fe604841ff3efae2e9f7282be939ca6a5c6b6b (
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
|
/*******************************************************************************
* Copyright (c) 2011 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.branch.management.test.purge;
import java.util.Collection;
import junit.framework.Assert;
import org.eclipse.osee.framework.branch.management.purge.DeletedBranchProvider;
import org.eclipse.osee.framework.branch.management.test.mocks.MockBranchProvider;
import org.eclipse.osee.framework.core.enums.BranchArchivedState;
import org.eclipse.osee.framework.core.enums.BranchState;
import org.eclipse.osee.framework.core.enums.BranchType;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.cache.BranchCache;
import org.eclipse.osee.framework.core.model.mocks.MockOseeDataAccessor;
import org.junit.Test;
/**
* @author John Misinco
*/
public final class DeletedBranchProviderTest {
private int expectedResult(Collection<Branch> branches) {
int result = 0;
for (Branch branch : branches) {
if (branch.getBranchState() == BranchState.DELETED && branch.getArchiveState() == BranchArchivedState.ARCHIVED && !(branch.getBranchType() == BranchType.BASELINE)) {
result++;
}
}
return result;
}
@Test
public void testGetBranches() throws OseeCoreException {
BranchCache mockCache = new BranchCache(new MockOseeDataAccessor<Branch>());
Collection<Branch> branches = MockBranchProvider.createTestBranches();
mockCache.cache(branches.toArray(new Branch[branches.size()]));
DeletedBranchProvider provider = new DeletedBranchProvider(mockCache);
int numBranches = provider.getBranches().size();
Assert.assertEquals(expectedResult(branches), numBranches);
}
@Test(expected = OseeCoreException.class)
public void testGetBranchesException() throws OseeCoreException {
DeletedBranchProvider provider = new DeletedBranchProvider(null);
provider.getBranches().size();
}
}
|