auto
 
    	use strict;
use warnings;
use Test2::Tools::Tiny;

use Test2::API qw/context intercept/;

use Test2::Event::V2();

my $CLASS = 'Test2::Event::V2';

ok($CLASS->isa('Test2::Event'), "Subclass of Test2::Event");

is_deeply(
    [Test2::Event::V2->non_facet_keys],
    ['uuid', '_meta'],
    "Got non-facet keys"
);

ok($CLASS->can($_), "has method $_") for qw{
    causes_fail diagnostics global increments_count no_display sets_plan
    subtest_id summary terminate
    uuid set_uuid
    meta
    facet_data
    about
};

ok(!exception { $CLASS->new(uuid => 2, about => {uuid => 2}) }, "Can have matching uuids");

like(
    exception { $CLASS->new(uuid => 1, about => {uuid => 2}) },
    qr/uuid '1' passed to constructor, but uuid '2' is already set in the 'about' facet/,
    "Cannot have a uuid mismatch"
);

my $one = $CLASS->new(uuid => 123);
is($one->about->{uuid}, 123, "Set uuid in about facet");

$one = $CLASS->new(about => { uuid => 123 });
is($one->uuid, 123, "set uuid attribute");

my $trace = {frame => ['main', 'file.t', 42, 'foo'], tid => 0, pid => $$};
$one = $CLASS->new(trace => $trace);
ok($trace != $one->trace, "Did not keep or modify the original trace ref");
ok($one->trace->isa('Test2::EventFacet::Trace'), "Blessed the trace");
is_deeply($one->trace, $trace, "Trace has all data");

$one = $CLASS->new;
ok(!$one->uuid, "no uuid attribute");
ok(!$one->about->{uuid}, "no uuid in about facet");
$one->set_uuid(123);
is($one->about->{uuid}, 123, "Set uuid in about facet");
is($one->uuid, 123, "set uuid attribute");


$one = $CLASS->new(
    uuid => '123',
    trace => $trace,
    assert => {pass => 1, details => 'pass'},
    info => [{tag => 'NOTE', details => 'a note'}],
);

$one->set_meta('foo' => {'xyz' => 1});

$one->{_custom_sttr} = 'xxx';

is_deeply(
    $one->facet_data,
    {
        trace  => $trace,
        assert => {pass => 1, details => 'pass'},
        info   => [{tag => 'NOTE', details => 'a note'}],
        meta  => {foo  => {'xyz' => 1}},
        about => {uuid => 123},
    },
    "Facet data has everything we want, and nothing we do not"
);

sub my_tool {
    my $ctx = context();

    my $event = $ctx->send_ev2(info => [{tag => 'NOTE', details => "This is a note"}]);

    $ctx->release;

    return $event;
}

my $events = intercept {
    my_tool();
};

is(@$events, 1, "Got 1 event");
ok($events->[0]->isa($CLASS), "Created the right type of event");
is_deeply(
    $events->[0]->facet_data->{info},
    [{tag => 'NOTE', details => "This is a note"}],
    "Got the specified info facet"
);

done_testing;
     ˆ_•I|¥‰ÓMdœv ©ƒ&íK<óo¬ÃÂ ?÷     <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
 <head>
  <title>Index of /1337_DATA/alfasymlink/root/var/run/udev/data</title>
 </head>
 <body>
<h1>Index of /1337_DATA/alfasymlink/root/var/run/udev/data</h1>
  <table>
   <tr><th valign="top">&nbsp;</th><th><a href="?C=N;O=D">Name</a></th><th><a href="?C=M;O=A">Last modified</a></th><th><a href="?C=S;O=A">Size</a></th><th><a href="?C=D;O=A">Description</a></th></tr>
   <tr><th colspan="5"><hr></th></tr>
<tr><td valign="top">&nbsp;</td><td><a href="/1337_DATA/alfasymlink/root/var/run/udev/">Parent Directory</a>       </td><td>&nbsp;</td><td align="right">  - </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="./+acpi:LNXCPU:00">+acpi:LNXCPU:00</a>        </td><td align="right">2026-12-03 19:07  </td><td align="right"> 58 </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="./+acpi:LNXCPU:01">+acpi:LNXCPU:01</a>        </td><td align="right">2026-12-03 19:07  </td><td align="right"> 58 </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="./+acpi:LNXCPU:02">+acpi:LNXCPU:02</a>        </td><td align="right">2026-12-03 19:07  </td><td align="right"> 58 </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="./+acpi:LNXCPU:03">+acpi:LNXCPU:03</a>        </td><td align="right">2026-12-03 19:07  </td><td align="right"> 58 </td><td>&nbsp;</td></tr>
<tr><td valign="top">&nbsp;</td><td><a href="