@Override
    public void write(DataOutput out) throws IOException {
        String json = GsonUtils.GSON.toJson(this, OptimizeJobV2.class);
        Text.writeString(out, json);
    }
@Test
    public void testSerializeOfOptimizeJob() throws IOException {
        // prepare file
        File file = new File(TEST_FILE_NAME);
        file.createNewFile();
        file.deleteOnExit();
        DataOutputStream out = new DataOutputStream(new FileOutputStream(file));

        OptimizeJobV2 optimizeJobV2 = new OptimizeJobV2(1, 1, 1, "test", 600000);
        Deencapsulation.setField(optimizeJobV2, "jobState", AlterJobV2.JobState.FINISHED);

        // write schema change job
        optimizeJobV2.write(out);
        out.flush();
        out.close();

        DataInputStream in = new DataInputStream(new FileInputStream(file));
        OptimizeJobV2 result = (OptimizeJobV2) AlterJobV2.read(in);
        Assert.assertEquals(1, result.getJobId());
        Assert.assertEquals(AlterJobV2.JobState.FINISHED, result.getJobState());
    }