MySQLJsonBinlogProtocolValue implements MySQLBinlogProtocolValue { @Override public Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload) { return MySQLJsonValueDecoder.decode(payload.getByteBuf().readBytes(readLengthFromMeta(columnDef.getColumnMeta(), payload))); }  @Override Serializable read(final MySQLBinlogColumnDef columnDef, final MySQLPacketPayload payload);  }
@Test public void assertReadJsonValueWithMeta1() { columnDef.setColumnMeta(1); when(byteBuf.readUnsignedByte()).thenReturn((short) 1); when(byteBuf.readBytes(1)).thenReturn(jsonValueByteBuf); assertThat(new MySQLJsonBinlogProtocolValue().read(columnDef, payload), is(EXPECTED_JSON)); }
@Test public void assertReadJsonValueWithMeta2() { columnDef.setColumnMeta(2); when(byteBuf.readUnsignedShortLE()).thenReturn(2); when(byteBuf.readBytes(2)).thenReturn(jsonValueByteBuf); assertThat(new MySQLJsonBinlogProtocolValue().read(columnDef, payload), is(EXPECTED_JSON)); }
@Test public void assertReadJsonValueWithMeta3() { columnDef.setColumnMeta(3); when(byteBuf.readUnsignedMediumLE()).thenReturn(3); when(byteBuf.readBytes(3)).thenReturn(jsonValueByteBuf); assertThat(new MySQLJsonBinlogProtocolValue().read(columnDef, payload), is(EXPECTED_JSON)); }
@Test public void assertReadJsonValueWithMeta4() { columnDef.setColumnMeta(4); when(payload.readInt4()).thenReturn(4); when(byteBuf.readBytes(4)).thenReturn(jsonValueByteBuf); assertThat(new MySQLJsonBinlogProtocolValue().read(columnDef, payload), is(EXPECTED_JSON)); }
@Test(expected = UnsupportedOperationException.class) public void assertReadJsonValueWithIllegalMeta() { columnDef.setColumnMeta(5); new MySQLJsonBinlogProtocolValue().read(columnDef, payload); }