3 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
7 * This program and the accompanying materials are made available under the
9 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
11 * and is available at http://www.eclipse.org/legal/epl-v10.html
14 package org.opendaylight.nemo.user.tenantmanager;
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;
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;
28 * Created by zhangmeng on 2015/11/20.
30 public class AAATest extends TestCase {
32 private TenantManage tenantManage;
33 private UserInstance userInstance;
36 public void setUp() throws Exception {
37 tenantManage = mock(TenantManage.class);
38 aaa = new AAA(tenantManage);
40 userInstance = mock(UserInstance.class);
44 public void testCheckUser() throws Exception {
45 doNothing().when(tenantManage).fetchUsers();
46 when(tenantManage.getUsersList()).thenReturn(null);
47 String acutal = aaa.checkUser(userInstance);
48 String expected = "The user is not exist.";
49 verify(tenantManage).fetchUsers();
50 verify(tenantManage).getUsersList();
51 Assert.assertNotNull(aaa);
52 Assert.assertEquals(expected,acutal);