MySQLCommandPacketTypeLoader { public static MySQLCommandPacketType getCommandPacketType(final MySQLPacketPayload payload) { Preconditions.checkArgument(0 == payload.readInt1(), "Sequence ID of MySQL command packet must be `0`."); return MySQLCommandPacketType.valueOf(payload.readInt1()); }  static MySQLCommandPacketType getCommandPacketType(final MySQLPacketPayload payload);  }
@Test public void assertGetCommandPacketType() { MySQLPacketPayload payload = mock(MySQLPacketPayload.class); when(payload.readInt1()).thenReturn(0, MySQLCommandPacketType.COM_QUIT.getValue()); assertThat(MySQLCommandPacketTypeLoader.getCommandPacketType(payload), is(MySQLCommandPacketType.COM_QUIT)); }
@Test(expected = IllegalArgumentException.class) public void assertGetCommandPacketTypeError() { MySQLPacketPayload payload = mock(MySQLPacketPayload.class); when(payload.readInt1()).thenReturn(0, 0x21); MySQLCommandPacketTypeLoader.getCommandPacketType(payload); }