-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmethods.json
More file actions
1 lines (1 loc) · 50.3 KB
/
methods.json
File metadata and controls
1 lines (1 loc) · 50.3 KB
1
[{"name":"setLastName","body":"{\n\t\tthis.lastName \u003d lastName;\n\t}"},{"name":"setFirstName","body":"{\n\t\tthis.firstName \u003d firstName;\n\t}"},{"name":"getFirstName","body":"{\n\t\treturn this.firstName;\n\t}"},{"name":"getLastName","body":"{\n\t\treturn this.lastName;\n\t}"},{"name":"setName","body":"{\n\t\tthis.name \u003d name;\n\t}"},{"name":"getName","body":"{\n\t\treturn this.name;\n\t}"},{"name":"findAll","body":"N/A"},{"name":"getId","body":"{\n\t\treturn id;\n\t}"},{"name":"isNew","body":"{\n\t\treturn this.id \u003d\u003d null;\n\t}"},{"name":"showResourcesVetList","body":"{\n\t\t// Here we are returning an object of type \u0027Vets\u0027 rather than a collection of Vet\n\t\t// objects so it is simpler for JSon/Object mapping\n\t\tVets vets \u003d new Vets();\n\t\tvets.getVetList().addAll(this.vetRepository.findAll());\n\t\treturn vets;\n\t}"},{"name":"findPaginated","body":"{\n\t\tint pageSize \u003d 5;\n\t\tPageable pageable \u003d PageRequest.of(page - 1, pageSize);\n\t\treturn vetRepository.findAll(pageable);\n\t}"},{"name":"showVetList","body":"{\n\t\t// Here we are returning an object of type \u0027Vets\u0027 rather than a collection of Vet\n\t\t// objects so it is simpler for Object-Xml mapping\n\t\tVets vets \u003d new Vets();\n\t\tPage\u003cVet\u003e paginated \u003d findPaginated(page);\n\t\tvets.getVetList().addAll(paginated.toList());\n\t\treturn addPaginationModel(page, paginated, model);\n\t}"},{"name":"VetController","body":"{\n\t\tthis.vetRepository \u003d vetRepository;\n\t}"},{"name":"getVetList","body":"{\n\t\tif (vets \u003d\u003d null) {\n\t\t\tvets \u003d new ArrayList\u003c\u003e();\n\t\t}\n\t\treturn vets;\n\t}"},{"name":"getSpecialties","body":"{\n\t\treturn getSpecialtiesInternal().stream()\n\t\t\t.sorted(Comparator.comparing(NamedEntity::getName))\n\t\t\t.collect(Collectors.toList());\n\t}"},{"name":"getSpecialtiesInternal","body":"{\n\t\tif (this.specialties \u003d\u003d null) {\n\t\t\tthis.specialties \u003d new HashSet\u003c\u003e();\n\t\t}\n\t\treturn this.specialties;\n\t}"},{"name":"getNrOfSpecialties","body":"{\n\t\treturn getSpecialtiesInternal().size();\n\t}"},{"name":"addSpecialty","body":"{\n\t\tgetSpecialtiesInternal().add(specialty);\n\t}"},{"name":"Visit","body":"{\n\t\tthis.date \u003d LocalDate.now();\n\t}"},{"name":"setDate","body":"{\n\t\tthis.date \u003d date;\n\t}"},{"name":"setDescription","body":"{\n\t\tthis.description \u003d description;\n\t}"},{"name":"getDescription","body":"{\n\t\treturn this.description;\n\t}"},{"name":"findByLastNameStartingWith","body":"N/A"},{"name":"findById","body":"N/A"},{"name":"getPet","body":"{\n\t\tfor (Pet pet : getPets()) {\n\t\t\tString compName \u003d pet.getName();\n\t\t\tif (compName !\u003d null \u0026\u0026 compName.equalsIgnoreCase(name)) {\n\t\t\t\tif (!ignoreNew || !pet.isNew()) {\n\t\t\t\t\treturn pet;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn null;\n\t}"},{"name":"getTelephone","body":"{\n\t\treturn this.telephone;\n\t}"},{"name":"setAddress","body":"{\n\t\tthis.address \u003d address;\n\t}"},{"name":"setCity","body":"{\n\t\tthis.city \u003d city;\n\t}"},{"name":"getPets","body":"{\n\t\treturn this.pets;\n\t}"},{"name":"getAddress","body":"{\n\t\treturn this.address;\n\t}"},{"name":"addPet","body":"{\n\t\tif (pet.isNew()) {\n\t\t\tgetPets().add(pet);\n\t\t}\n\t}"},{"name":"setTelephone","body":"{\n\t\tthis.telephone \u003d telephone;\n\t}"},{"name":"getCity","body":"{\n\t\treturn this.city;\n\t}"},{"name":"findPetTypes","body":"N/A"},{"name":"triggerException","body":"{\n\t\tthrow new RuntimeException(\n\t\t\t\t\"Expected: controller used to showcase what \" + \"happens when an exception is thrown\");\n\t}"},{"name":"welcome","body":"{\n\t\treturn \"welcome\";\n\t}"},{"name":"getType","body":"{\n\t\treturn this.type;\n\t}"},{"name":"setBirthDate","body":"{\n\t\tthis.birthDate \u003d birthDate;\n\t}"},{"name":"getBirthDate","body":"{\n\t\treturn this.birthDate;\n\t}"},{"name":"getVisits","body":"{\n\t\treturn this.visits;\n\t}"},{"name":"localeChangeInterceptor","body":"{\n\t\tLocaleChangeInterceptor interceptor \u003d new LocaleChangeInterceptor();\n\t\tinterceptor.setParamName(\"lang\");\n\t\treturn interceptor;\n\t}"},{"name":"localeResolver","body":"{\n\t\tSessionLocaleResolver resolver \u003d new SessionLocaleResolver();\n\t\tresolver.setDefaultLocale(Locale.ENGLISH);\n\t\treturn resolver;\n\t}"},{"name":"addInterceptors","body":"{\n\t\tregistry.addInterceptor(localeChangeInterceptor());\n\t}"},{"name":"PetTypeFormatter","body":"{\n\t\tthis.types \u003d types;\n\t}"},{"name":"initUpdateOwnerForm","body":"{\n\t\treturn VIEWS_OWNER_CREATE_OR_UPDATE_FORM;\n\t}"},{"name":"OwnerController","body":"{\n\t\tthis.owners \u003d owners;\n\t}"},{"name":"initFindForm","body":"{\n\t\treturn \"owners/findOwners\";\n\t}"},{"name":"findPaginatedForOwnersLastName","body":"{\n\t\tint pageSize \u003d 5;\n\t\tPageable pageable \u003d PageRequest.of(page - 1, pageSize);\n\t\treturn owners.findByLastNameStartingWith(lastname, pageable);\n\t}"},{"name":"processUpdateOwnerForm","body":"{\n\t\tif (result.hasErrors()) {\n\t\t\tredirectAttributes.addFlashAttribute(\"error\", \"There was an error in updating the owner.\");\n\t\t\treturn VIEWS_OWNER_CREATE_OR_UPDATE_FORM;\n\t\t}\n\n\t\tif (!Objects.equals(owner.getId(), ownerId)) {\n\t\t\tresult.rejectValue(\"id\", \"mismatch\", \"The owner ID in the form does not match the URL.\");\n\t\t\tredirectAttributes.addFlashAttribute(\"error\", \"Owner ID mismatch. Please try again.\");\n\t\t\treturn \"redirect:/owners/{ownerId}/edit\";\n\t\t}\n\n\t\towner.setId(ownerId);\n\t\tthis.owners.save(owner);\n\t\tredirectAttributes.addFlashAttribute(\"message\", \"Owner Values Updated\");\n\t\treturn \"redirect:/owners/{ownerId}\";\n\t}"},{"name":"showOwner","body":"{\n\t\tModelAndView mav \u003d new ModelAndView(\"owners/ownerDetails\");\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(ownerId);\n\t\tOwner owner \u003d optionalOwner.orElseThrow(() -\u003e new IllegalArgumentException(\n\t\t\t\t\"Owner not found with id: \" + ownerId + \". Please ensure the ID is correct \"));\n\t\tmav.addObject(owner);\n\t\treturn mav;\n\t}"},{"name":"processFindForm","body":"{\n\t\t// allow parameterless GET request for /owners to return all records\n\t\tString lastName \u003d owner.getLastName();\n\t\tif (lastName \u003d\u003d null) {\n\t\t\tlastName \u003d \"\"; // empty string signifies broadest possible search\n\t\t}\n\n\t\t// find owners by last name\n\t\tPage\u003cOwner\u003e ownersResults \u003d findPaginatedForOwnersLastName(page, lastName);\n\t\tif (ownersResults.isEmpty()) {\n\t\t\t// no owners found\n\t\t\tresult.rejectValue(\"lastName\", \"notFound\", \"not found\");\n\t\t\treturn \"owners/findOwners\";\n\t\t}\n\n\t\tif (ownersResults.getTotalElements() \u003d\u003d 1) {\n\t\t\t// 1 owner found\n\t\t\towner \u003d ownersResults.iterator().next();\n\t\t\treturn \"redirect:/owners/\" + owner.getId();\n\t\t}\n\n\t\t// multiple owners found\n\t\treturn addPaginationModel(page, model, ownersResults);\n\t}"},{"name":"VisitController","body":"{\n\t\tthis.owners \u003d owners;\n\t}"},{"name":"loadPetWithVisit","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d owners.findById(ownerId);\n\t\tOwner owner \u003d optionalOwner.orElseThrow(() -\u003e new IllegalArgumentException(\n\t\t\t\t\"Owner not found with id: \" + ownerId + \". Please ensure the ID is correct \"));\n\n\t\tPet pet \u003d owner.getPet(petId);\n\t\tif (pet \u003d\u003d null) {\n\t\t\tthrow new IllegalArgumentException(\n\t\t\t\t\t\"Pet with id \" + petId + \" not found for owner with id \" + ownerId + \".\");\n\t\t}\n\t\tmodel.put(\"pet\", pet);\n\t\tmodel.put(\"owner\", owner);\n\n\t\tVisit visit \u003d new Visit();\n\t\tpet.addVisit(visit);\n\t\treturn visit;\n\t}"},{"name":"initNewVisitForm","body":"{\n\t\treturn \"pets/createOrUpdateVisitForm\";\n\t}"},{"name":"processNewVisitForm","body":"{\n\t\tif (result.hasErrors()) {\n\t\t\treturn \"pets/createOrUpdateVisitForm\";\n\t\t}\n\n\t\towner.addVisit(petId, visit);\n\t\tthis.owners.save(owner);\n\t\tredirectAttributes.addFlashAttribute(\"message\", \"Your visit has been booked\");\n\t\treturn \"redirect:/owners/{ownerId}\";\n\t}"},{"name":"cacheConfiguration","body":"{\n\t\treturn new MutableConfiguration\u003c\u003e().setStatisticsEnabled(true);\n\t}"},{"name":"petclinicCacheConfigurationCustomizer","body":"{\n\t\treturn cm -\u003e cm.createCache(\"vets\", cacheConfiguration());\n\t}"},{"name":"PetController","body":"{\n\t\tthis.owners \u003d owners;\n\t\tthis.types \u003d types;\n\t}"},{"name":"findPet","body":"{\n\n\t\tif (petId \u003d\u003d null) {\n\t\t\treturn new Pet();\n\t\t}\n\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(ownerId);\n\t\tOwner owner \u003d optionalOwner.orElseThrow(() -\u003e new IllegalArgumentException(\n\t\t\t\t\"Owner not found with id: \" + ownerId + \". Please ensure the ID is correct \"));\n\t\treturn owner.getPet(petId);\n\t}"},{"name":"initOwnerBinder","body":"{\n\t\tdataBinder.setDisallowedFields(\"id\");\n\t}"},{"name":"initPetBinder","body":"{\n\t\tdataBinder.setValidator(new PetValidator());\n\t}"},{"name":"initUpdateForm","body":"{\n\t\treturn VIEWS_PETS_CREATE_OR_UPDATE_FORM;\n\t}"},{"name":"populatePetTypes","body":"{\n\t\treturn this.types.findPetTypes();\n\t}"},{"name":"updatePetDetails","body":"{\n\t\tInteger id \u003d pet.getId();\n\t\tAssert.state(id !\u003d null, \"\u0027pet.getId()\u0027 must not be null\");\n\t\tPet existingPet \u003d owner.getPet(id);\n\t\tif (existingPet !\u003d null) {\n\t\t\t// Update existing pet\u0027s properties\n\t\t\texistingPet.setName(pet.getName());\n\t\t\texistingPet.setBirthDate(pet.getBirthDate());\n\t\t\texistingPet.setType(pet.getType());\n\t\t}\n\t\telse {\n\t\t\towner.addPet(pet);\n\t\t}\n\t\tthis.owners.save(owner);\n\t}"},{"name":"processUpdateForm","body":"{\n\n\t\tString petName \u003d pet.getName();\n\n\t\t// checking if the pet name already exists for the owner\n\t\tif (StringUtils.hasText(petName)) {\n\t\t\tPet existingPet \u003d owner.getPet(petName, false);\n\t\t\tif (existingPet !\u003d null \u0026\u0026 !Objects.equals(existingPet.getId(), pet.getId())) {\n\t\t\t\tresult.rejectValue(\"name\", \"duplicate\", \"already exists\");\n\t\t\t}\n\t\t}\n\n\t\tLocalDate currentDate \u003d LocalDate.now();\n\t\tif (pet.getBirthDate() !\u003d null \u0026\u0026 pet.getBirthDate().isAfter(currentDate)) {\n\t\t\tresult.rejectValue(\"birthDate\", \"typeMismatch.birthDate\");\n\t\t}\n\n\t\tif (result.hasErrors()) {\n\t\t\treturn VIEWS_PETS_CREATE_OR_UPDATE_FORM;\n\t\t}\n\n\t\tupdatePetDetails(owner, pet);\n\t\tredirectAttributes.addFlashAttribute(\"message\", \"Pet details has been edited\");\n\t\treturn \"redirect:/owners/{ownerId}\";\n\t}"},{"name":"registerHints","body":"{\n\t\thints.resources().registerPattern(\"db/*\"); // https://github.com/spring-projects/spring-boot/issues/32654\n\t\thints.resources().registerPattern(\"messages/*\");\n\t\thints.resources().registerPattern(\"mysql-default-conf\");\n\t\thints.serialization().registerType(BaseEntity.class);\n\t\thints.serialization().registerType(Person.class);\n\t\thints.serialization().registerType(Vet.class);\n\t}"},{"name":"helen","body":"{\n\t\tVet helen \u003d new Vet();\n\t\thelen.setFirstName(\"Helen\");\n\t\thelen.setLastName(\"Leary\");\n\t\thelen.setId(2);\n\t\tSpecialty radiology \u003d new Specialty();\n\t\tradiology.setId(1);\n\t\tradiology.setName(\"radiology\");\n\t\thelen.addSpecialty(radiology);\n\t\treturn helen;\n\t}"},{"name":"testShowResourcesVetList","body":"{\n\t\tResultActions actions \u003d mockMvc.perform(get(\"/vets\").accept(MediaType.APPLICATION_JSON))\n\t\t\t.andExpect(status().isOk());\n\t\tactions.andExpect(content().contentType(MediaType.APPLICATION_JSON))\n\t\t\t.andExpect(jsonPath(\"$.vetList[0].id\").value(1));\n\t}"},{"name":"james","body":"{\n\t\tVet james \u003d new Vet();\n\t\tjames.setFirstName(\"James\");\n\t\tjames.setLastName(\"Carter\");\n\t\tjames.setId(1);\n\t\treturn james;\n\t}"},{"name":"testShowVetListHtml","body":"{\n\n\t\tmockMvc.perform(MockMvcRequestBuilders.get(\"/vets.html?page\u003d1\"))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attributeExists(\"listVets\"))\n\t\t\t.andExpect(view().name(\"vets/vetList\"));\n\n\t}"},{"name":"createValidator","body":"{\n\t\tLocalValidatorFactoryBean localValidatorFactoryBean \u003d new LocalValidatorFactoryBean();\n\t\tlocalValidatorFactoryBean.afterPropertiesSet();\n\t\treturn localValidatorFactoryBean;\n\t}"},{"name":"shouldNotValidateWhenFirstNameEmpty","body":"{\n\n\t\tLocaleContextHolder.setLocale(Locale.ENGLISH);\n\t\tPerson person \u003d new Person();\n\t\tperson.setFirstName(\"\");\n\t\tperson.setLastName(\"smith\");\n\n\t\tValidator validator \u003d createValidator();\n\t\tSet\u003cConstraintViolation\u003cPerson\u003e\u003e constraintViolations \u003d validator.validate(person);\n\n\t\tassertThat(constraintViolations).hasSize(1);\n\t\tConstraintViolation\u003cPerson\u003e violation \u003d constraintViolations.iterator().next();\n\t\tassertThat(violation.getPropertyPath()).hasToString(\"firstName\");\n\t\tassertThat(violation.getMessage()).isEqualTo(\"must not be blank\");\n\t}"},{"name":"testValidateWithInvalidBirthDate","body":"{\n\t\t\tpetType.setName(petTypeName);\n\t\t\tpet.setName(petName);\n\t\t\tpet.setType(petType);\n\t\t\tpet.setBirthDate(null);\n\n\t\t\tpetValidator.validate(pet, errors);\n\n\t\t\tassertTrue(errors.hasFieldErrors(\"birthDate\"));\n\t\t}"},{"name":"testValidate","body":"{\n\t\tpetType.setName(petTypeName);\n\t\tpet.setName(petName);\n\t\tpet.setType(petType);\n\t\tpet.setBirthDate(petBirthDate);\n\n\t\tpetValidator.validate(pet, errors);\n\n\t\tassertFalse(errors.hasErrors());\n\t}"},{"name":"setUp","body":"{\n\t\tpetValidator \u003d new PetValidator();\n\t\tpet \u003d new Pet();\n\t\tpetType \u003d new PetType();\n\t\terrors \u003d new MapBindingResult(new HashMap\u003c\u003e(), \"pet\");\n\t}"},{"name":"testValidateWithInvalidPetName","body":"{\n\t\t\tpetType.setName(petTypeName);\n\t\t\tpet.setName(\"\");\n\t\t\tpet.setType(petType);\n\t\t\tpet.setBirthDate(petBirthDate);\n\n\t\t\tpetValidator.validate(pet, errors);\n\n\t\t\tassertTrue(errors.hasFieldErrors(\"name\"));\n\t\t}"},{"name":"testValidateWithInvalidPetType","body":"{\n\t\t\tpet.setName(petName);\n\t\t\tpet.setType(null);\n\t\t\tpet.setBirthDate(petBirthDate);\n\n\t\t\tpetValidator.validate(pet, errors);\n\n\t\t\tassertTrue(errors.hasFieldErrors(\"type\"));\n\t\t}"},{"name":"testSerialization","body":"{\n\t\tVet vet \u003d new Vet();\n\t\tvet.setFirstName(\"Zaphod\");\n\t\tvet.setLastName(\"Beeblebrox\");\n\t\tvet.setId(123);\n\t\t@SuppressWarnings(\"deprecation\")\n\t\tVet other \u003d (Vet) SerializationUtils.deserialize(SerializationUtils.serialize(vet));\n\t\tassertThat(other.getFirstName()).isEqualTo(vet.getFirstName());\n\t\tassertThat(other.getLastName()).isEqualTo(vet.getLastName());\n\t\tassertThat(other.getId()).isEqualTo(vet.getId());\n\t}"},{"name":"testProcessNewVisitFormHasErrors","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/{ownerId}/pets/{petId}/visits/new\", TEST_OWNER_ID, TEST_PET_ID).param(\"name\",\n\t\t\t\t\t\"George\"))\n\t\t\t.andExpect(model().attributeHasErrors(\"visit\"))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(view().name(\"pets/createOrUpdateVisitForm\"));\n\t}"},{"name":"testInitNewVisitForm","body":"{\n\t\tmockMvc.perform(get(\"/owners/{ownerId}/pets/{petId}/visits/new\", TEST_OWNER_ID, TEST_PET_ID))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(view().name(\"pets/createOrUpdateVisitForm\"));\n\t}"},{"name":"testProcessNewVisitFormSuccess","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/{ownerId}/pets/{petId}/visits/new\", TEST_OWNER_ID, TEST_PET_ID)\n\t\t\t\t.param(\"name\", \"George\")\n\t\t\t\t.param(\"description\", \"Visit Description\"))\n\t\t\t.andExpect(status().is3xxRedirection())\n\t\t\t.andExpect(view().name(\"redirect:/owners/{ownerId}\"));\n\t}"},{"name":"testTriggerException","body":"{\n\t\tassertThatExceptionOfType(RuntimeException.class).isThrownBy(() -\u003e testee.triggerException())\n\t\t\t.withMessageContaining(\"Expected: controller used to showcase what happens when an exception is thrown\");\n\t}"},{"name":"testProcessUpdateFormWithInvalidBirthDate","body":"{\n\t\t\tmockMvc\n\t\t\t\t.perform(post(\"/owners/{ownerId}/pets/{petId}/edit\", TEST_OWNER_ID, TEST_PET_ID).param(\"name\", \" \")\n\t\t\t\t\t.param(\"birthDate\", \"2015/02/12\"))\n\t\t\t\t.andExpect(model().attributeHasNoErrors(\"owner\"))\n\t\t\t\t.andExpect(model().attributeHasErrors(\"pet\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrors(\"pet\", \"birthDate\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrorCode(\"pet\", \"birthDate\", \"typeMismatch\"))\n\t\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"));\n\t\t}"},{"name":"testProcessUpdateFormWithBlankName","body":"{\n\t\t\tmockMvc\n\t\t\t\t.perform(post(\"/owners/{ownerId}/pets/{petId}/edit\", TEST_OWNER_ID, TEST_PET_ID).param(\"name\", \" \")\n\t\t\t\t\t.param(\"birthDate\", \"2015-02-12\"))\n\t\t\t\t.andExpect(model().attributeHasNoErrors(\"owner\"))\n\t\t\t\t.andExpect(model().attributeHasErrors(\"pet\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrors(\"pet\", \"name\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrorCode(\"pet\", \"name\", \"required\"))\n\t\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"));\n\t\t}"},{"name":"testProcessCreationFormWithDuplicateName","body":"{\n\t\t\tmockMvc\n\t\t\t\t.perform(post(\"/owners/{ownerId}/pets/new\", TEST_OWNER_ID).param(\"name\", \"petty\")\n\t\t\t\t\t.param(\"birthDate\", \"2015-02-12\"))\n\t\t\t\t.andExpect(model().attributeHasNoErrors(\"owner\"))\n\t\t\t\t.andExpect(model().attributeHasErrors(\"pet\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrors(\"pet\", \"name\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrorCode(\"pet\", \"name\", \"duplicate\"))\n\t\t\t\t.andExpect(status().isOk())\n\t\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"));\n\t\t}"},{"name":"testProcessCreationFormWithInvalidBirthDate","body":"{\n\t\t\tLocalDate currentDate \u003d LocalDate.now();\n\t\t\tString futureBirthDate \u003d currentDate.plusMonths(1).toString();\n\n\t\t\tmockMvc\n\t\t\t\t.perform(post(\"/owners/{ownerId}/pets/new\", TEST_OWNER_ID).param(\"name\", \"Betty\")\n\t\t\t\t\t.param(\"birthDate\", futureBirthDate))\n\t\t\t\t.andExpect(model().attributeHasNoErrors(\"owner\"))\n\t\t\t\t.andExpect(model().attributeHasErrors(\"pet\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrors(\"pet\", \"birthDate\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrorCode(\"pet\", \"birthDate\", \"typeMismatch.birthDate\"))\n\t\t\t\t.andExpect(status().isOk())\n\t\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"));\n\t\t}"},{"name":"testProcessUpdateFormSuccess","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/{ownerId}/pets/{petId}/edit\", TEST_OWNER_ID, TEST_PET_ID).param(\"name\", \"Betty\")\n\t\t\t\t.param(\"type\", \"hamster\")\n\t\t\t\t.param(\"birthDate\", \"2015-02-12\"))\n\t\t\t.andExpect(status().is3xxRedirection())\n\t\t\t.andExpect(view().name(\"redirect:/owners/{ownerId}\"));\n\t}"},{"name":"testInitUpdateForm","body":"{\n\t\t\tmockMvc.perform(get(\"/owners/{ownerId}/pets/{petId}/edit\", TEST_OWNER_ID, TEST_PET_ID))\n\t\t\t\t.andExpect(status().isOk())\n\t\t\t\t.andExpect(model().attributeExists(\"pet\"))\n\t\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"));\n\t\t}"},{"name":"testProcessCreationFormWithBlankName","body":"{\n\t\t\tmockMvc\n\t\t\t\t.perform(post(\"/owners/{ownerId}/pets/new\", TEST_OWNER_ID).param(\"name\", \"\\t \\n\")\n\t\t\t\t\t.param(\"birthDate\", \"2015-02-12\"))\n\t\t\t\t.andExpect(model().attributeHasNoErrors(\"owner\"))\n\t\t\t\t.andExpect(model().attributeHasErrors(\"pet\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrors(\"pet\", \"name\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrorCode(\"pet\", \"name\", \"required\"))\n\t\t\t\t.andExpect(status().isOk())\n\t\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"));\n\t\t}"},{"name":"testProcessCreationFormWithMissingPetType","body":"{\n\t\t\tmockMvc\n\t\t\t\t.perform(post(\"/owners/{ownerId}/pets/new\", TEST_OWNER_ID).param(\"name\", \"Betty\")\n\t\t\t\t\t.param(\"birthDate\", \"2015-02-12\"))\n\t\t\t\t.andExpect(model().attributeHasNoErrors(\"owner\"))\n\t\t\t\t.andExpect(model().attributeHasErrors(\"pet\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrors(\"pet\", \"type\"))\n\t\t\t\t.andExpect(model().attributeHasFieldErrorCode(\"pet\", \"type\", \"required\"))\n\t\t\t\t.andExpect(status().isOk())\n\t\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"));\n\t\t}"},{"name":"container","body":"{\n\t\treturn new MySQLContainer\u003c\u003e(DockerImageName.parse(\"mysql:9.2\"));\n\t}"},{"name":"getById","body":"{\n\t\tfor (T entity : entities) {\n\t\t\tif (entity.getId() !\u003d null \u0026\u0026 entity.getId() \u003d\u003d entityId \u0026\u0026 entityClass.isInstance(entity)) {\n\t\t\t\treturn entity;\n\t\t\t}\n\t\t}\n\t\tthrow new ObjectRetrievalFailureException(entityClass, entityId);\n\t}"},{"name":"shouldParse","body":"{\n\t\tgiven(types.findPetTypes()).willReturn(makePetTypes());\n\t\tPetType petType \u003d petTypeFormatter.parse(\"Bird\", Locale.ENGLISH);\n\t\tassertThat(petType.getName()).isEqualTo(\"Bird\");\n\t}"},{"name":"makePetTypes","body":"{\n\t\tList\u003cPetType\u003e petTypes \u003d new ArrayList\u003c\u003e();\n\t\tpetTypes.add(new PetType() {\n\t\t\t{\n\t\t\t\tsetName(\"Dog\");\n\t\t\t}\n\t\t});\n\t\tpetTypes.add(new PetType() {\n\t\t\t{\n\t\t\t\tsetName(\"Bird\");\n\t\t\t}\n\t\t});\n\t\treturn petTypes;\n\t}"},{"name":"shouldThrowParseException","body":"{\n\t\tgiven(types.findPetTypes()).willReturn(makePetTypes());\n\t\tAssertions.assertThrows(ParseException.class, () -\u003e {\n\t\t\tpetTypeFormatter.parse(\"Fish\", Locale.ENGLISH);\n\t\t});\n\t}"},{"name":"testPrint","body":"{\n\t\tPetType petType \u003d new PetType();\n\t\tpetType.setName(\"Hamster\");\n\t\tString petTypeName \u003d this.petTypeFormatter.print(petType, Locale.ENGLISH);\n\t\tassertThat(petTypeName).isEqualTo(\"Hamster\");\n\t}"},{"name":"testProcessUpdateOwnerFormHasErrors","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/{ownerId}/edit\", TEST_OWNER_ID).param(\"firstName\", \"Joe\")\n\t\t\t\t.param(\"lastName\", \"Bloggs\")\n\t\t\t\t.param(\"address\", \"\")\n\t\t\t\t.param(\"telephone\", \"\"))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attributeHasErrors(\"owner\"))\n\t\t\t.andExpect(model().attributeHasFieldErrors(\"owner\", \"address\"))\n\t\t\t.andExpect(model().attributeHasFieldErrors(\"owner\", \"telephone\"))\n\t\t\t.andExpect(view().name(\"owners/createOrUpdateOwnerForm\"));\n\t}"},{"name":"testProcessFindFormSuccess","body":"{\n\t\tPage\u003cOwner\u003e tasks \u003d new PageImpl\u003c\u003e(List.of(george(), new Owner()));\n\t\twhen(this.owners.findByLastNameStartingWith(anyString(), any(Pageable.class))).thenReturn(tasks);\n\t\tmockMvc.perform(get(\"/owners?page\u003d1\")).andExpect(status().isOk()).andExpect(view().name(\"owners/ownersList\"));\n\t}"},{"name":"testInitUpdateOwnerForm","body":"{\n\t\tmockMvc.perform(get(\"/owners/{ownerId}/edit\", TEST_OWNER_ID))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attributeExists(\"owner\"))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"lastName\", is(\"Franklin\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"firstName\", is(\"George\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"address\", is(\"110 W. Liberty St.\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"city\", is(\"Madison\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"telephone\", is(\"6085551023\"))))\n\t\t\t.andExpect(view().name(\"owners/createOrUpdateOwnerForm\"));\n\t}"},{"name":"testProcessCreationFormHasErrors","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/new\").param(\"firstName\", \"Joe\").param(\"lastName\", \"Bloggs\").param(\"city\", \"London\"))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attributeHasErrors(\"owner\"))\n\t\t\t.andExpect(model().attributeHasFieldErrors(\"owner\", \"address\"))\n\t\t\t.andExpect(model().attributeHasFieldErrors(\"owner\", \"telephone\"))\n\t\t\t.andExpect(view().name(\"owners/createOrUpdateOwnerForm\"));\n\t}"},{"name":"testInitFindForm","body":"{\n\t\tmockMvc.perform(get(\"/owners/find\"))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attributeExists(\"owner\"))\n\t\t\t.andExpect(view().name(\"owners/findOwners\"));\n\t}"},{"name":"testProcessUpdateOwnerFormSuccess","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/{ownerId}/edit\", TEST_OWNER_ID).param(\"firstName\", \"Joe\")\n\t\t\t\t.param(\"lastName\", \"Bloggs\")\n\t\t\t\t.param(\"address\", \"123 Caramel Street\")\n\t\t\t\t.param(\"city\", \"London\")\n\t\t\t\t.param(\"telephone\", \"1616291589\"))\n\t\t\t.andExpect(status().is3xxRedirection())\n\t\t\t.andExpect(view().name(\"redirect:/owners/{ownerId}\"));\n\t}"},{"name":"george","body":"{\n\t\tOwner george \u003d new Owner();\n\t\tgeorge.setId(TEST_OWNER_ID);\n\t\tgeorge.setFirstName(\"George\");\n\t\tgeorge.setLastName(\"Franklin\");\n\t\tgeorge.setAddress(\"110 W. Liberty St.\");\n\t\tgeorge.setCity(\"Madison\");\n\t\tgeorge.setTelephone(\"6085551023\");\n\t\tPet max \u003d new Pet();\n\t\tPetType dog \u003d new PetType();\n\t\tdog.setName(\"dog\");\n\t\tmax.setType(dog);\n\t\tmax.setName(\"Max\");\n\t\tmax.setBirthDate(LocalDate.now());\n\t\tgeorge.addPet(max);\n\t\tmax.setId(1);\n\t\treturn george;\n\t}"},{"name":"testProcessUpdateOwnerFormWithIdMismatch","body":"{\n\t\tint pathOwnerId \u003d 1;\n\n\t\tOwner owner \u003d new Owner();\n\t\towner.setId(2);\n\t\towner.setFirstName(\"John\");\n\t\towner.setLastName(\"Doe\");\n\t\towner.setAddress(\"Center Street\");\n\t\towner.setCity(\"New York\");\n\t\towner.setTelephone(\"0123456789\");\n\n\t\twhen(owners.findById(pathOwnerId)).thenReturn(Optional.of(owner));\n\n\t\tmockMvc.perform(MockMvcRequestBuilders.post(\"/owners/{ownerId}/edit\", pathOwnerId).flashAttr(\"owner\", owner))\n\t\t\t.andExpect(status().is3xxRedirection())\n\t\t\t.andExpect(redirectedUrl(\"/owners/\" + pathOwnerId + \"/edit\"))\n\t\t\t.andExpect(flash().attributeExists(\"error\"));\n\t}"},{"name":"testProcessFindFormNoOwnersFound","body":"{\n\t\tPage\u003cOwner\u003e tasks \u003d new PageImpl\u003c\u003e(List.of());\n\t\twhen(this.owners.findByLastNameStartingWith(eq(\"Unknown Surname\"), any(Pageable.class))).thenReturn(tasks);\n\t\tmockMvc.perform(get(\"/owners?page\u003d1\").param(\"lastName\", \"Unknown Surname\"))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attributeHasFieldErrors(\"owner\", \"lastName\"))\n\t\t\t.andExpect(model().attributeHasFieldErrorCode(\"owner\", \"lastName\", \"notFound\"))\n\t\t\t.andExpect(view().name(\"owners/findOwners\"));\n\n\t}"},{"name":"testProcessUpdateOwnerFormUnchangedSuccess","body":"{\n\t\tmockMvc.perform(post(\"/owners/{ownerId}/edit\", TEST_OWNER_ID))\n\t\t\t.andExpect(status().is3xxRedirection())\n\t\t\t.andExpect(view().name(\"redirect:/owners/{ownerId}\"));\n\t}"},{"name":"testShowOwner","body":"{\n\t\tmockMvc.perform(get(\"/owners/{ownerId}\", TEST_OWNER_ID))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"lastName\", is(\"Franklin\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"firstName\", is(\"George\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"address\", is(\"110 W. Liberty St.\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"city\", is(\"Madison\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"telephone\", is(\"6085551023\"))))\n\t\t\t.andExpect(model().attribute(\"owner\", hasProperty(\"pets\", not(empty()))))\n\t\t\t.andExpect(model().attribute(\"owner\",\n\t\t\t\t\thasProperty(\"pets\", hasItem(hasProperty(\"visits\", hasSize(greaterThan(0)))))))\n\t\t\t.andExpect(view().name(\"owners/ownerDetails\"));\n\t}"},{"name":"testProcessFindFormByLastName","body":"{\n\t\tPage\u003cOwner\u003e tasks \u003d new PageImpl\u003c\u003e(List.of(george()));\n\t\twhen(this.owners.findByLastNameStartingWith(eq(\"Franklin\"), any(Pageable.class))).thenReturn(tasks);\n\t\tmockMvc.perform(get(\"/owners?page\u003d1\").param(\"lastName\", \"Franklin\"))\n\t\t\t.andExpect(status().is3xxRedirection())\n\t\t\t.andExpect(view().name(\"redirect:/owners/\" + TEST_OWNER_ID));\n\t}"},{"name":"testTriggerExceptionHtml","body":"{\n\t\tHttpHeaders headers \u003d new HttpHeaders();\n\t\theaders.setAccept(List.of(MediaType.TEXT_HTML));\n\t\tResponseEntity\u003cString\u003e resp \u003d rest.exchange(\"http://localhost:\" + port + \"/oups\", HttpMethod.GET,\n\t\t\t\tnew HttpEntity\u003c\u003e(headers), String.class);\n\t\tassertThat(resp).isNotNull();\n\t\tassertThat(resp.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);\n\t\tassertThat(resp.getBody()).isNotNull();\n\t\t// html:\n\t\tassertThat(resp.getBody()).containsSubsequence(\"\u003cbody\u003e\", \"\u003ch2\u003e\", \"Something happened...\", \"\u003c/h2\u003e\", \"\u003cp\u003e\",\n\t\t\t\t\"Expected:\", \"controller\", \"used\", \"to\", \"showcase\", \"what\", \"happens\", \"when\", \"an\", \"exception\", \"is\",\n\t\t\t\t\"thrown\", \"\u003c/p\u003e\", \"\u003c/body\u003e\");\n\t\t// Not the whitelabel error page:\n\t\tassertThat(resp.getBody()).doesNotContain(\"Whitelabel Error Page\",\n\t\t\t\t\"This application has no explicit mapping for\");\n\t}"},{"name":"testTriggerExceptionJson","body":"{\n\t\tResponseEntity\u003cMap\u003cString, Object\u003e\u003e resp \u003d rest.exchange(\n\t\t\t\tRequestEntity.get(\"http://localhost:\" + port + \"/oups\").build(),\n\t\t\t\tnew ParameterizedTypeReference\u003cMap\u003cString, Object\u003e\u003e() {\n\t\t\t\t});\n\t\tassertThat(resp).isNotNull();\n\t\tassertThat(resp.getStatusCode()).isEqualTo(HttpStatus.INTERNAL_SERVER_ERROR);\n\t\tassertThat(resp.getBody()).containsKey(\"timestamp\");\n\t\tassertThat(resp.getBody()).containsKey(\"status\");\n\t\tassertThat(resp.getBody()).containsKey(\"error\");\n\t\tassertThat(resp.getBody()).containsEntry(\"message\",\n\t\t\t\t\"Expected: controller used to showcase what happens when an exception is thrown\");\n\t\tassertThat(resp.getBody()).containsEntry(\"path\", \"/oups\");\n\t}"},{"name":"shouldUpdateOwner","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(1);\n\t\tassertThat(optionalOwner).isPresent();\n\t\tOwner owner \u003d optionalOwner.get();\n\t\tString oldLastName \u003d owner.getLastName();\n\t\tString newLastName \u003d oldLastName + \"X\";\n\n\t\towner.setLastName(newLastName);\n\t\tthis.owners.save(owner);\n\n\t\t// retrieving new name from database\n\t\toptionalOwner \u003d this.owners.findById(1);\n\t\tassertThat(optionalOwner).isPresent();\n\t\towner \u003d optionalOwner.get();\n\t\tassertThat(owner.getLastName()).isEqualTo(newLastName);\n\t}"},{"name":"shouldFindVets","body":"{\n\t\tCollection\u003cVet\u003e vets \u003d this.vets.findAll();\n\n\t\tVet vet \u003d EntityUtils.getById(vets, Vet.class, 3);\n\t\tassertThat(vet.getLastName()).isEqualTo(\"Douglas\");\n\t\tassertThat(vet.getNrOfSpecialties()).isEqualTo(2);\n\t\tassertThat(vet.getSpecialties().get(0).getName()).isEqualTo(\"dentistry\");\n\t\tassertThat(vet.getSpecialties().get(1).getName()).isEqualTo(\"surgery\");\n\t}"},{"name":"shouldInsertOwner","body":"{\n\t\tPage\u003cOwner\u003e owners \u003d this.owners.findByLastNameStartingWith(\"Schultz\", pageable);\n\t\tint found \u003d (int) owners.getTotalElements();\n\n\t\tOwner owner \u003d new Owner();\n\t\towner.setFirstName(\"Sam\");\n\t\towner.setLastName(\"Schultz\");\n\t\towner.setAddress(\"4, Evans Street\");\n\t\towner.setCity(\"Wollongong\");\n\t\towner.setTelephone(\"4444444444\");\n\t\tthis.owners.save(owner);\n\t\tassertThat(owner.getId()).isNotZero();\n\n\t\towners \u003d this.owners.findByLastNameStartingWith(\"Schultz\", pageable);\n\t\tassertThat(owners.getTotalElements()).isEqualTo(found + 1);\n\t}"},{"name":"shouldFindAllPetTypes","body":"{\n\t\tCollection\u003cPetType\u003e petTypes \u003d this.types.findPetTypes();\n\n\t\tPetType petType1 \u003d EntityUtils.getById(petTypes, PetType.class, 1);\n\t\tassertThat(petType1.getName()).isEqualTo(\"cat\");\n\t\tPetType petType4 \u003d EntityUtils.getById(petTypes, PetType.class, 4);\n\t\tassertThat(petType4.getName()).isEqualTo(\"snake\");\n\t}"},{"name":"shouldFindVisitsByPetId","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(6);\n\t\tassertThat(optionalOwner).isPresent();\n\t\tOwner owner6 \u003d optionalOwner.get();\n\n\t\tPet pet7 \u003d owner6.getPet(7);\n\t\tCollection\u003cVisit\u003e visits \u003d pet7.getVisits();\n\n\t\tassertThat(visits) //\n\t\t\t.hasSize(2) //\n\t\t\t.element(0)\n\t\t\t.extracting(Visit::getDate)\n\t\t\t.isNotNull();\n\t}"},{"name":"shouldInsertPetIntoDatabaseAndGenerateId","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(6);\n\t\tassertThat(optionalOwner).isPresent();\n\t\tOwner owner6 \u003d optionalOwner.get();\n\n\t\tint found \u003d owner6.getPets().size();\n\n\t\tPet pet \u003d new Pet();\n\t\tpet.setName(\"bowser\");\n\t\tCollection\u003cPetType\u003e types \u003d this.types.findPetTypes();\n\t\tpet.setType(EntityUtils.getById(types, PetType.class, 2));\n\t\tpet.setBirthDate(LocalDate.now());\n\t\towner6.addPet(pet);\n\t\tassertThat(owner6.getPets()).hasSize(found + 1);\n\n\t\tthis.owners.save(owner6);\n\n\t\toptionalOwner \u003d this.owners.findById(6);\n\t\tassertThat(optionalOwner).isPresent();\n\t\towner6 \u003d optionalOwner.get();\n\t\tassertThat(owner6.getPets()).hasSize(found + 1);\n\t\t// checks that id has been generated\n\t\tpet \u003d owner6.getPet(\"bowser\");\n\t\tassertThat(pet.getId()).isNotNull();\n\t}"},{"name":"shouldUpdatePetName","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(6);\n\t\tassertThat(optionalOwner).isPresent();\n\t\tOwner owner6 \u003d optionalOwner.get();\n\n\t\tPet pet7 \u003d owner6.getPet(7);\n\t\tString oldName \u003d pet7.getName();\n\n\t\tString newName \u003d oldName + \"X\";\n\t\tpet7.setName(newName);\n\t\tthis.owners.save(owner6);\n\n\t\toptionalOwner \u003d this.owners.findById(6);\n\t\tassertThat(optionalOwner).isPresent();\n\t\towner6 \u003d optionalOwner.get();\n\t\tpet7 \u003d owner6.getPet(7);\n\t\tassertThat(pet7.getName()).isEqualTo(newName);\n\t}"},{"name":"shouldFindOwnersByLastName","body":"{\n\t\tPage\u003cOwner\u003e owners \u003d this.owners.findByLastNameStartingWith(\"Davis\", pageable);\n\t\tassertThat(owners).hasSize(2);\n\n\t\towners \u003d this.owners.findByLastNameStartingWith(\"Daviss\", pageable);\n\t\tassertThat(owners).isEmpty();\n\t}"},{"name":"shouldAddNewVisitForPet","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(6);\n\t\tassertThat(optionalOwner).isPresent();\n\t\tOwner owner6 \u003d optionalOwner.get();\n\n\t\tPet pet7 \u003d owner6.getPet(7);\n\t\tint found \u003d pet7.getVisits().size();\n\t\tVisit visit \u003d new Visit();\n\t\tvisit.setDescription(\"test\");\n\n\t\towner6.addVisit(pet7.getId(), visit);\n\t\tthis.owners.save(owner6);\n\n\t\tassertThat(pet7.getVisits()) //\n\t\t\t.hasSize(found + 1) //\n\t\t\t.allMatch(value -\u003e value.getId() !\u003d null);\n\t}"},{"name":"shouldFindSingleOwnerWithPet","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(1);\n\t\tassertThat(optionalOwner).isPresent();\n\t\tOwner owner \u003d optionalOwner.get();\n\t\tassertThat(owner.getLastName()).startsWith(\"Franklin\");\n\t\tassertThat(owner.getPets()).hasSize(1);\n\t\tassertThat(owner.getPets().get(0).getType()).isNotNull();\n\t\tassertThat(owner.getPets().get(0).getType().getName()).isEqualTo(\"cat\");\n\t}"},{"name":"checkNonInternationalizedStrings","body":"{\n\t\tPath root \u003d Paths.get(\"src/main\");\n\t\tList\u003cPath\u003e files;\n\n\t\ttry (Stream\u003cPath\u003e stream \u003d Files.walk(root)) {\n\t\t\tfiles \u003d stream.filter(p -\u003e p.toString().endsWith(\".java\") || p.toString().endsWith(\".html\"))\n\t\t\t\t.filter(p -\u003e !p.toString().contains(\"/test/\"))\n\t\t\t\t.filter(p -\u003e !p.getFileName().toString().endsWith(\"Test.java\"))\n\t\t\t\t.toList();\n\t\t}\n\n\t\tStringBuilder report \u003d new StringBuilder();\n\n\t\tfor (Path file : files) {\n\t\t\tList\u003cString\u003e lines \u003d Files.readAllLines(file);\n\t\t\tfor (int i \u003d 0; i \u003c lines.size(); i++) {\n\t\t\t\tString line \u003d lines.get(i).trim();\n\n\t\t\t\tif (line.startsWith(\"//\") || line.startsWith(\"@\") || line.contains(\"log.\")\n\t\t\t\t\t\t|| line.contains(\"System.out\"))\n\t\t\t\t\tcontinue;\n\n\t\t\t\tif (file.toString().endsWith(\".html\")) {\n\t\t\t\t\tboolean hasLiteralText \u003d HTML_TEXT_LITERAL.matcher(line).find();\n\t\t\t\t\tboolean hasThTextAttribute \u003d HAS_TH_TEXT_ATTRIBUTE.matcher(line).find();\n\t\t\t\t\tboolean isBracketOnly \u003d BRACKET_ONLY.matcher(line).find();\n\n\t\t\t\t\tif (hasLiteralText \u0026\u0026 !line.contains(\"#{\") \u0026\u0026 !hasThTextAttribute \u0026\u0026 !isBracketOnly) {\n\t\t\t\t\t\treport.append(\"HTML: \")\n\t\t\t\t\t\t\t.append(file)\n\t\t\t\t\t\t\t.append(\" Line \")\n\t\t\t\t\t\t\t.append(i + 1)\n\t\t\t\t\t\t\t.append(\": \")\n\t\t\t\t\t\t\t.append(line)\n\t\t\t\t\t\t\t.append(\"\\n\");\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif (!report.isEmpty()) {\n\t\t\tfail(\"Hardcoded (non-internationalized) strings found:\\n\" + report);\n\t\t}\n\t}"},{"name":"checkI18nPropertyFilesAreInSync","body":"{\n\t\tList\u003cPath\u003e propertyFiles;\n\t\ttry (Stream\u003cPath\u003e stream \u003d Files.walk(Paths.get(I18N_DIR))) {\n\t\t\tpropertyFiles \u003d stream.filter(p -\u003e p.getFileName().toString().startsWith(BASE_NAME))\n\t\t\t\t.filter(p -\u003e p.getFileName().toString().endsWith(PROPERTIES))\n\t\t\t\t.toList();\n\t\t}\n\n\t\tMap\u003cString, Properties\u003e localeToProps \u003d new HashMap\u003c\u003e();\n\n\t\tfor (Path path : propertyFiles) {\n\t\t\tProperties props \u003d new Properties();\n\t\t\ttry (var reader \u003d Files.newBufferedReader(path)) {\n\t\t\t\tprops.load(reader);\n\t\t\t\tlocaleToProps.put(path.getFileName().toString(), props);\n\t\t\t}\n\t\t}\n\n\t\tString baseFile \u003d BASE_NAME + PROPERTIES;\n\t\tProperties baseProps \u003d localeToProps.get(baseFile);\n\t\tif (baseProps \u003d\u003d null) {\n\t\t\tfail(\"Base properties file \u0027\" + baseFile + \"\u0027 not found.\");\n\t\t\treturn;\n\t\t}\n\n\t\tSet\u003cString\u003e baseKeys \u003d baseProps.stringPropertyNames();\n\t\tStringBuilder report \u003d new StringBuilder();\n\n\t\tfor (Map.Entry\u003cString, Properties\u003e entry : localeToProps.entrySet()) {\n\t\t\tString fileName \u003d entry.getKey();\n\t\t\t// We use fallback logic to include english strings, hence messages_en is not\n\t\t\t// populated.\n\t\t\tif (fileName.equals(baseFile) || fileName.equals(\"messages_en.properties\"))\n\t\t\t\tcontinue;\n\n\t\t\tProperties props \u003d entry.getValue();\n\t\t\tSet\u003cString\u003e missingKeys \u003d new TreeSet\u003c\u003e(baseKeys);\n\t\t\tmissingKeys.removeAll(props.stringPropertyNames());\n\n\t\t\tif (!missingKeys.isEmpty()) {\n\t\t\t\treport.append(\"Missing keys in \").append(fileName).append(\":\\n\");\n\t\t\t\tmissingKeys.forEach(k -\u003e report.append(\" \").append(k).append(\"\\n\"));\n\t\t\t}\n\t\t}\n\n\t\tif (!report.isEmpty()) {\n\t\t\tfail(\"Translation files are not in sync:\\n\" + report);\n\t\t}\n\t}"},{"name":"printProperties","body":"{\n\t\t\tfor (EnumerablePropertySource\u003c?\u003e source : findPropertiesPropertySources()) {\n\t\t\t\tlog.info(\"PropertySource: \" + source.getName());\n\t\t\t\tString[] names \u003d source.getPropertyNames();\n\t\t\t\tArrays.sort(names);\n\t\t\t\tfor (String name : names) {\n\t\t\t\t\tString resolved \u003d environment.getProperty(name);\n\n\t\t\t\t\tassertNotNull(resolved, \"resolved environment property: \" + name + \" is null.\");\n\n\t\t\t\t\tObject sourceProperty \u003d source.getProperty(name);\n\n\t\t\t\t\tassertNotNull(sourceProperty, \"source property was expecting an object but is null.\");\n\n\t\t\t\t\tassertNotNull(sourceProperty.toString(), \"source property toString() returned null.\");\n\n\t\t\t\t\tString value \u003d sourceProperty.toString();\n\t\t\t\t\tif (resolved.equals(value)) {\n\t\t\t\t\t\tlog.info(name + \"\u003d\" + resolved);\n\t\t\t\t\t}\n\t\t\t\t\telse {\n\t\t\t\t\t\tlog.info(name + \"\u003d\" + value + \" OVERRIDDEN to \" + resolved);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}"},{"name":"onApplicationEvent","body":"{\n\t\t\tif (isFirstRun) {\n\t\t\t\tenvironment \u003d event.getApplicationContext().getEnvironment();\n\t\t\t\tprintProperties();\n\t\t\t}\n\t\t\tisFirstRun \u003d false;\n\t\t}"},{"name":"findPropertiesPropertySources","body":"{\n\t\t\tList\u003cEnumerablePropertySource\u003c?\u003e\u003e sources \u003d new LinkedList\u003c\u003e();\n\t\t\tfor (PropertySource\u003c?\u003e source : environment.getPropertySources()) {\n\t\t\t\tif (source instanceof EnumerablePropertySource enumerable) {\n\t\t\t\t\tsources.add(enumerable);\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn sources;\n\t\t}"},{"name":"addVisit","body":"{\n\t\tgetVisits().add(visit);\n\t}"},{"name":"addVisit","body":"{\n\n\t\tAssert.notNull(petId, \"Pet identifier must not be null!\");\n\t\tAssert.notNull(visit, \"Visit must not be null!\");\n\n\t\tPet pet \u003d getPet(petId);\n\n\t\tAssert.notNull(pet, \"Invalid Pet identifier!\");\n\n\t\tpet.addVisit(visit);\n\t}"},{"name":"addPaginationModel","body":"{\n\t\tList\u003cVet\u003e listVets \u003d paginated.getContent();\n\t\tmodel.addAttribute(\"currentPage\", page);\n\t\tmodel.addAttribute(\"totalPages\", paginated.getTotalPages());\n\t\tmodel.addAttribute(\"totalItems\", paginated.getTotalElements());\n\t\tmodel.addAttribute(\"listVets\", listVets);\n\t\treturn \"vets/vetList\";\n\t}"},{"name":"addPaginationModel","body":"{\n\t\tList\u003cOwner\u003e listOwners \u003d paginated.getContent();\n\t\tmodel.addAttribute(\"currentPage\", page);\n\t\tmodel.addAttribute(\"totalPages\", paginated.getTotalPages());\n\t\tmodel.addAttribute(\"totalItems\", paginated.getTotalElements());\n\t\tmodel.addAttribute(\"listOwners\", listOwners);\n\t\treturn \"owners/ownersList\";\n\t}"},{"name":"setAllowedFields","body":"{\n\t\tdataBinder.setDisallowedFields(\"id\");\n\t}"},{"name":"setAllowedFields","body":"{\n\t\tdataBinder.setDisallowedFields(\"id\");\n\t}"},{"name":"initCreationForm","body":"{\n\t\treturn VIEWS_OWNER_CREATE_OR_UPDATE_FORM;\n\t}"},{"name":"initCreationForm","body":"{\n\t\tPet pet \u003d new Pet();\n\t\towner.addPet(pet);\n\t\treturn VIEWS_PETS_CREATE_OR_UPDATE_FORM;\n\t}"},{"name":"findOwner","body":"{\n\t\treturn ownerId \u003d\u003d null ? new Owner()\n\t\t\t\t: this.owners.findById(ownerId)\n\t\t\t\t\t.orElseThrow(() -\u003e new IllegalArgumentException(\"Owner not found with id: \" + ownerId\n\t\t\t\t\t\t\t+ \". Please ensure the ID is correct \" + \"and the owner exists in the database.\"));\n\t}"},{"name":"findOwner","body":"{\n\t\tOptional\u003cOwner\u003e optionalOwner \u003d this.owners.findById(ownerId);\n\t\tOwner owner \u003d optionalOwner.orElseThrow(() -\u003e new IllegalArgumentException(\n\t\t\t\t\"Owner not found with id: \" + ownerId + \". Please ensure the ID is correct \"));\n\t\treturn owner;\n\t}"},{"name":"processCreationForm","body":"{\n\t\tif (result.hasErrors()) {\n\t\t\tredirectAttributes.addFlashAttribute(\"error\", \"There was an error in creating the owner.\");\n\t\t\treturn VIEWS_OWNER_CREATE_OR_UPDATE_FORM;\n\t\t}\n\n\t\tthis.owners.save(owner);\n\t\tredirectAttributes.addFlashAttribute(\"message\", \"New Owner Created\");\n\t\treturn \"redirect:/owners/\" + owner.getId();\n\t}"},{"name":"processCreationForm","body":"{\n\n\t\tif (StringUtils.hasText(pet.getName()) \u0026\u0026 pet.isNew() \u0026\u0026 owner.getPet(pet.getName(), true) !\u003d null)\n\t\t\tresult.rejectValue(\"name\", \"duplicate\", \"already exists\");\n\n\t\tLocalDate currentDate \u003d LocalDate.now();\n\t\tif (pet.getBirthDate() !\u003d null \u0026\u0026 pet.getBirthDate().isAfter(currentDate)) {\n\t\t\tresult.rejectValue(\"birthDate\", \"typeMismatch.birthDate\");\n\t\t}\n\n\t\tif (result.hasErrors()) {\n\t\t\treturn VIEWS_PETS_CREATE_OR_UPDATE_FORM;\n\t\t}\n\n\t\towner.addPet(pet);\n\t\tthis.owners.save(owner);\n\t\tredirectAttributes.addFlashAttribute(\"message\", \"New Pet has been Added\");\n\t\treturn \"redirect:/owners/{ownerId}\";\n\t}"},{"name":"testProcessCreationFormSuccess","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/{ownerId}/pets/new\", TEST_OWNER_ID).param(\"name\", \"Betty\")\n\t\t\t\t.param(\"type\", \"hamster\")\n\t\t\t\t.param(\"birthDate\", \"2015-02-12\"))\n\t\t\t.andExpect(status().is3xxRedirection())\n\t\t\t.andExpect(view().name(\"redirect:/owners/{ownerId}\"));\n\t}"},{"name":"testProcessCreationFormSuccess","body":"{\n\t\tmockMvc\n\t\t\t.perform(post(\"/owners/new\").param(\"firstName\", \"Joe\")\n\t\t\t\t.param(\"lastName\", \"Bloggs\")\n\t\t\t\t.param(\"address\", \"123 Caramel Street\")\n\t\t\t\t.param(\"city\", \"London\")\n\t\t\t\t.param(\"telephone\", \"1316761638\"))\n\t\t\t.andExpect(status().is3xxRedirection());\n\t}"},{"name":"testInitCreationForm","body":"{\n\t\tmockMvc.perform(get(\"/owners/new\"))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(model().attributeExists(\"owner\"))\n\t\t\t.andExpect(view().name(\"owners/createOrUpdateOwnerForm\"));\n\t}"},{"name":"testInitCreationForm","body":"{\n\t\tmockMvc.perform(get(\"/owners/{ownerId}/pets/new\", TEST_OWNER_ID))\n\t\t\t.andExpect(status().isOk())\n\t\t\t.andExpect(view().name(\"pets/createOrUpdatePetForm\"))\n\t\t\t.andExpect(model().attributeExists(\"pet\"));\n\t}"},{"name":"testOwnerDetails","body":"{\n\t\tRestTemplate template \u003d builder.rootUri(\"http://localhost:\" + port).build();\n\t\tResponseEntity\u003cString\u003e result \u003d template.exchange(RequestEntity.get(\"/owners/1\").build(), String.class);\n\t\tassertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);\n\t}"},{"name":"testOwnerDetails","body":"{\n\t\tRestTemplate template \u003d builder.rootUri(\"http://localhost:\" + port).build();\n\t\tResponseEntity\u003cString\u003e result \u003d template.exchange(RequestEntity.get(\"/owners/1\").build(), String.class);\n\t\tassertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);\n\t}"},{"name":"testOwnerDetails","body":"{\n\t\tRestTemplate template \u003d builder.rootUri(\"http://localhost:\" + port).build();\n\t\tResponseEntity\u003cString\u003e result \u003d template.exchange(RequestEntity.get(\"/owners/1\").build(), String.class);\n\t\tassertThat(result.getStatusCode()).isEqualTo(HttpStatus.OK);\n\t}"},{"name":"testFindAll","body":"{\n\t\tvets.findAll();\n\t\tvets.findAll(); // served from cache\n\t}"},{"name":"testFindAll","body":"{\n\t\tvets.findAll();\n\t\tvets.findAll(); // served from cache\n\t}"},{"name":"testFindAll","body":"{\n\t\tvets.findAll();\n\t\tvets.findAll(); // served from cache\n\t}"},{"name":"setup","body":"{\n\n\t\tOwner george \u003d george();\n\t\tgiven(this.owners.findByLastNameStartingWith(eq(\"Franklin\"), any(Pageable.class)))\n\t\t\t.willReturn(new PageImpl\u003c\u003e(List.of(george)));\n\n\t\tgiven(this.owners.findById(TEST_OWNER_ID)).willReturn(Optional.of(george));\n\t\tVisit visit \u003d new Visit();\n\t\tvisit.setDate(LocalDate.now());\n\t\tgeorge.getPet(\"Max\").getVisits().add(visit);\n\n\t}"},{"name":"setup","body":"{\n\t\tgiven(this.vets.findAll()).willReturn(Lists.newArrayList(james(), helen()));\n\t\tgiven(this.vets.findAll(any(Pageable.class)))\n\t\t\t.willReturn(new PageImpl\u003cVet\u003e(Lists.newArrayList(james(), helen())));\n\n\t}"},{"name":"setup","body":"{\n\t\tthis.petTypeFormatter \u003d new PetTypeFormatter(types);\n\t}"},{"name":"setup","body":"{\n\t\tPetType cat \u003d new PetType();\n\t\tcat.setId(3);\n\t\tcat.setName(\"hamster\");\n\t\tgiven(this.types.findPetTypes()).willReturn(List.of(cat));\n\n\t\tOwner owner \u003d new Owner();\n\t\tPet pet \u003d new Pet();\n\t\tPet dog \u003d new Pet();\n\t\towner.addPet(pet);\n\t\towner.addPet(dog);\n\t\tpet.setId(TEST_PET_ID);\n\t\tdog.setId(TEST_PET_ID + 1);\n\t\tpet.setName(\"petty\");\n\t\tdog.setName(\"doggy\");\n\t\tgiven(this.owners.findById(TEST_OWNER_ID)).willReturn(Optional.of(owner));\n\t}"},{"name":"supports","body":"{\n\t\treturn Pet.class.isAssignableFrom(clazz);\n\t}"},{"name":"getDate","body":"{\n\t\treturn this.date;\n\t}"},{"name":"setId","body":"{\n\t\tthis.id \u003d id;\n\t}"},{"name":"available","body":"{\n\t\tassumeTrue(DockerClientFactory.instance().isDockerAvailable(), \"Docker not available\");\n\t}"},{"name":"setType","body":"{\n\t\tthis.type \u003d type;\n\t}"},{"name":"validate","body":"{\n\t\tPet pet \u003d (Pet) obj;\n\t\tString name \u003d pet.getName();\n\t\t// name validation\n\t\tif (!StringUtils.hasText(name)) {\n\t\t\terrors.rejectValue(\"name\", REQUIRED, REQUIRED);\n\t\t}\n\n\t\t// type validation\n\t\tif (pet.isNew() \u0026\u0026 pet.getType() \u003d\u003d null) {\n\t\t\terrors.rejectValue(\"type\", REQUIRED, REQUIRED);\n\t\t}\n\n\t\t// birth date validation\n\t\tif (pet.getBirthDate() \u003d\u003d null) {\n\t\t\terrors.rejectValue(\"birthDate\", REQUIRED, REQUIRED);\n\t\t}\n\t}"},{"name":"print","body":"{\n\t\tString name \u003d petType.getName();\n\t\treturn (name !\u003d null) ? name : \"\u003cnull\u003e\";\n\t}"},{"name":"main","body":"{\n\t\tSpringApplication.run(PetClinicApplication.class, \"--spring.profiles.active\u003dmysql\",\n\t\t\t\t\"--spring.docker.compose.enabled\u003dfalse\");\n\t}"},{"name":"main","body":"{\n\t\tSpringApplication.run(PetClinicApplication.class, args);\n\t}"},{"name":"main","body":"{\n\t\tSpringApplication.run(PetClinicApplication.class, args);\n\t}"},{"name":"main","body":"{\n\t\tnew SpringApplicationBuilder(PetClinicApplication.class) //\n\t\t\t.profiles(\"postgres\") //\n\t\t\t.properties( //\n\t\t\t\t\t\"spring.docker.compose.start.arguments\u003dpostgres\" //\n\t\t\t) //\n\t\t\t.listeners(new PropertiesLogger()) //\n\t\t\t.run(args);\n\t}"},{"name":"init","body":"{\n\t\tOwner owner \u003d new Owner();\n\t\tPet pet \u003d new Pet();\n\t\towner.addPet(pet);\n\t\tpet.setId(TEST_PET_ID);\n\t\tgiven(this.owners.findById(TEST_OWNER_ID)).willReturn(Optional.of(owner));\n\t}"},{"name":"parse","body":"{\n\t\tCollection\u003cPetType\u003e findPetTypes \u003d this.types.findPetTypes();\n\t\tfor (PetType type : findPetTypes) {\n\t\t\tif (Objects.equals(type.getName(), text)) {\n\t\t\t\treturn type;\n\t\t\t}\n\t\t}\n\t\tthrow new ParseException(\"type not found: \" + text, 0);\n\t}"},{"name":"toString","body":"{\n\t\treturn new ToStringCreator(this).append(\"id\", this.getId())\n\t\t\t.append(\"new\", this.isNew())\n\t\t\t.append(\"lastName\", this.getLastName())\n\t\t\t.append(\"firstName\", this.getFirstName())\n\t\t\t.append(\"address\", this.address)\n\t\t\t.append(\"city\", this.city)\n\t\t\t.append(\"telephone\", this.telephone)\n\t\t\t.toString();\n\t}"},{"name":"toString","body":"{\n\t\tString name \u003d this.getName();\n\t\treturn (name !\u003d null) ? name : \"\u003cnull\u003e\";\n\t}"}]