2 * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.
\r
4 * This program and the accompanying materials are made available under the
\r
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
\r
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
\r
8 package org.opendaylight.nemo.user.vnspacemanager.languagestyle.deleteintentlang;
\r
10 import junit.framework.TestCase;
\r
11 import org.junit.Assert;
\r
12 import org.junit.Before;
\r
13 import org.junit.Test;
\r
14 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
\r
15 import org.opendaylight.nemo.user.tenantmanager.TenantManage;
\r
16 import org.opendaylight.nemo.user.vnspacemanager.structurestyle.deleteintent.DeleteFlow;
\r
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.FlowId;
\r
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nemo.common.rev151010.UserId;
\r
20 import java.lang.reflect.Field;
\r
22 import static org.mockito.Mockito.*;
\r
24 * Created by zhangmeng on 2015/12/28.
\r
26 public class DeleteFlowLangTest extends TestCase {
\r
27 private DataBroker dataBroker;
\r
28 private TenantManage tenantManage;
\r
29 private DeleteFlowLang deleteFlowLang;
\r
31 public void setUp() throws Exception {
\r
32 dataBroker = mock(DataBroker.class);
\r
33 tenantManage = mock(TenantManage.class);
\r
35 deleteFlowLang = new DeleteFlowLang(dataBroker,tenantManage);
\r
39 public void testDeleteFlowHandling() throws Exception {
\r
40 Class<DeleteFlowLang> class1 = DeleteFlowLang.class;
\r
41 Field field = class1.getDeclaredField("deleteFlow");
\r
42 field.setAccessible(true);
\r
44 UserId userId = mock(UserId.class);
\r
45 String flowname = new String("test");
\r
46 DeleteFlow deleteFlow = mock(DeleteFlow.class);
\r
48 when(tenantManage.getObjectId(userId,flowname))
\r
50 .thenReturn("00001111-0000-0000-0000-000011112222");
\r
52 Assert.assertTrue(deleteFlowLang.DeleteFlowHandling(userId, flowname).equals("The flow " + flowname + " is not exist."));
\r
54 field.set(deleteFlowLang, deleteFlow);
\r
55 when(deleteFlow.DeleteFlowHandling(any(UserId.class),any(FlowId.class))).thenReturn(new String("test"));
\r
56 Assert.assertTrue(deleteFlowLang.DeleteFlowHandling(userId, flowname).equals("test"));
\r