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

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

## 1. Role

### OwnerControllerTests.george()

This method acts as a deterministic test-data builder for the owner domain. It constructs a fully populated `Owner` instance representing George Franklin, including core person attributes, address/contact data, and one associated pet. In business terms, it provides a reusable fixture that mirrors a realistic owner record used by controller tests to validate owner-related presentation and domain behavior.

The method follows a simple builder-style initialization pattern: it creates the aggregate root (`Owner`), assigns identity and demographic attributes, creates a related `Pet`, and attaches a `PetType` describing the pet as a dog. It then adds the pet to the owner and assigns a pet identifier after the relationship is established, which is typical in test fixtures where persistence is not involved. The method does not branch or dispatch; its role is to prepare a canonical owner-with-pet object that can be reused across multiple assertions in the test class. Because it lives in a test class, it is not business transaction logic itself, but it supports the broader owner controller test suite by supplying stable domain state.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
    START(["george()"])
    A["Create new Owner instance"]
    B["Set owner id to TEST_OWNER_ID"]
    C["Set first name to George"]
    D["Set last name to Franklin"]
    E["Set address to 110 W. Liberty St."]
    F["Set city to Madison"]
    G["Set telephone to 6085551023"]
    H["Create new Pet instance"]
    I["Create new PetType instance"]
    J["Set PetType name to dog"]
    K["Assign PetType to Pet"]
    L["Set pet name to Max"]
    M["Set pet birth date to LocalDate.now()"]
    N["Add pet to owner"]
    O["Set pet id to 1"]
    P(["Return Owner"])
    START --> A
    A --> B
    B --> C
    C --> D
    D --> E
    E --> F
    F --> G
    G --> H
    H --> I
    I --> J
    J --> K
    K --> L
    L --> M
    M --> N
    N --> O
    O --> P
```

## 3. Parameter Analysis

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

**Instance fields / external state read by the method:** `TEST_OWNER_ID` from the enclosing test class; system clock through `LocalDate.now()` when assigning the pet birth date.

## 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's source code.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `Owner` / `setId` | - | `owners` | Assigns the owner identity used by the test fixture |
| C | `Owner` / `setFirstName` | - | `owners` | Populates the owner's first name for display and matching scenarios |
| C | `Owner` / `setLastName` | - | `owners` | Populates the owner's last name for display and matching scenarios |
| C | `Owner` / `setAddress` | - | `owners` | Populates the owner's street address |
| C | `Owner` / `setCity` | - | `owners` | Populates the owner's city |
| C | `Owner` / `setTelephone` | - | `owners` | Populates the owner's telephone number |
| C | `Pet` / `setType` | - | `pets` | Associates the pet with its classified type |
| C | `PetType` / `setName` | - | `pet_types` | Sets the pet type label to dog |
| C | `Pet` / `setName` | - | `pets` | Assigns the pet name used in owner-pet views |
| C | `Pet` / `setBirthDate` | - | `pets` | Sets the pet birth date for the test scenario |
| C | `Owner` / `addPet` | - | `owners`, `pets` | Adds the pet to the owner aggregate for downstream assertions |
| C | `Pet` / `setId` | - | `pets` | Assigns a stable pet identifier after the relationship is formed |

## 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` [-]

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 class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Owner.setId [C] owners` |
| 2 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Owner.setFirstName [C] owners` |
| 3 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Owner.setLastName [C] owners` |
| 4 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Owner.setAddress [C] owners` |
| 5 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Owner.setCity [C] owners` |
| 6 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Owner.setTelephone [C] owners` |
| 7 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Owner.addPet [C] pets` |
| 8 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `PetType.setName [C] pet_types` |
| 9 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Pet.setType [C] pets` |
| 10 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Pet.setName [C] pets` |
| 11 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Pet.setBirthDate [C] pets` |
| 12 | Test class: `OwnerControllerTests` | `OwnerControllerTests.george()` | `Pet.setId [C] pets` |

## 6. Per-Branch Detail Blocks

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

> Creates a canonical owner fixture for controller testing, including one pet and one pet type.

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

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `Owner` | Domain entity | Pet clinic customer who owns one or more pets |
| `Pet` | Domain entity | Animal record associated with an owner |
| `PetType` | Domain entity | Classification of a pet, such as dog or cat |
| `george` | Fixture object | Test owner instance representing George Franklin |
| `TEST_OWNER_ID` | Test constant | Stable owner identifier used in controller test setup |
| `setId` | Method | Assigns a persistent-style identifier to the domain object |
| `setFirstName` | Method | Sets the person's given name |
| `setLastName` | Method | Sets the person's family name |
| `setAddress` | Method | Sets the street address |
| `setCity` | Method | Sets the city of residence |
| `setTelephone` | Method | Sets the contact telephone number |
| `setType` | Method | Links a pet to its type classification |
| `setName` | Method | Assigns a display name to the pet or pet type |
| `setBirthDate` | Method | Records the pet's date of birth |
| `addPet` | Method | Adds a pet to the owner's in-memory pet collection |
| `LocalDate.now()` | Platform API | Current system date used as the pet birth date in the fixture |
| `owners` | DB table / entity group | Persistence table backing owner records |
| `pets` | DB table / entity group | Persistence table backing pet records |
| `pet_types` | DB table / entity group | Persistence table backing pet type classifications |
| FTTH | Acronym | Fiber To The Home — not used in this method |
| SC | Acronym | Service Component — not used in this method |
| CBS | Acronym | Component-based service — not used in this method |
