/**
* openflowplugin-api
* org.opendaylight.openflowplugin.impl.openflow.device
- * <p/>
- * Test class for testing basic method functionality for {@link MultiMsgCollector}
+ * Test class for testing basic method functionality for {@link MultiMsgCollector}.
*
* @author <a href="mailto:vdemcak@cisco.com">Vaclav Demcak</a>
* @author <a href="mailto:tkubas@cisco.com">Timotej Kubas</a>
- * <p/>
- * Created: Mar 23, 2015
+ *
*/
@RunWith(MockitoJUnitRunner.class)
public class MultiMsgCollectorImplTest {
- private MultiMsgCollectorImpl collector;
+ private MultiMsgCollectorImpl<MultipartReply> collector;
private Runnable cleanUpCheck;
@Mock
@Before
public void setUp() {
- collector = new MultiMsgCollectorImpl(deviceProcessor, requestContext);
+ collector = new MultiMsgCollectorImpl<>(deviceProcessor, requestContext);
cleanUpCheck = Runnables.doNothing();
Mockito.when(requestContext.getXid()).thenReturn(new Xid(xid));
}
}
/**
- * test of ${link MultiMsgCollector#addMultipartMsg} <br>
- * success with message consisting of 1 part
+ * Test of ${link MultiMsgCollector#addMultipartMsg}
+ * success with message consisting of 1 part.
*/
@Test
public void testAddMultipartMsgOne() {
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, false).build(), false, null);
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
}
/**
- * test of ${link MultiMsgCollector#addMultipartMsg} <br>
- * success with message consisting of 2 parts
+ * Test of ${link MultiMsgCollector#addMultipartMsg}
+ * success with message consisting of 2 parts.
*/
@Test
public void testAddMultipartMsgTwo() {
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, true).build(), true, null);
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, false).build(), false, null);
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
}
/**
- * test of ${link MultiMsgCollector#addMultipartMsg} <br>
- * xid not registered before message
+ * Test of ${link MultiMsgCollector#addMultipartMsg}
+ * xid not registered before message.
*/
- @Test(expected=IllegalArgumentException.class)
+ @Test(expected = IllegalArgumentException.class)
public void testAddMultipartMsgNotExpectedXid() {
final Long dif_xid = 5L;
- final MultipartReplyMessage mrMsg = MsgGeneratorTestUtils.makeMultipartDescReply(dif_xid, hwTestValue, true).build();
- collector.addMultipartMsg(mrMsg);
+ final MultipartReplyMessage mrMsg = MsgGeneratorTestUtils
+ .makeMultipartDescReply(dif_xid, hwTestValue, true).build();
+ collector.addMultipartMsg(mrMsg, true, null);
}
/**
- * test of ${link MultiMsgCollector#addMultipartMsg} <br>
- * message types are inconsistent - second message is final and should be rejected
+ * Test of ${link MultiMsgCollector#addMultipartMsg}
+ * message types are inconsistent - second message is final and should be rejected.
*/
@Test
public void testAddMultipartMsgWrongType1() {
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, true).build(), true, null);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false)
- .setType(MultipartType.OFPMPPORTDESC).build());
+ .setType(MultipartType.OFPMPPORTDESC).build(), false, null);
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());
Mockito.reset(deviceProcessor);
- cleanUpCheck = new Runnable() {
- @Override
- public void run() {
- Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
- .processReply(xidCaptor.capture(), mmCaptor.capture());
- Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- }
+ cleanUpCheck = () -> {
+ Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
+ .processReply(xidCaptor.capture(), mmCaptor.capture());
+ Assert.assertEquals(xid, xidCaptor.getValue().getValue());
};
}
/**
- * test of ${link MultiMsgCollector#addMultipartMsg} <br>
- * message types are inconsistent - second message is not final and should be rejected
+ * Test of ${link MultiMsgCollector#addMultipartMsg}
+ * message types are inconsistent - second message is not final and should be rejected.
*/
@Test
public void testAddMultipartMsgWrongType2() {
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, true).build(), true, null);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true)
- .setType(MultipartType.OFPMPPORTDESC).build());
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
+ .setType(MultipartType.OFPMPPORTDESC).build(), true, null);
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, false).build(), false, null);
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Mockito.reset(deviceProcessor);
- cleanUpCheck = new Runnable() {
- @Override
- public void run() {
- Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
- .processReply(xidCaptor.capture(), mmCaptor.capture());
- Assert.assertEquals(xid, xidCaptor.getValue().getValue());
- }
+ cleanUpCheck = () -> {
+ Mockito.verify(deviceProcessor, VerificationModeFactory.noMoreInteractions())
+ .processReply(xidCaptor.capture(), mmCaptor.capture());
+ Assert.assertEquals(xid, xidCaptor.getValue().getValue());
};
}
/**
- * test of ${link MultiMsgCollector#addMultipartMsg} <br>
- * message types are inconsistent - second message and third should be rejected
+ * Test of ${link MultiMsgCollector#addMultipartMsg}
+ * message types are inconsistent - second message and third should be rejected.
*/
@Test
public void testAddMultipartMsgWrongType3() {
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true).build());
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, true).build(), true, null);
collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, true)
- .setType(MultipartType.OFPMPPORTDESC).build());
- collector.addMultipartMsg(MsgGeneratorTestUtils.makeMultipartDescReply(xid, hwTestValue, false).build());
+ .setType(MultipartType.OFPMPPORTDESC).build(), true, null);
+ collector.addMultipartMsg(MsgGeneratorTestUtils
+ .makeMultipartDescReply(xid, hwTestValue, false).build(), false, null);
Mockito.verify(deviceProcessor).processReply(xidCaptor.capture(), mmCaptor.capture());
Assert.assertEquals(xid, xidCaptor.getValue().getValue());