public static void writeFile(byte[] data, String destFilePath, BrokerDesc brokerDesc) throws UserException {
        BrokerWriter writer = new BrokerWriter(destFilePath, brokerDesc);
        try {
            writer.open();
            ByteBuffer byteBuffer = ByteBuffer.wrap(data);
            writer.write(byteBuffer, data.length);
        } finally {
            writer.close();
        }
    }
@Test
    public void testWriteFile(@Mocked TFileBrokerService.Client client, @Mocked GlobalStateMgr globalStateMgr,
                              @Injectable BrokerMgr brokerMgr)
            throws TException, UserException {
        // open writer response
        TBrokerOpenWriterResponse openWriterResponse = new TBrokerOpenWriterResponse();
        TBrokerOperationStatus status = new TBrokerOperationStatus();
        status.statusCode = TBrokerOperationStatusCode.OK;
        openWriterResponse.opStatus = status;
        openWriterResponse.fd = new TBrokerFD(1, 2);
        FsBroker fsBroker = new FsBroker("127.0.0.1", 99999);

        new MockUp<ThriftConnectionPool<TFileBrokerService.Client>>() {
            @Mock
            public TFileBrokerService.Client borrowObject(TNetworkAddress address, int timeoutMs) throws Exception {
                return client;
            }

            @Mock
            public void returnObject(TNetworkAddress address, TFileBrokerService.Client object) {
                return;
            }

            @Mock
            public void invalidateObject(TNetworkAddress address, TFileBrokerService.Client object) {
                return;
            }
        };

        try (MockedStatic<ThriftRPCRequestExecutor> thriftConnectionPoolMockedStatic =
                     Mockito.mockStatic(ThriftRPCRequestExecutor.class)) {
            thriftConnectionPoolMockedStatic.when(()
                            -> ThriftRPCRequestExecutor.call(Mockito.any(), Mockito.any(), Mockito.any()))
                    .thenReturn(openWriterResponse, status);

            BrokerDesc brokerDesc = new BrokerDesc("broker0", Maps.newHashMap());
            byte[] configs = "{'label': 'label0'}".getBytes(StandardCharsets.UTF_8);
            String destFilePath = "hdfs://127.0.0.1:10000/starrocks/jobs/1/label6/9/configs/jobconfig.json";
            try {
                BrokerUtil.writeFile(configs, destFilePath, brokerDesc);
            } catch (Exception e) {
                Assert.fail(e.getMessage());
            }
        }
    }