Refactor and fix TenantManage for repeated queries
[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.mock;
17 import static org.mockito.Mockito.verify;
18 import static org.mockito.Mockito.when;
19
20 import java.util.HashMap;
21
22 import junit.framework.TestCase;
23
24 import org.junit.Assert;
25 import org.junit.Before;
26 import org.junit.Test;
27 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User;
29 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.user.rev151010.UserInstance;
30
31 /**
32  * Created by zhangmeng on 2015/11/20.
33  */
34 public class AAATest extends TestCase {
35     private AAA aaa;
36     private TenantManage tenantManage;
37     private UserInstance userInstance;
38
39     @Override
40     @Before
41     public void setUp() throws Exception {
42         tenantManage = mock(TenantManage.class);
43         aaa = new AAA(tenantManage);
44
45         userInstance = mock(UserInstance.class);
46     }
47
48     @Test
49     public void testCheckUser() throws Exception {
50         when(tenantManage.getUsers()).thenReturn(new HashMap<UserId, User>());
51         String acutal = aaa.checkUser(userInstance);
52         String expected = "The user is not exist.";
53         verify(tenantManage).getUsers();
54         Assert.assertNotNull(aaa);
55         Assert.assertEquals(expected,acutal);
56     }
57 }