Files
ai-engineering/src/test/java/net/intrepid/aiengineering/DiscussionTextFileTest.java
T
Nilton Constantino e7e8d95415
Test / Tests and coverage occurred while executing withChecks step.
Intrepid/AI Engineering/pipeline/head There was a failure building this commit
build / jvm (push) Canceled after 0s
build / native (macos-15, macos-arm64) (push) Canceled after 0s
build / native (ubuntu-24.04, linux-x86_64) (push) Canceled after 0s
build / native (windows-2025, windows-x86_64) (push) Canceled after 0s
feat: add Work guidance and adaptive Plan experiments
Persist explicit human discussion choices, DEC requests and approval policies. Add optional evidence-backed Plan experiments and align context, adapters and next actions under protocol contract 3.

Include WRK-000B decisions, plan history and verification evidence: 167 JVM tests, 25 focused checks, Jenkins fixtures and native smoke coverage.
2026-11-16 17:33:24 +00:00

54 lines
3.5 KiB
Java

package net.intrepid.aiengineering;
import net.intrepid.aiengineering.cli.EngineeringCli;
import net.intrepid.aiengineering.discussion.DiscussionService;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import java.io.*;
import java.nio.file.*;
import java.util.List;
import static org.assertj.core.api.Assertions.*;
class DiscussionTextFileTest {
@TempDir Path root;
@TempDir Path drafts;
private String output;
private int cli(Path cwd, String... args) {
var out = new StringWriter(); var err = new StringWriter();
int code = new EngineeringCli(cwd).execute(new PrintWriter(out), new PrintWriter(err), args);
output = out + err.toString(); return code;
}
private void ok(String... args) { int code = cli(root, args); assertThat(code).as(output).isZero(); }
private void initialize() { ok("init", "--name", "Test"); ok("work", "create", "--mode", "DIRECT", "--approval", "WAIVED", "--human-approved", "--choice-reason", "Explicit synthetic fixture policy", "One"); }
@Test void importsExactUtf8TextRelativeToInvocationDirectoryAndPersistsIndependently() throws Exception {
initialize(); ok("discussion", "add", "WRK-0001", "--kind", "QUESTION", "--text", "Which approach?");
String prose = "\n## Proposta — árvore 日本語\r\n\r\n- First limit\n- Second limit\n\n```yaml\n---\nkey: value\n```\n";
Path file = Files.writeString(drafts.resolve("proposal.md"), prose);
assertThat(cli(drafts, "--project", root.toString(), "discussion", "add", "WRK-0001", "--text-file", "proposal.md",
"--author", "agent", "--kind", "SUGGESTION", "--responds-to", "DSC-0001")).as(output).isZero();
assertThat(output).contains("documentVersion: 2", prose);
var entries = new DiscussionService().list(root, "WRK-0001");
assertThat(entries).hasSize(2); assertThat(entries.getLast().text()).isEqualTo(prose);
assertThat(entries.getLast().author()).isEqualTo("agent"); assertThat(entries.getLast().respondsTo()).isEqualTo("DSC-0001");
assertThat(Files.readString(file)).isEqualTo(prose); Files.delete(file);
ok("work", "context", "WRK-0001"); assertThat(output).contains(prose);
ok("project", "validate");
}
@Test void requiresExactlyOneTextSourceAndDoesNotAppendOnFailure() throws Exception {
initialize(); Path file = Files.writeString(drafts.resolve("proposal.md"), "Proposal");
assertThat(cli(root, "discussion", "add", "WRK-0001")).isEqualTo(2);
assertThat(cli(root, "discussion", "add", "WRK-0001", "--text", "Inline", "--text-file", file.toString())).isEqualTo(2);
assertThat(new DiscussionService().list(root, "WRK-0001")).isEmpty();
}
@Test void missingInvalidEmptyAndOversizedSourcesProduceUsefulFailures() throws Exception {
initialize(); Path malformed = Files.write(drafts.resolve("malformed.md"), new byte[]{(byte) 0xc3, 0x28});
Path empty = Files.writeString(drafts.resolve("empty.md"), " \n\t");
Path large = Files.write(drafts.resolve("large.md"), new byte[1024 * 1024 + 1]);
assertThat(cli(root, "discussion", "add", "WRK-0001", "--text-file", drafts.resolve("missing.md").toString())).isEqualTo(3);
assertThat(output).contains("missing.md");
for (Path input : List.of(drafts, malformed, empty, large))
assertThat(cli(root, "discussion", "add", "WRK-0001", "--text-file", input.toString())).as(output).isEqualTo(2);
assertThat(new DiscussionService().list(root, "WRK-0001")).isEmpty();
}
}