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
9 package org.opendaylight.openflowplugin.impl.services.singlelayer;
11 import static org.junit.Assert.assertEquals;
13 import java.util.Collections;
14 import java.util.concurrent.Future;
15 import org.junit.Test;
16 import org.opendaylight.openflowplugin.impl.services.ServiceMocking;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestInput;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestInputBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.experimenter.mp.message.service.rev151020.SendExperimenterMpRequestOutput;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartReplyBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.multipart.types.rev170112.MultipartRequest;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.OfHeader;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.reply.multipart.reply.body.MultipartReplyExperimenterBuilder;
24 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.experimenter.types.rev151020.multipart.request.multipart.request.body.MultipartRequestExperimenter;
25 import org.opendaylight.yangtools.yang.common.RpcResult;
27 public class SingleLayerExperimenterMultipartServiceTest extends ServiceMocking {
28 private SingleLayerExperimenterMultipartService service;
31 protected void setup() throws Exception {
32 service = new SingleLayerExperimenterMultipartService(
33 mockedRequestContextStack, mockedDeviceContext,
34 mockedExtensionConverterProvider);
38 public void buildRequest() throws Exception {
39 final SendExperimenterMpRequestInput input = new SendExperimenterMpRequestInputBuilder()
40 .setExperimenterMessageOfChoice(mockExperimenter())
43 final OfHeader ofHeader = service.buildRequest(DUMMY_XID, input);
44 assertEquals(MultipartRequest.class, ofHeader.getImplementedInterface());
46 final MultipartRequestExperimenter result = MultipartRequestExperimenter.class.cast(
47 MultipartRequest.class.cast(ofHeader)
48 .getMultipartRequestBody());
50 assertEquals(DummyExperimenter.class, result.getExperimenterMessageOfChoice().getImplementedInterface());
54 public void handleAndReply() throws Exception {
55 mockSuccessfulFuture(Collections.singletonList(new MultipartReplyBuilder()
56 .setMultipartReplyBody(new MultipartReplyExperimenterBuilder()
57 .setExperimenterMessageOfChoice(mockExperimenter())
61 final SendExperimenterMpRequestInput input = new SendExperimenterMpRequestInputBuilder()
62 .setExperimenterMessageOfChoice(mockExperimenter())
65 final Future<RpcResult<SendExperimenterMpRequestOutput>> rpcResultFuture = service
66 .handleAndReply(input);
68 final RpcResult<SendExperimenterMpRequestOutput> sendExperimenterMpRequestOutputRpcResult =
69 rpcResultFuture.get();
71 assertEquals(DummyExperimenter.class, sendExperimenterMpRequestOutputRpcResult
73 .getExperimenterCoreMessageItem()
75 .getExperimenterMessageOfChoice().getImplementedInterface());