package platformadapter

import (
	"testing"
)

func TestNewAPIAdapter_BuildIngressAck_NilMeta(t *testing.T) {
	adapter := NewNewAPIAdapter()
	result := adapter.BuildIngressAck(nil, nil)
	m, ok := result.(map[string]any)
	if !ok {
		t.Fatalf("expected map[string]any, got %T", result)
	}
	if m["accepted"] != false {
		t.Fatalf("accepted = %v, want false", m["accepted"])
	}
	if m["platform"] != "newapi" {
		t.Fatalf("platform = %v, want newapi", m["platform"])
	}
	if _, exists := m["event_id"]; exists {
		t.Fatalf("event_id should not exist when meta is nil")
	}
}

func TestNewAPIAdapter_BuildIngressAck_WithMeta(t *testing.T) {
	adapter := NewNewAPIAdapter()
	meta := &PlatformInboundMeta{EventID: "evt-1"}
	result := adapter.BuildIngressAck(nil, meta)
	m, ok := result.(map[string]any)
	if !ok {
		t.Fatalf("expected map[string]any, got %T", result)
	}
	if m["accepted"] != false {
		t.Fatalf("accepted = %v, want false", m["accepted"])
	}
	if m["platform"] != "newapi" {
		t.Fatalf("platform = %v, want newapi", m["platform"])
	}
	if m["event_id"] != "evt-1" {
		t.Fatalf("event_id = %v, want evt-1", m["event_id"])
	}
}
