---

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

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

## 1. Role

### OwnerControllerTests.george()

This method is a test-data factory that builds a fully populated `Owner` aggregate for the PetClinic owner domain. It creates the owner profile for George Franklin, assigns the canonical test owner identifier, and populates the owner with a realistic contact profile so controller tests can exercise search, lookup, and rendering scenarios against stable business data.

The method also constructs the owner's pet collection by creating a `Pet` named Max with a `PetType` of dog, then links the pet back to the owner through `george.addPet(max)`. This reflects the domain relationship used by the owner and pet management screens: a single owner can manage multiple pets, and each pet must carry identity, type, and birth-date data before it can participate in downstream visit workflows.

From a design perspective, the method follows a fixture-builder pattern with direct object construction and delegation to the domain aggregate (`Owner.addPet`) to preserve encapsulation rules. Its larger role in the system is supporting repeatable controller test execution by supplying deterministic reference data that matches common UI and repository expectations.

## 2. Processing Pattern (Detailed Business Logic)

```mermaid
flowchart TD
START(["george()"])
CREATE_OWNER["Instantiate Owner and assign owner profile data"]
SET_ID["Set owner id to TEST_OWNER_ID = 1"]
SET_NAME["Set first name George and last name Franklin"]
SET_ADDRESS["Set address 110 W. Liberty St., city Madison, telephone 6085551023"]
CREATE_PET["Instantiate Pet and PetType"]
SET_PETTYPE["Set pet type name dog"]
SET_PET_DATA["Set pet name Max and birth date to current date"]
ADD_PET["Call george.addPet(max)"]
SET_PET_ID["Set pet id to 1"]
RETURN_NODE["Return Owner george"]
START --> CREATE_OWNER
CREATE_OWNER --> SET_ID
SET_ID --> SET_NAME
SET_NAME --> SET_ADDRESS
SET_ADDRESS --> CREATE_PET
CREATE_PET --> SET_PETTYPE
SET_PETTYPE --> SET_PET_DATA
SET_PET_DATA --> ADD_PET
ADD_PET --> SET_PET_ID
SET_PET_ID --> RETURN_NODE
```

**CRITICAL — Constant Resolution:**
The method uses the local test constant `TEST_OWNER_ID`. The source file defines it as `1`, so the flowchart and block analysis resolve it as `TEST_OWNER_ID = "1"`.

## 3. Parameter Analysis

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

This method has no parameters. It depends on one instance field and local test state: `TEST_OWNER_ID` is read from the enclosing test class to assign a stable owner identifier, and `LocalDate.now()` is used to stamp the sample pet with the current business 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.

| CRUD | SC / CBS | SC Code | Entity / DB | Operation Description |
|------|----------|---------|-------------|----------------------|
| C | `Owner` constructor | - | `Owner` | Creates a new owner aggregate for test fixture setup |
| U | `setId(int)` | - | `Owner` | Assigns the canonical owner identifier `1` to the test owner |
| U | `setFirstName(String)` | - | `Owner` | Sets the owner's first name to George |
| U | `setLastName(String)` | - | `Owner` | Sets the owner's last name to Franklin |
| U | `setAddress(String)` | - | `Owner` | Sets the owner's mailing address for UI and validation scenarios |
| U | `setCity(String)` | - | `Owner` | Sets the owner's city for contact profile completeness |
| U | `setTelephone(String)` | - | `Owner` | Sets the owner's telephone number for contact profile completeness |
| C | `Pet` constructor | - | `Pet` | Creates a new pet aggregate for the owner fixture |
| C | `PetType` constructor | - | `PetType` | Creates a new pet type reference object |
| U | `setName(String)` on `PetType` | - | `PetType` | Assigns the pet type name dog |
| U | `setType(PetType)` | - | `Pet` | Links the pet to its type classification |
| U | `setName(String)` on `Pet` | - | `Pet` | Sets the pet name Max |
| U | `setBirthDate(LocalDate)` | - | `Pet` | Assigns the pet birth date using the current day |
| U | `addPet(Pet)` | - | `Owner` / `Pet` | Adds the pet to the owner's managed pet collection |
| U | `setId(int)` on `Pet` | - | `Pet` | Assigns the pet identifier `1` for deterministic test behavior |
| R | `LocalDate.now()` | - | System clock | Reads the current date to make the fixture time-sensitive but valid |

## 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.

| # | Caller (Screen/Batch) | Call Chain (Full Path to this Method) | Terminal (SC / CRUD / Entity) |
|---|----------------------|--------------------------------------|-------------------------------|
| 1 | Controller test method in `OwnerControllerTests` | `OwnerControllerTests.setup` -> `OwnerControllerTests.george` | `Owner [C] Owner` / `Pet [C] Pet` / `PetType [C] PetType` |
| 2 | Controller test method in `OwnerControllerTests` | `OwnerControllerTests.processCreationFormSuccess` -> `OwnerControllerTests.george` | `Owner [C] Owner` / `Pet [C] Pet` / `PetType [C] PetType` |
| 3 | Controller test method in `OwnerControllerTests` | `OwnerControllerTests.findOwners` -> `OwnerControllerTests.george` | `Owner [C] Owner` / `Pet [C] Pet` / `PetType [C] PetType` |

## 6. Per-Branch Detail Blocks

**Block 1** — [SEQUENCE] `(object construction and owner field population)` (L71-L77)

> Builds the owner fixture with full contact and identity data.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Owner george = new Owner();` |
| 2 | SET | `george.setId(TEST_OWNER_ID);` [-> `TEST_OWNER_ID="1"`] |
| 3 | EXEC | `george.setFirstName("George");` |
| 4 | EXEC | `george.setLastName("Franklin");` |
| 5 | EXEC | `george.setAddress("110 W. Liberty St.");` |
| 6 | EXEC | `george.setCity("Madison");` |
| 7 | EXEC | `george.setTelephone("6085551023");` |

**Block 2** — [SEQUENCE] `(pet and pet type construction)` (L78-L82)

> Creates the sample pet and classifies it as a dog.

| # | Type | Code |
|---|------|------|
| 1 | SET | `Pet max = new Pet();` |
| 2 | SET | `PetType dog = new PetType();` |
| 3 | EXEC | `dog.setName("dog");` |
| 4 | EXEC | `max.setType(dog);` |
| 5 | EXEC | `max.setName("Max");` |
| 6 | EXEC | `max.setBirthDate(LocalDate.now());` |

**Block 3** — [SEQUENCE] `(aggregate association and return)` (L83-L85)

> Attaches the pet to the owner and finalizes the fixture.

| # | Type | Code |
|---|------|------|
| 1 | CALL | `george.addPet(max);` |
| 2 | EXEC | `max.setId(1);` |
| 3 | RETURN | `return george;` |

## 7. Glossary

| Term | Type | Business Meaning |
|------|------|------------------|
| `TEST_OWNER_ID` | Field | Stable test owner identifier used to keep controller test data deterministic |
| `Owner` | Domain entity | PetClinic owner profile containing contact and identity information |
| `Pet` | Domain entity | Animal registered to an owner for veterinary management |
| `PetType` | Domain entity | Classification of a pet, such as dog or cat |
| `addPet` | Domain method | Owner aggregate operation that attaches a pet to the owner's managed pet list |
| `LocalDate.now()` | Technical API | Current system date used to create a valid sample birth date |
| `George Franklin` | Test fixture identity | Canonical sample owner used across PetClinic test scenarios |
| `Max` | Test fixture identity | Canonical sample pet linked to George Franklin |
| `dog` | Business term | Pet species classification used for the sample pet |
| `OwnerControllerTests` | Test class | Web MVC test class for owner controller behavior |
| `owner` | Module term | PetClinic business area for owner and pet lifecycle management |
