24f50ac385ad35da9ab550ed53440ead1ae1653b
[nemo.git] / nemo-impl / src / test / java / org / opendaylight / nemo / user / tenantmanager / AAATest.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.tenantmanager;
15
16 import static org.mockito.Mockito.doNothing;
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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.user.rev151010.UserInstance;
26
27 /**
28  * Created by zhangmeng on 2015/11/20.
29  */
30 public class AAATest extends TestCase {
31     private AAA aaa;
32     private TenantManage tenantManage;
33     private UserInstance userInstance;
34
35     @Override
36     @Before
37     public void setUp() throws Exception {
38         tenantManage = mock(TenantManage.class);
39         aaa = new AAA(tenantManage);
40
41         userInstance = mock(UserInstance.class);
42     }
43
44     @Test
45     public void testCheckUser() throws Exception {
46         doNothing().when(tenantManage).fetchUsers();
47         when(tenantManage.getUsersList()).thenReturn(null);
48         String acutal = aaa.checkUser(userInstance);
49         String expected = "The user is not exist.";
50         verify(tenantManage).fetchUsers();
51         verify(tenantManage).getUsers();
52         Assert.assertNotNull(aaa);
53         Assert.assertEquals(expected,acutal);
54     }
55 }