Migrate openflowplugim-impl tests to uint types
[openflowplugin.git] / openflowplugin-impl / src / test / java / org / opendaylight / openflowplugin / impl / protocol / serialization / InstructionSerializerInjectorTest.java
1 /*
2  * Copyright (c) 2016 Pantheon Technologies s.r.o. and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.openflowplugin.impl.protocol.serialization;
10
11 import static org.mockito.Mockito.verify;
12
13 import java.util.function.Consumer;
14 import java.util.function.Function;
15 import org.junit.Before;
16 import org.junit.Test;
17 import org.junit.runner.RunWith;
18 import org.mockito.Mock;
19 import org.mockito.junit.MockitoJUnitRunner;
20 import org.opendaylight.openflowjava.protocol.api.extensibility.OFSerializer;
21 import org.opendaylight.openflowjava.protocol.api.keys.MessageTypeKey;
22 import org.opendaylight.openflowjava.protocol.api.util.EncodeConstants;
23 import org.opendaylight.openflowjava.protocol.spi.connection.SwitchConnectionProvider;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.Instruction;
25 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
26
27 @RunWith(MockitoJUnitRunner.class)
28 public class InstructionSerializerInjectorTest {
29
30     @Mock
31     private SwitchConnectionProvider switchConnectionProvider;
32
33     @Mock
34     private OFSerializer<Instruction> instructionSerializer;
35
36     private Function<Class<? extends Instruction>, Consumer<OFSerializer<? extends Instruction>>> injector;
37
38     @Before
39     public void setUp() {
40         injector =
41                 InstructionSerializerInjector.createInjector(switchConnectionProvider, EncodeConstants.OF13_VERSION_ID);
42     }
43
44     @Test
45     public void injectSerializers() {
46         injector.apply(ApplyActionsCase.class).accept(instructionSerializer);
47         verify(switchConnectionProvider).registerSerializer(
48                 new MessageTypeKey<>(EncodeConstants.OF13_VERSION_ID, ApplyActionsCase.class),
49                 instructionSerializer);
50     }
51
52 }