blob: 5ff98dfac569b408630c828bf1504167d9752e96 (
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
84
85
86
87
88
89
90
91
|
/*******************************************************************************
* 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.orcs.core.internal.graph;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;
import org.eclipse.osee.framework.core.data.IOseeBranch;
import org.eclipse.osee.framework.core.enums.CoreBranches;
import org.eclipse.osee.framework.core.exception.OseeArgumentException;
import org.eclipse.osee.framework.core.exception.OseeCoreException;
import org.eclipse.osee.orcs.OrcsSession;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ExpectedException;
import org.mockito.Mock;
/**
* Test Case for {@link GraphUtil}
*
* @author Megumi Telles
*/
public class GraphUtilTest {
private static final IOseeBranch BRANCH = CoreBranches.COMMON;
private static final int TRANSACTION_ID = 231214214;
@Rule
public ExpectedException thrown = ExpectedException.none();
// @formatter:off
@Mock private OrcsSession session;
@Mock private GraphData graph;
// @formatter:on
private GraphProvider provider;
@Before
public void setUp() {
initMocks(this);
provider = GraphUtil.asProvider(graph);
when(graph.getBranch()).thenReturn(BRANCH);
when(graph.getTransaction()).thenReturn(TRANSACTION_ID);
}
@Test
public void testAsProviderNullBranch() throws OseeCoreException {
assertNotNull(provider);
thrown.expect(OseeArgumentException.class);
thrown.expectMessage("branch cannot be null - Invalid branch - can't provide graph");
provider.getGraph(session, null, TRANSACTION_ID);
}
@Test
public void testAsProviderBranchNotSame() throws OseeCoreException {
assertNotNull(provider);
thrown.expect(OseeArgumentException.class);
thrown.expectMessage("Invalid branch - Graph's branch[Common] does not equals requested branch[System Root Branch]");
provider.getGraph(session, CoreBranches.SYSTEM_ROOT, TRANSACTION_ID);
}
@Test
public void testAsProviderTxIdNotSame() throws OseeCoreException {
assertNotNull(provider);
int txId = 123456789;
thrown.expect(OseeArgumentException.class);
thrown.expectMessage("Invalid transactionId - Graph's transactionId[231214214] does not equals requested transactionId[123456789]");
provider.getGraph(session, BRANCH, txId);
}
@Test
public void testAsProviderGetName() throws OseeCoreException {
assertNotNull(provider);
assertEquals(graph, provider.getGraph(session, BRANCH, TRANSACTION_ID));
}
}
|