package com.graphtest;

import com.graphtest.model.NodeStatus;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;

import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.assertj.core.api.Assertions.*;

@DisplayName("Case 2: File chỉ có comments")
class Case2_CommentOnlyTest {

    private CodeGraph graph;

    @BeforeEach
    void setUp() throws Exception {
        URL resource = getClass().getClassLoader().getResource("fixtures/case2_comment_only");
        Path dir = Paths.get(resource.toURI());
        graph = new GraphBuilder().buildFromDirectory(dir);
    }

    @Test
    @DisplayName("Node phải được tạo cho file chỉ có comment")
    void nodeShouldExist() {
        assertThat(graph.hasNode("CommentOnlyFile")).isTrue();
    }

    @Test
    @DisplayName("Node phải có status COMMENT_ONLY")
    void nodeShouldHaveCommentOnlyStatus() {
        assertThat(graph.getNode("CommentOnlyFile").getStatus()).isEqualTo(NodeStatus.COMMENT_ONLY);
    }

    @Test
    @DisplayName("File chỉ có comment không có outgoing edges")
    void shouldHaveNoOutgoingEdges() {
        assertThat(graph.getOutgoingEdges("CommentOnlyFile")).isEmpty();
    }

    @Test
    @DisplayName("File chỉ có comment không gây ra build error")
    void shouldNotCauseBuildError() {
        assertThat(graph.getBuildErrors()).isEmpty();
    }

    @Test
    @DisplayName("Phân biệt được COMMENT_ONLY và EMPTY")
    void commentOnlyShouldBeDifferentFromEmpty() {
        assertThat(graph.getNode("CommentOnlyFile").getStatus())
            .isNotEqualTo(NodeStatus.EMPTY)
            .isEqualTo(NodeStatus.COMMENT_ONLY);
    }
}
