2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package user.transactionmanager;
\r
10 import junit.framework.TestCase;
\r
11 import org.junit.Assert;
\r
12 import org.junit.Before;
\r
13 import org.junit.Test;
\r
14 import org.opendaylight.nemo.user.tenantmanager.AAA;
\r
15 import org.opendaylight.nemo.user.transactionmanager.TransactionBegin;
\r
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.BeginTransactionInput;
\r
17 import static org.junit.Assert.*;
\r
18 import static org.mockito.Mockito.*;
\r
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
\r
21 * Created by zhangmeng on 2015/12/15.
\r
23 public class TransactionBeginTest extends TestCase {
\r
25 private BeginTransactionInput input;
\r
26 private TransactionBegin transactionBegin;
\r
28 public void setUp() throws Exception {
\r
29 aaa = mock(AAA.class);
\r
30 input = mock(BeginTransactionInput.class);
\r
32 transactionBegin = new TransactionBegin();
\r
36 public void testTransactionbegin() throws Exception {
\r
38 UserId userId = mock(UserId.class);
\r
40 when(aaa.checkUser(any(UserId.class))).thenReturn(new String("test"));
\r
41 when(input.getUserId()).thenReturn(userId);
\r
43 result = transactionBegin.transactionbegin(aaa,input);
\r
44 Assert.assertTrue(result.equals("test"));
\r