Skip to content

test: PetServiceTest – logik och behörighetskontroll #144

Description

@lindaeskilsson

Mocka: PetRepository, UserRepository, PetPolicy, MedicalRecordRepository
createPet:

OWNER skapar för sig själv (ownerId null) → sparas korrekt
ADMIN skapar med giltig ownerId → owner sätts korrekt
ADMIN utan ownerId → RuntimeException
ADMIN med ownerId som inte är OWNER → RuntimeException
Användare utan canCreate → RuntimeException

getPetById:

ADMIN hämtar vilket pet som helst → lyckas
OWNER hämtar eget pet → lyckas
OWNER hämtar annans pet utan veterinärsrelation → RuntimeException
VET med kopplad klinik och journalrelation → lyckas
VET utan klinik → RuntimeException
Pet finns inte → RuntimeException

getPetsByOwner:

OWNER hämtar sina egna → returnerar lista
OWNER försöker hämta annans → RuntimeException
ADMIN hämtar vems som helst → lyckas

updatePet:

OWNER uppdaterar eget pet → alla fält uppdateras
OWNER uppdaterar annans → RuntimeException
ADMIN uppdaterar vad som helst → lyckas

deletePet:

OWNER raderar eget pet → petRepository.delete() anropas
OWNER raderar annans → RuntimeException
Pet finns inte → RuntimeException
DataIntegrityViolationException → RuntimeException med meddelande om journaler

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions