Merge "Refactor UserManager"
[nemo.git] / nemo-impl / src / test / java / org / opendaylight / nemo / user / transactionmanager / TransactionBeginTest.java
1 /*
2
3 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
4
5 *
6
7 * This program and the accompanying materials are made available under the
8
9 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
10
11 * and is available at http://www.eclipse.org/legal/epl-v10.html
12
13 */
14 package org.opendaylight.nemo.user.transactionmanager;
15
16 import static org.mockito.Matchers.any;
17 import static org.mockito.Mockito.mock;
18 import static org.mockito.Mockito.verify;
19 import static org.mockito.Mockito.when;
20 import junit.framework.TestCase;
21
22 import org.junit.Assert;
23 import org.junit.Before;
24 import org.junit.Test;
25 import org.opendaylight.nemo.user.tenantmanager.AAA;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserName;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserPassword;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserRoleName;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.BeginTransactionInput;
31
32 /**
33  * Created by zhangmeng on 2015/11/20.
34  */
35 public class TransactionBeginTest extends TestCase {
36     private TransactionBegin transactionBegin;
37     @Before
38     public void setUp() throws Exception {
39         transactionBegin = new TransactionBegin();
40     }
41
42     @Test
43     public void testTransactionbegin() throws Exception {
44         AAA aaa = mock(AAA.class);
45         BeginTransactionInput input = mock(BeginTransactionInput.class);
46         when(aaa.CheckUser(any(UserId.class),any(UserName.class),any(UserPassword.class),any(UserRoleName.class)))
47                 .thenReturn(new String("test"));
48         String flag = transactionBegin.transactionbegin(aaa,input);
49         verify(aaa).CheckUser(any(UserId.class),any(UserName.class),any(UserPassword.class),any(UserRoleName.class));
50         Assert.assertEquals("test",flag);
51     }
52 }