### Question:
ExperimenterInputMessageFactory implements OFSerializer<ExperimenterOfMessage>,
        SerializerRegistryInjector { @Override public void serialize(ExperimenterOfMessage message, ByteBuf outBuffer) { long expId = message.getExperimenter().getValue(); OFSerializer<ExperimenterDataOfChoice> serializer = registry.getSerializer( ExperimenterSerializerKeyFactory.createExperimenterMessageSerializerKey( EncodeConstants.OF13_VERSION_ID, expId, message.getExpType().longValue())); ByteBufUtils.writeOFHeader(MESSAGE_TYPE, message, outBuffer, EncodeConstants.EMPTY_LENGTH); outBuffer.writeInt(message.getExperimenter().getValue().intValue()); outBuffer.writeInt(message.getExpType().intValue()); serializer.serialize(message.getExperimenterDataOfChoice(), outBuffer); ByteBufUtils.updateOFHeaderLength(outBuffer); }  @Override void serialize(ExperimenterOfMessage message, ByteBuf outBuffer); @Override void injectSerializerRegistry(SerializerRegistry serializerRegistry);  }### Answer:
@Test(expected=IllegalStateException.class) public void testV10Real() throws Exception { startUp(true); ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); builder.setExpType(21L); builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); expFactory.serialize(input, out); }
@Test(expected=IllegalStateException.class) public void testV13Real() throws Exception { startUp(true); ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); builder.setExpType(22L); builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); expFactory.serialize(input, out); }
@Test public void testV10() throws Exception { startUp(false); ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); builder.setExpType(21L); builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); Mockito.when(registry.getSerializer( (ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer); expFactory.serialize(input, out); Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out); }
@Test public void testV13() throws Exception { startUp(false); ExperimenterInputBuilder builder = new ExperimenterInputBuilder(); BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID); builder.setExperimenter(new ExperimenterId(42L)); builder.setExpType(21L); builder.setExperimenterDataOfChoice(vendorData); ExperimenterInput input = builder.build(); Mockito.when(registry.getSerializer( (ExperimenterIdSerializerKey<?>) Matchers.any())).thenReturn(serializer); expFactory.serialize(input, out); Mockito.verify(serializer, Mockito.times(1)).serialize(input.getExperimenterDataOfChoice(), out); }