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 org.opendaylight.nemo.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;
31 public void setUp() throws Exception {
32 tenantManage = mock(TenantManage.class);
33 aaa = new AAA(tenantManage);
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>();
42 when(tenantManage.getUsers())
45 Assert.assertTrue(aaa.checkUser(userId).equals("The user is not exist."));
46 verify(tenantManage).getUsers();
48 users.put(userId, user);
49 Assert.assertTrue(users != null);
50 Assert.assertTrue(aaa.checkUser(userId) == null);
51 verify(tenantManage,times(2)).getUsers();