From d21f994fbd9f9c9b5bb95b11e231975e13c6ab57 Mon Sep 17 00:00:00 2001 From: John Blum Date: Wed, 9 Feb 2022 15:09:57 -0800 Subject: [PATCH] Refactor the PetClinicApplicationSmokeTests class. Cleanup compiler warnings. Declare pet references as final. Edit descriptions for assertion errors. --- .../PetClinicApplicationSmokeTests.java | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/spring-geode-tests/smoke-tests/function-execution-on-region/src/test/java/example/app/petclinic/PetClinicApplicationSmokeTests.java b/spring-geode-tests/smoke-tests/function-execution-on-region/src/test/java/example/app/petclinic/PetClinicApplicationSmokeTests.java index 87fb91bd..2c92e604 100644 --- a/spring-geode-tests/smoke-tests/function-execution-on-region/src/test/java/example/app/petclinic/PetClinicApplicationSmokeTests.java +++ b/spring-geode-tests/smoke-tests/function-execution-on-region/src/test/java/example/app/petclinic/PetClinicApplicationSmokeTests.java @@ -87,12 +87,12 @@ public class PetClinicApplicationSmokeTests extends ForkingClientServerIntegrati "-Dspring.profiles.active=petclinic-server-function-execution"); } - private Pet castle = Pet.newPet("Castle").as(Pet.Type.CAT); - private Pet cocoa = Pet.newPet("Cocoa").as(Pet.Type.CAT); - private Pet maha = Pet.newPet("Maha").as(Pet.Type.DOG); - private Pet mittens = Pet.newPet("Mittens").as(Pet.Type.CAT); + private final Pet castle = Pet.newPet("Castle").as(Pet.Type.CAT); + private final Pet cocoa = Pet.newPet("Cocoa").as(Pet.Type.CAT); + private final Pet maha = Pet.newPet("Maha").as(Pet.Type.DOG); + private final Pet mittens = Pet.newPet("Mittens").as(Pet.Type.CAT); - private Set pets = CollectionUtils.asSet(castle, cocoa, maha, mittens); + private final Set pets = CollectionUtils.asSet(castle, cocoa, maha, mittens); @Autowired private PetRepository petRepository; @@ -123,7 +123,7 @@ public class PetClinicApplicationSmokeTests extends ForkingClientServerIntegrati this.petRepository.findAll().forEach(pet -> { assertThat(pet.getVaccinationDateTime()) - .describedAs("Vaccinations [%s] for [%s] was not correct", pet.getVaccinationDateTime(), pet) + .describedAs("Vaccinations [%s] for Pet [%s] was not correct", pet.getVaccinationDateTime(), pet) .isAfterOrEqualTo(beforeVaccinations); assertThat(pet.getVaccinationDateTime()).isBeforeOrEqualTo(afterVaccinations); @@ -164,6 +164,7 @@ public class PetClinicApplicationSmokeTests extends ForkingClientServerIntegrati public static class PetServiceFunctions { + @SuppressWarnings("rawtypes") @GemfireFunction(id = "AdministerPetVaccinations", optimizeForWrite = true) public void administerPetVaccinations(FunctionContext functionContext) { @@ -174,11 +175,11 @@ public class PetClinicApplicationSmokeTests extends ForkingClientServerIntegrati .map(Region::values) .ifPresent(pets -> pets.forEach(pet -> { - Pet resolvePet = (Pet) pet; + Pet resolvedPet = (Pet) pet; - resolvePet.vaccinate(); + resolvedPet.vaccinate(); - ((RegionFunctionContext) functionContext).getDataSet().put(resolvePet.getName(), resolvePet); + ((RegionFunctionContext) functionContext).getDataSet().put(resolvedPet.getName(), resolvedPet); })); } }