@Test void shouldThrowPetNotFoundException_whenNotFound() { BDDMockito.given(petRepository.findById(PET_ID)).willReturn(Optional.empty()); Assertions.assertThrows(PetNotFoundException.class, () -> petFinder.findById(PET_ID)); }
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);  }