// Copyright 2025 The NATS Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Mirrors server/jetstream_batching_test.go in the NATS server Go source.
// ALL tests in this file are deferred: they all use createJetStreamClusterExplicit()
// or RunBasicJetStreamServer() and require a running JetStream cluster/server.

using Shouldly;
using ZB.MOM.NatsNet.Server;

namespace ZB.MOM.NatsNet.Server.Tests.JetStream;

/// <summary>
/// Tests for JetStream atomic batch publishing.
/// Mirrors server/jetstream_batching_test.go.
/// All tests are deferred pending JetStream server infrastructure.
/// </summary>
public sealed class JetStreamBatchingTests
{
    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:716
    public void JetStreamAtomicBatchPublish_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:717
    public void JetStreamAtomicBatchPublishEmptyAck_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:718
    public void JetStreamAtomicBatchPublishCommitEob_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:719
    public void JetStreamAtomicBatchPublishLimits_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:720
    public void JetStreamAtomicBatchPublishDedupeNotAllowed_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:721
    public void JetStreamAtomicBatchPublishSourceAndMirror_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:722
    public void JetStreamAtomicBatchPublishCleanup_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:723
    public void JetStreamAtomicBatchPublishConfigOpts_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:724
    public void JetStreamAtomicBatchPublishDenyHeaders_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:725
    public void JetStreamAtomicBatchPublishStageAndCommit_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:726
    public void JetStreamAtomicBatchPublishHighLevelRollback_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:727
    public void JetStreamAtomicBatchPublishExpectedPerSubject_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:728
    public void JetStreamAtomicBatchPublishSingleServerRecovery_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:729
    public void JetStreamAtomicBatchPublishSingleServerRecoveryCommitEob_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:730
    public void JetStreamAtomicBatchPublishEncode_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:731
    public void JetStreamAtomicBatchPublishProposeOne_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:732
    public void JetStreamAtomicBatchPublishProposeMultiple_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:733
    public void JetStreamAtomicBatchPublishProposeOnePartialBatch_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:734
    public void JetStreamAtomicBatchPublishProposeMultiplePartialBatches_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:735
    public void JetStreamAtomicBatchPublishContinuousBatchesStillMoveAppliedUp_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:736
    public void JetStreamAtomicBatchPublishPartiallyAppliedBatchOnRecovery_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:737
    public void JetStreamRollupIsolatedRead_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:738
    public void JetStreamAtomicBatchPublishAdvisories_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:739
    public void JetStreamAtomicBatchPublishExpectedSeq_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:740
    public void JetStreamAtomicBatchPublishPartialBatchInSharedAppendEntry_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:741
    public void JetStreamAtomicBatchPublishRejectPartialBatchOnLeaderChange_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:742
    public void JetStreamAtomicBatchPublishPersistModeAsync_RequiresRunningServer() { }

    [Fact] // T:742
    public void JetStreamAtomicBatchPublishPersistModeAsync_ShouldSucceed()
    {
        var err = JsApiErrors.NewJSStreamInvalidConfigError(
            new InvalidOperationException("async persist mode is not supported with atomic batch publish"));

        err.Code.ShouldBe(JsApiErrors.StreamInvalidConfig.Code);
        err.ErrCode.ShouldBe(JsApiErrors.StreamInvalidConfig.ErrCode);
        err.Description.ShouldBe("async persist mode is not supported with atomic batch publish");
    }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:743
    public void JetStreamAtomicBatchPublishExpectedLastSubjectSequence_RequiresRunningServer() { }

    [Fact(Skip = "deferred: requires running JetStream cluster")] // T:744
    public void JetStreamAtomicBatchPublishCommitUnsupported_RequiresRunningServer() { }
}
