This is an automated email from the ASF dual-hosted git repository. danhaywood pushed a commit to branch CAUSEWAY-2873 in repository https://gitbox.apache.org/repos/asf/causeway.git
commit a881ffbad69fcc862ec739361164e4cec7d21978 Author: Dan Haywood <[email protected]> AuthorDate: Sat May 25 14:48:11 2024 +0100 CAUSEWAY-2873: removes old exercise --- .../petclinic/pages/030-petowner-entity.adoc | 144 --------------------- .../modules/petclinic/pages/100-todo.adoc | 5 + 2 files changed, 5 insertions(+), 144 deletions(-) diff --git a/antora/components/tutorials/modules/petclinic/pages/030-petowner-entity.adoc b/antora/components/tutorials/modules/petclinic/pages/030-petowner-entity.adoc index 529472a39d..f0b01273b5 100644 --- a/antora/components/tutorials/modules/petclinic/pages/030-petowner-entity.adoc +++ b/antora/components/tutorials/modules/petclinic/pages/030-petowner-entity.adoc @@ -649,150 +649,6 @@ daysSinceLastVisit ---- -* Hide the `lastName` and `firstName` properties, using `@Property(hidden=...)`. -We can also remove the `@PropertyLayout` annotation. -+ -[source,java] -.PetOwner.java ----- -@LastName -@Column(length = LastName.MAX_LEN, nullable = false) -@Getter @Setter @ToString.Include -@Property(hidden = Where.EVERYWHERE) -private String lastName; - -@FirstName -@Column(length = FirstName.MAX_LEN, nullable = true) -@Getter @Setter @ToString.Include -@Property(hidden = Where.EVERYWHERE) -private String firstName; ----- - - -* Update the `PetOwner#updateName` to associate with the new `name` property: -+ -[source,xml] ----- -@ActionLayout(associateWith = "name",) -public PetOwner updateName( ... ) {} ----- - - -Run the application and check that it behaves as you expect. - -However, if you now try to build the app (`mvn clean install`) then you'll hit test errors, because we have changed the visibility of the `lastName` and `firstName` properties. - -We will be looking at tests later on, so if you want to just comment out the failing tests, then do that. -Alternatively, here are the changes that need to be made: - -* update the `PetOwner_IntegTest#name` nested static test class: -+ -[source,java] -.PetOwner_IntegTest.java ----- -@Nested -public static class name extends PetOwner_IntegTest { - - @Test - public void accessible() { - // when - final String name = wrap(petOwner).getName(); // <.> - - // then - assertThat(name).isEqualTo(petOwner.getLastName()); - } - - // <.> -} ----- -<.> change this line from `getLastName()` to `getName()` -<.> delete the 'editable' test - -* add a new `PetOwner_IntegTest#lastName` nested static test class to check that the `lastName` property can no longer be viewed: -+ -[source,java] -.PetOwner_IntegTest.java ----- -@Nested -public static class lastName extends PetOwner_IntegTest { - - @Test - public void not_accessible() { - // expect - assertThrows(HiddenException.class, ()->{ - - // when - wrap(petOwner).getLastName(); - }); - } -} ----- -+ -This asserts that the `lastName` property cannot be viewed. - -* add a new `PetOwner_IntegTest#firstName` nested static test class to check that the `firstName` property can no longer be viewed. -+ -[source,java] -.PetOwner_IntegTest.java ----- -@Nested -public static class firstName extends PetOwner_IntegTest { - - @Test - public void not_accessible() { - // expect - assertThrows(HiddenException.class, ()->{ - - // when - wrap(petOwner).getFirstName(); - }); - } -} ----- - -* update the `PetOwner_IntegTest#updateName` nested static test class, specifically the assertion: -+ -[source,java] -.PetOwner_IntegTest.java ----- -@Nested -public static class updateName extends PetOwner_IntegTest { - - - @Test - public void can_be_updated_directly() { - - // when - wrap(petOwner).updateName("McAdam", "Adam"); // <.> - transactionService.flushTransaction(); - - // then - assertThat(petOwner.getLastName()).isEqualTo("McAdam"); // <.> - assertThat(petOwner.getFirstName()).isEqualTo("Adam"); // <2> - } - //... -} ----- -<.> provide both `lastName` and `firstName` parameters -<.> assert on both properties. -Note that the `petOwner` object cannot be "wrapped". - -In case you are wondering, the wrap method is a call to xref:refguide:applib:index/services/wrapper/WrapperFactory.adoc[WrapperFactory], which provides a proxy to the object. -This proxy emulates the UI, in this case enforcing the "hidden" rule by throwing an exception if it would not be visible. -For this test, we _want_ to peek under the covers to check the direct state of the entity, therefore we don't wrap the object. - -* also update the `Smoke_IntegTest`: -+ -[source,java] -.Smoke_IntegTest.java ----- -... -assertThat(wrap(fred).getName()).isEqualTo("Freddy"); // <.> -... ----- -<.> previously was "wrap(fred).getLastName(). - - [#exercise-3-8-add-other-properties-for-petowner] == Ex 3.8: Add other properties for PetOwner diff --git a/antora/components/tutorials/modules/petclinic/pages/100-todo.adoc b/antora/components/tutorials/modules/petclinic/pages/100-todo.adoc index 66bd2a3312..6ebd2b2b7f 100644 --- a/antora/components/tutorials/modules/petclinic/pages/100-todo.adoc +++ b/antora/components/tutorials/modules/petclinic/pages/100-todo.adoc @@ -8,3 +8,8 @@ add validation for telephone number and email address. PetOwner#daysSinceLastVisit could be made into a mixin - eg if these marketing analytics were the responsibility of some other module. + + + +hidden properties +
