2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
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
8 package user.tenantmanager;
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;
21 import static org.junit.Assert.*;
22 import static org.mockito.Mockito.*;
24 * Created by zhangmeng on 2015/12/15.
26 public class AAATest extends TestCase {
27 private TenantManage tenantManage;
30 public void setUp() throws Exception {
31 tenantManage = mock(TenantManage.class);
32 aaa = new AAA(tenantManage);
36 public void testCheckUser() throws Exception {
37 UserId userId = mock(UserId.class);
38 User user = mock(User.class);
39 Map<UserId, User> users = new HashMap<UserId, User>();
41 when(tenantManage.getUsers())
44 Assert.assertTrue(aaa.checkUser(userId).equals("The user is not exist."));
45 verify(tenantManage).getUsers();
47 users.put(userId, user);
48 Assert.assertTrue(users != null);
49 Assert.assertTrue(aaa.checkUser(userId) == null);
50 verify(tenantManage,times(2)).getUsers();