Fix incorrect package names
[nemo.git] / nemo-impl / src / test / java / org / opendaylight / nemo / user / tenantmanager / AAATest.java
1 /*
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.nemo.user.tenantmanager;
9
10 import junit.framework.TestCase;
11 import org.junit.Assert;
12 import org.junit.Before;
13 import org.junit.Test;
14 import org.opendaylight.nemo.user.tenantmanager.AAA;
15 import org.opendaylight.nemo.user.tenantmanager.TenantManage;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.intent.rev151010.users.User;
18 import java.util.HashMap;
19 import java.util.Map;
20
21 import static org.junit.Assert.*;
22 import static org.mockito.Mockito.*;
23 /**
24  * Created by zhangmeng on 2015/12/15.
25  */
26 public class AAATest extends TestCase {
27     private TenantManage tenantManage;
28     private AAA aaa;
29     @Override
30     @Before
31     public void setUp() throws Exception {
32         tenantManage = mock(TenantManage.class);
33         aaa = new AAA(tenantManage);
34     }
35
36     @Test
37     public void testCheckUser() throws Exception {
38         UserId userId = mock(UserId.class);
39         User user = mock(User.class);
40         Map<UserId, User> users = new HashMap<UserId, User>();
41
42         when(tenantManage.getUsers())
43                 .thenReturn(null)
44                 .thenReturn(users);
45         Assert.assertTrue(aaa.checkUser(userId).equals("The user is not exist."));
46         verify(tenantManage).getUsers();
47
48         users.put(userId, user);
49         Assert.assertTrue(users != null);
50         Assert.assertTrue(aaa.checkUser(userId) == null);
51         verify(tenantManage,times(2)).getUsers();
52     }
53 }