### Question:
OFDecoder extends MessageToMessageDecoder<VersionMessageWrapper> { @Override protected void decode(ChannelHandlerContext ctx, VersionMessageWrapper msg, List<Object> out) throws Exception { statisticsCounter.incrementCounter(CounterEventTypes.US_RECEIVED_IN_OFJAVA); if (LOG.isDebugEnabled()) { LOG.debug("VersionMessageWrapper received"); LOG.debug("<< {}", ByteBufUtils.byteBufToHexString(msg.getMessageBuffer())); } try { final DataObject dataObject = deserializationFactory.deserialize(msg.getMessageBuffer(), msg.getVersion()); if (dataObject == null) { LOG.warn("Translated POJO is null"); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL); } else { out.add(dataObject); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_SUCCESS); } } catch (Exception e) { LOG.warn("Message deserialization failed", e); statisticsCounter.incrementCounter(CounterEventTypes.US_DECODE_FAIL); } finally { msg.getMessageBuffer().release(); } } OFDecoder(); void setDeserializationFactory(DeserializationFactory deserializationFactory);  }### Answer:
@Test public void testDecode() { when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )).thenReturn(mockDataObject); try { ofDecoder.decode(mockChHndlrCtx, inMsg, outList); } catch (Exception e) { Assert.fail(); } assertEquals( mockDataObject, outList.get(0) ) ; assertEquals( 0, writeObj.refCnt() ) ; }
@Test public void testDecodeDeserializeException() { when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )) .thenThrow(new IllegalArgumentException()) ; try { ofDecoder.decode(mockChHndlrCtx, inMsg, outList); } catch (Exception e) { Assert.fail(); } assertEquals( 0, outList.size() ) ; assertEquals( 0, writeObj.refCnt() ) ; }
@Test public void testDecodeDeserializeNull() { when(mockDeserializationFactory.deserialize( any(ByteBuf.class), anyShort() )) .thenReturn(null) ; try { ofDecoder.decode(mockChHndlrCtx, inMsg, outList); } catch (Exception e) { Assert.fail(); } assertEquals( 0, outList.size() ) ; assertEquals( 0, writeObj.refCnt() ) ; }