36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
package dev.lions.unionflow.server.service;
|
|
|
|
import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
|
|
|
import io.quarkus.test.junit.QuarkusTest;
|
|
import jakarta.inject.Inject;
|
|
import jakarta.ws.rs.NotFoundException;
|
|
import org.junit.jupiter.api.DisplayName;
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
import java.util.UUID;
|
|
|
|
/**
|
|
* Tests pour TicketService — couvre la branche {@code ticket == null} dans
|
|
* {@code obtenirTicket()} via un UUID inexistant en base.
|
|
*
|
|
* <p>{@code BaseRepository.findById(UUID)} appelle {@code entityManager.find()}
|
|
* qui retourne {@code null} pour un ID inexistant → branche {@code ticket == null} couverte.
|
|
*/
|
|
@QuarkusTest
|
|
@DisplayName("TicketService — branche ticket == null dans obtenirTicket:40")
|
|
class TicketServiceMockCoverageTest {
|
|
|
|
@Inject
|
|
TicketService ticketService;
|
|
|
|
@Test
|
|
@DisplayName("obtenirTicket avec UUID inexistant → findById retourne null → NotFoundException (branche ticket == null)")
|
|
void obtenirTicket_findByIdRetourneNull_throwsNotFoundException() {
|
|
UUID inexistantId = UUID.randomUUID();
|
|
|
|
assertThatThrownBy(() -> ticketService.obtenirTicket(inexistantId))
|
|
.isInstanceOf(NotFoundException.class);
|
|
}
|
|
}
|