Open Kilda Java Documentation
VerificationDispatchCommandTest.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.floodlight.command.flow;
17 
18 import static org.easymock.EasyMock.capture;
19 import static org.easymock.EasyMock.eq;
20 import static org.easymock.EasyMock.expect;
21 import static org.easymock.EasyMock.newCapture;
22 import static org.easymock.EasyMock.replay;
23 import static org.easymock.EasyMock.verify;
24 
33 
34 import org.easymock.Capture;
35 import org.junit.Assert;
36 import org.junit.Test;
37 import org.projectfloodlight.openflow.protocol.ver12.OFFactoryVer12;
38 
39 import java.util.List;
40 import java.util.Optional;
41 
43  @Test
45  Capture<Message> captureMessage = newCapture();
46 
47  expect(destSwitch.getOFFactory()).andReturn(new OFFactoryVer12()).anyTimes();
48  kafkaProducerService.postMessage(eq(Topic.FLOW), capture(captureMessage));
49 
51 
54 
55  List<Optional<Command>> subCommands = subject.produceSubCommands();
56  verify(destSwitch);
57 
58  Assert.assertEquals("Produced sub operations list is not empty", 0, subCommands.size());
59 
60  Message message = captureMessage.getValue();
61  Assert.assertTrue(message instanceof InfoMessage);
62 
63  InfoData rawPayload = ((InfoMessage) message).getData();
64  Assert.assertTrue(rawPayload instanceof UniFlowVerificationResponse);
65  Assert.assertEquals(
67  }
68 }
void postMessage(final String topic, final Message message)
static final String FLOW
Definition: Topic.java:25