# (DD09) Business Logic — OwnerControllerTests.george() [18 LOC]

| Field | Value |
|-------|-------|
| Fully Qualified Name | `org.springframework.samples.petclinic.owner.OwnerControllerTests` |
| Layer | Controller Test |
| Module | `owner` (Package: `org.springframework.samples.petclinic.owner`) |

## 1. Role

### OwnerControllerTests.george()

This method acts as a deterministic test-data factory for the PetClinic owner domain. It constructs a fully populated `Owner` aggregate with identity, address, and contact details, then attaches a single `Pet` child entity so controller tests can exercise owner-with-pet scenarios without repeating fixture setup in each test case. The method represents the canonical sample customer used throughout the test class: George Franklin from Madison, with a dog named Max. In business terms, it supports validation of owner display, owner search, pagination, and any controller path that needs a realistic owner record with an associated pet. The method uses a simple builder-style setup pattern and returns the ready-to-use domain object for reuse across multiple assertions.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["george()"])
    N1["Instantiate Owner george = new Owner()"]
    N2["Set owner id to TEST_OWNER_ID = 1"]
    N3["Set owner identity and contact fields
George Franklin, address, city, telephone"]
    N4["Instantiate Pet max = new Pet()"]
    N5["Instantiate PetType dog = new PetType()"]
    N6["Set pet type name to dog"]
    N7["Attach PetType to Pet"]
    N8["Set pet name to Max"]
    N9["Set pet birth date to LocalDate.now()"]
    N10["Add pet to owner with george.addPet(max)"]
    N11["Set pet id to 1"]
    END(["Return Owner george"])
    START --> N1
    N1 --> N2
    N2 --> N3
    N3 --> N4
    N4 --> N5
    N5 --> N6
    N6 --> N7
    N7 --> N8
    N8 --> N9
    N9 --> N10
    N10 --> N11
    N11 --> END
```

**CRITICAL — Constant Resolution:**
The method uses one local constant defined in the same test class:
- `TEST_OWNER_ID = 1` — the fixed identifier assigned to the sample owner fixture.

## 3. Parameter Analysis

| No | Parameter Name | Type | Business Description |
|----|---------------|------|---------------------|
| - | (none) | - | - |

This method has no input parameters. Its behavior is driven entirely by internal fixture construction and one test-class constant, `TEST_OWNER_ID`, plus the current system date used for the pet birth date. It does not read any external state beyond the runtime clock used by `LocalDate.now()`.

## 4. CRUD Operations / Called Services

### Pre-computed evidence from code analysis graph:

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| - | `OwnerControllerTests.george` | OwnerControllerTests | - | Calls `george` in `OwnerControllerTests` |

Analyze all method calls within this method and classify each as a CRUD operation.
Use the pre-computed evidence above. If SC Code or Entity/DB is missing, try to infer from:
- The **SC Code** (Service Component code, e.g., `EKK0361A010SC`, `EKK1081D010CBS`) — look at the class name of the called method or its containing class.
- The **Entity/DB tables** — search for table name constants (often `KK_T_*` pattern), SQL references, or entity names in the called method.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `george()` | `OwnerControllerTests` | `Owner`, `Pet`, `PetType` | Creates a reusable owner fixture with one associated pet for controller test scenarios |
| U | `setId(1)` | - | `Pet` | Assigns a generated-like identifier to the sample pet after it is added to the owner |
| U | `setId(TEST_OWNER_ID)` | - | `Owner` | Assigns the fixed owner identifier used by the test fixture |
| U | `setFirstName`, `setLastName`, `setAddress`, `setCity`, `setTelephone` | - | `Owner` | Populates the owner profile and contact attributes |
| U | `setName("dog")` | - | `PetType` | Classifies the sample pet as a dog |
| U | `setType`, `setName`, `setBirthDate` | - | `Pet` | Completes the pet profile before attaching it to the owner |
| C | `addPet(max)` | - | `Owner` / `Pet` | Links the pet to the owner aggregate for downstream test use |

## 5. Dependency Trace

### Pre-computed evidence from code analysis graph:

No screen/batch entry points found within 8 hops. Direct callers found: 3 methods.
Terminal operations from this method: `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-], `george` [-]

Trace who calls this method and what this method ultimately calls.
Use the pre-computed evidence and caller search results from Step 2 above.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Test:OwnerControllerTests | `OwnerControllerTests.testFindOwnersWithEmptyLastName` -> `OwnerControllerTests.george` | `Owner [C] Owner` |
| 2 | Test:OwnerControllerTests | `OwnerControllerTests.testFindOwnersWithPartialLastName` -> `OwnerControllerTests.george` | `Owner [C] Owner` |
| 3 | Test:OwnerControllerTests | `OwnerControllerTests.testFindOwnersWithMultipleMatches` -> `OwnerControllerTests.george` | `Owner [C] Owner` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENTIAL] (L71-L88)

> Straight-line fixture construction for a reusable owner-with-pet test object.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Owner george = new Owner();` |
| 2 | SET | `george.setId(TEST_OWNER_ID);` // assign fixed test identifier [-> TEST_OWNER_ID="1"] |
| 3 | SET | `george.setFirstName("George");` |
| 4 | SET | `george.setLastName("Franklin");` |
| 5 | SET | `george.setAddress("110 W. Liberty St.");` |
| 6 | SET | `george.setCity("Madison");` |
| 7 | SET | `george.setTelephone("6085551023");` |
| 8 | SET | `Pet max = new Pet();` |
| 9 | SET | `PetType dog = new PetType();` |
| 10 | EXEC | `dog.setName("dog");` |
| 11 | EXEC | `max.setType(dog);` |
| 12 | EXEC | `max.setName("Max");` |
| 13 | EXEC | `max.setBirthDate(LocalDate.now());` |
| 14 | CALL | `george.addPet(max);` |
| 15 | EXEC | `max.setId(1);` |
| 16 | RETURN | `return george;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `Owner` | Entity | Pet owner domain record used by the clinic to store customer identity and contact data |
| `Pet` | Entity | Animal owned by a customer; linked to an owner for scheduling and clinical records |
| `PetType` | Entity | Classification of a pet such as dog or cat |
| `george` | Fixture object | Sample owner instance representing George Franklin, reused across controller tests |
| `Max` | Fixture value | Sample pet name used to build a realistic owner-with-pet scenario |
| `TEST_OWNER_ID` | Constant | Fixed identifier used to keep the test fixture stable and predictable |
| `id` | Field | Technical identifier for owner or pet records |
| `firstName` | Field | Owner given name |
| `lastName` | Field | Owner family name |
| `address` | Field | Street address for the owner |
| `city` | Field | City portion of the owner address |
| `telephone` | Field | Contact phone number for the owner |
| `birthDate` | Field | Pet date of birth used in age-related validation and display |
| `addPet` | Method | Adds a pet to the owner aggregate so tests can work with a complete owner profile |
| `LocalDate.now()` | Technical API | Current system date used to give the sample pet a valid birth date |
| `dog` | Business term | A pet type value representing a dog |
| `owner controller tests` | Test layer | Automated controller-level verification of owner-related user flows |
