# Getting Started

## What This Project Does

This project provides test data for a pipeline that generates dependency graphs and wiki documentation from Java codebases. It exercises a variety of reflection, dependency injection, and utility patterns so the analysis pipeline can be tested against realistic code scenarios — including edge cases like false positives from non-reflection factory APIs.

## Recommended Reading Order

1. **[README.md](../README.md)** — Project overview and pattern catalog
2. **`App.java`** — The single entry point; demonstrates every submodule in order
3. **`reflection/`** — Core test data: reflection patterns the pipeline must detect
4. **`di/`** — Dependency injection patterns using CDI annotations
5. **[pom.xml](../pom.xml)** — Build configuration

## Key Entry Points

- **[App.java](../src/main/java/com/optage/testdata/App.java)** — The `main` method that orchestrates all examples. Start here to understand what the project exercises.
- **[BillingService.java](../src/main/java/com/optage/testdata/di/BillingService.java)** — Interface used to test `@Inject` edge detection in the DI analyzer.
- **[ReflectTarget.java](../src/main/java/com/optage/testdata/targets/ReflectTarget.java)** — A simple class referenced by reflection patterns; the target the pipeline resolves to.

## Project Structure

```
src/main/java/com/optage/testdata/
  ├── App.java                          -- Main entry point
  ├── di/                               -- Dependency injection patterns
  │   ├── BillingService.java           -- Interface for @Inject testing
  │   ├── BillingServiceImpl.java       -- Implementation
  │   └── StatelessBeanExample.java     -- @Stateless bean with @Inject field
  ├── reflection/                       -- Reflection patterns (core test data)
  │   ├── DispatchFrameworkInvoke.java  -- Indirect reflection via utility stub
  │   ├── ReflectionForNameConstant.java -- Class.forName(String constant)
  │   ├── ReflectionForNameLiteral.java  -- Class.forName("literal")
  │   ├── ReflectionInvokeConstant.java  -- getDeclaredMethod + invoke
  │   └── XmlFactoryFalsePositive.java   -- Non-reflection factory (should be skipped)
  ├── targets/                          -- Reflection targets
  │   ├── EmailRule.java                -- Stub target class
  │   ├── ReflectTarget.java            -- Primary reflection target
  │   └── SmsRule.java                  -- Stub target class
  └── util/
      └── JBSbatCheckUtil.java          -- Utility stub used by DispatchFrameworkInvoke
```

### How the Modules Relate

```mermaid
flowchart TD
    A["App<br/>(entry point)"] --> B["Reflection examples"]
    A --> C["DI examples"]
    B --> D["Literal Class.forName"]
    B --> E["Constant Class.forName"]
    B --> F["Method invoke"]
    B --> G["Framework invoke"]
    B --> H["False positive"]
    D --> I["ReflectTarget"]
    E --> I
    F --> I
    G --> J["JBSbatCheckUtil"]
    C --> K["StatelessBeanExample"]
    K --> L["BillingService"]
    L --> M["BillingServiceImpl"]
```

## Configuration

The project uses a minimal [pom.xml](../pom.xml) configuration:

- **Group / Artifact**: `com.optage:optage-wiki-scan-test` (version `1.0.0`)
- **Java version**: 8 (both source and target)
- **Dependencies**:
  - `javax.inject:javax.inject:1` — runtime dependency for `@Inject` annotation
  - `javax.ejb:javax.ejb-api:3.2` (provided) — runtime dependency for `@Stateless` annotation

Since this is a test data project, there are no runtime configurations or external services. The build is a standard Maven compile.

## Common Patterns

### Reflection Patterns

The `reflection/` package exercises the specific patterns the analysis pipeline should detect:

- **Literal `Class.forName`**: `Class.forName("com.optage.testdata.targets.ReflectTarget").newInstance()` — direct string literal passed to `Class.forName`.
- **Constant `Class.forName`**: `Class.forName(TARGET_FQN)` where `TARGET_FQN` is a `static final` field — indirection via a constant.
- **Method invoke via reflection**: `getDeclaredMethod(METHOD_NAME).invoke(t)` — dynamic method lookup and invocation.
- **Framework invoke**: `JBSbatCheckUtil.invoke(ctx, rules)` — reflection-like dispatch through a utility layer.

### Negative Test Patterns

- **XML factory false positive**: `SAXParserFactory.newInstance()` should NOT be flagged as reflection. This ensures the analyzer does not conflate factory methods with reflection.

### Dependency Injection Patterns

- **`@Stateless`** — applied to `StatelessBeanExample` to test class-level annotation detection.
- **`@Inject`** — applied to `billingService` field to test field-level injection edge creation.
- **`@Override`** — used in `BillingServiceImpl` and `StatelessBeanExample`; expected to be treated as noise.

### Naming Conventions

- Package: `com.optage.testdata`
- Test target classes (classes referenced by reflection): placed in `targets/`
- Reflection examples: placed in `reflection/`
- DI examples: placed in `di/`
- Utility stubs: placed in `util/`
