boolean isWriteShareGroupStateSuccessful(List<PersisterStateBatch> stateBatches) {
        WriteShareGroupStateResult response;
        try {
            response = persister.writeState(new WriteShareGroupStateParameters.Builder()
                .setGroupTopicPartitionData(new GroupTopicPartitionData.Builder<PartitionStateBatchData>()
                    .setGroupId(this.groupId)
                    .setTopicsData(Collections.singletonList(new TopicData<>(topicIdPartition.topicId(),
                        Collections.singletonList(PartitionFactory.newPartitionStateBatchData(
                            topicIdPartition.partition(), stateEpoch, startOffset, 0, stateBatches))))
                    ).build()).build()).get();
        } catch (InterruptedException | ExecutionException e) {
            log.error("Failed to write the share group state for share partition: {}-{}", groupId, topicIdPartition, e);
            throw new IllegalStateException(String.format("Failed to write the share group state for share partition %s-%s",
                groupId, topicIdPartition), e);
        }

        if (response == null || response.topicsData() == null || response.topicsData().size() != 1) {
            log.error("Failed to write the share group state for share partition: {}-{}. Invalid state found: {}",
                groupId, topicIdPartition, response);
            throw new IllegalStateException(String.format("Failed to write the share group state for share partition %s-%s",
                groupId, topicIdPartition));
        }

        TopicData<PartitionErrorData> state = response.topicsData().get(0);
        if (state.topicId() != topicIdPartition.topicId() || state.partitions().size() != 1
            || state.partitions().get(0).partition() != topicIdPartition.partition()) {
            log.error("Failed to write the share group state for share partition: {}-{}. Invalid topic partition response: {}",
                groupId, topicIdPartition, response);
            throw new IllegalStateException(String.format("Failed to write the share group state for share partition %s-%s",
                groupId, topicIdPartition));
        }

        PartitionErrorData partitionData = state.partitions().get(0);
        if (partitionData.errorCode() != Errors.NONE.code()) {
            Exception exception = Errors.forCode(partitionData.errorCode()).exception(partitionData.errorMessage());
            log.error("Failed to write the share group state for share partition: {}-{} due to exception",
                groupId, topicIdPartition, exception);
            return false;
        }
        return true;
    }
@Test
    public void testIsWriteShareGroupStateSuccessful() {
        Persister persister = Mockito.mock(Persister.class);
        mockPersisterReadStateMethod(persister);
        SharePartition sharePartition = SharePartitionBuilder.builder().withPersister(persister).build();

        WriteShareGroupStateResult writeShareGroupStateResult = Mockito.mock(WriteShareGroupStateResult.class);
        Mockito.when(writeShareGroupStateResult.topicsData()).thenReturn(Collections.singletonList(
                new TopicData<>(TOPIC_ID_PARTITION.topicId(), Collections.singletonList(
                        PartitionFactory.newPartitionErrorData(0, Errors.NONE.code(), Errors.NONE.message())))));
        Mockito.when(persister.writeState(Mockito.any())).thenReturn(CompletableFuture.completedFuture(writeShareGroupStateResult));

        assertTrue(sharePartition.isWriteShareGroupStateSuccessful(Mockito.anyList()));
    }