public void testMetricsSize() {
    byte[] data = new byte[ClusterMetricsSnapshot.METRICS_SIZE];

    // Test serialization.
    int off = ClusterMetricsSnapshot.serialize(data, 0, createMetrics());

    assert off == ClusterMetricsSnapshot.METRICS_SIZE;

    // Test deserialization.
    ClusterMetrics res = ClusterMetricsSnapshot.deserialize(data, 0);

    assert res != null;
  }
  public void testSerialization() {
    byte[] data = new byte[ClusterMetricsSnapshot.METRICS_SIZE];

    ClusterMetrics metrics1 = createMetrics();

    // Test serialization.
    int off = ClusterMetricsSnapshot.serialize(data, 0, metrics1);

    assert off == ClusterMetricsSnapshot.METRICS_SIZE;

    // Test deserialization.
    ClusterMetrics metrics2 = ClusterMetricsSnapshot.deserialize(data, 0);

    assert metrics2 != null;

    assert isMetricsEquals(metrics1, metrics2);
  }