blob: 444f41fc8b9e21e0c043e2032c8b3a772b4fd74d (
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
|
/*******************************************************************************
* Copyright (c) 2004, 2007 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.core.model.cache;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.osee.framework.core.model.Branch;
import org.eclipse.osee.framework.core.model.mocks.MockDataFactory;
import org.eclipse.osee.framework.core.model.mocks.MockOseeDataAccessor;
import org.eclipse.osee.framework.jdk.core.type.OseeCoreException;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.junit.Assert;
import org.junit.BeforeClass;
/**
* Test Case for {@link BranchCache}
*
* @author Roberto E. Escobar
*/
public class BranchCacheTest extends AbstractOseeCacheTest<Long, Branch> {
private static List<Branch> branchData;
private static BranchCache cache;
@BeforeClass
public static void prepareTestData() throws OseeCoreException {
branchData = new ArrayList<Branch>();
BranchDataAccessor branchAccessor = new BranchDataAccessor(branchData);
cache = new BranchCache(branchAccessor);
cache.ensurePopulated();
Assert.assertTrue(branchAccessor.wasLoaded());
}
public BranchCacheTest() {
super(branchData, cache);
}
private final static class BranchDataAccessor extends MockOseeDataAccessor<Long, Branch> {
private final List<Branch> data;
public BranchDataAccessor(List<Branch> data) {
super();
this.data = data;
}
@Override
public void load(IOseeCache<Long, Branch> cache) throws OseeCoreException {
super.load(cache);
int typeId = 100;
for (int index = 0; index < 10; index++) {
Branch item = MockDataFactory.createBranch(typeId++, index);
data.add(item);
cache.cache(item);
}
}
}
@Override
protected Long createKey() {
return Lib.generateUuid();
}
}
|