@Test void shouldReturnAPet_whenFound() { var pet = new Pet(); pet.setPetId(PET_ID); BDDMockito.given(petRepository.findById(PET_ID)).willReturn(Optional.of(pet)); var petFound = petFinder.findById(PET_ID); Assertions.assertNotNull(petFound); Assertions.assertEquals(PET_ID, petFound.getPetId()); }
public Pet findById(String petId) { return petRepository.findById(petId).orElseThrow(() -> new PetNotFoundException(petId)); }
PetFinder { public Pet findById(String petId) { return petRepository.findById(petId).orElseThrow(() -> new PetNotFoundException(petId)); } }
PetFinder { public Pet findById(String petId) { return petRepository.findById(petId).orElseThrow(() -> new PetNotFoundException(petId)); } PetFinder(PetRepository petRepository); }
PetFinder { public Pet findById(String petId) { return petRepository.findById(petId).orElseThrow(() -> new PetNotFoundException(petId)); } PetFinder(PetRepository petRepository); Pet findById(String petId); }
PetFinder { public Pet findById(String petId) { return petRepository.findById(petId).orElseThrow(() -> new PetNotFoundException(petId)); } PetFinder(PetRepository petRepository); Pet findById(String petId);  }