2 * Copyright (c) 2017 Pantheon Technologies s.r.o. 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.openflowplugin.impl.services.sal;
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertTrue;
12 import static org.mockito.Mockito.verify;
14 import org.junit.Test;
15 import org.opendaylight.openflowplugin.api.openflow.device.Xid;
16 import org.opendaylight.openflowplugin.impl.services.ServiceMocking;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.module.config.rev141015.SetConfigInputBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.SwitchConfigFlag;
20 import org.opendaylight.yangtools.yang.common.Uint16;
21 import org.opendaylight.yangtools.yang.common.Uint32;
23 public class SetConfigImplTest extends ServiceMocking {
24 private static final Uint32 DUMMY_XID_VALUE = Uint32.valueOf(150);
25 private static final SwitchConfigFlag DUMMY_FLAG = SwitchConfigFlag.FRAGNORMAL;
26 private static final String DUMMY_FLAG_STR = "FRAGNORMAL";
27 private static final Uint16 DUMMY_MISS_SEARCH_LENGTH = Uint16.valueOf(3000);
29 private SetConfigImpl setConfig;
32 public void testSetConfig() {
33 setConfig = new SetConfigImpl(mockedRequestContextStack, mockedDeviceContext);
34 setConfig.invoke(dummyConfigInput());
35 verify(mockedRequestContextStack).createRequestContext();
39 public void testBuildRequest() {
40 setConfig = new SetConfigImpl(mockedRequestContextStack, mockedDeviceContext);
41 final var request = setConfig.buildRequest(new Xid(DUMMY_XID_VALUE), dummyConfigInput());
43 assertTrue(request instanceof org.opendaylight.yang.gen.v1.urn
44 .opendaylight.openflow.protocol.rev130731.SetConfigInput);
45 org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput setConfigInput
46 = (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput) request;
47 assertEquals(DUMMY_FLAG,setConfigInput.getFlags());
48 assertEquals(DUMMY_MISS_SEARCH_LENGTH, setConfigInput.getMissSendLen());
49 assertEquals(DUMMY_XID_VALUE, setConfigInput.getXid());
52 private static SetConfigInput dummyConfigInput() {
53 return new SetConfigInputBuilder()
54 .setFlag(DUMMY_FLAG_STR)
55 .setMissSearchLength(DUMMY_MISS_SEARCH_LENGTH)