Commit 509ca272 authored by Angelo Veltens's avatar Angelo Veltens

store ticket, so that it can be looked up later

parent aee1b397
package de.codecentric.ticketscanner;
import org.aspectj.weaver.ast.Not;
import org.hibernate.cfg.NotYetImplementedException;
import org.springframework.stereotype.Component;
......@@ -8,4 +9,8 @@ public class RegisteredTickets {
public Ticket findBy(Code knownCode) {
throw new NotYetImplementedException();
}
public void store(Code generatedCode, Ticket ticketToRegister) {
throw new NotYetImplementedException();
}
}
......@@ -16,7 +16,9 @@ public class TicketScanner {
}
public Code register(Ticket ticket) {
return codeGenerator.generate();
Code code = codeGenerator.generate();
registeredTickets.store(code, ticket);
return code;
}
public Ticket scan(Code code) {
......
......@@ -12,6 +12,7 @@ import java.util.UUID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;
import static org.mockito.Mockito.verify;
@ExtendWith(MockitoExtension.class)
@DisplayName("given a ticket scanner")
......@@ -37,14 +38,15 @@ class TicketScannerSpec {
private Code ticketCode;
private Code generatedCode;
private Ticket ticketToRegister;
@BeforeEach
void setUp() {
Ticket registeredTicket = new Ticket(UUID.randomUUID());
ticketToRegister = new Ticket(UUID.randomUUID());
generatedCode = new Code(CODE);
given(codeGenerator.generate()).willReturn(generatedCode);
ticketCode = ticketScanner.register(registeredTicket);
ticketCode = ticketScanner.register(ticketToRegister);
}
@Test
......@@ -53,6 +55,11 @@ class TicketScannerSpec {
assertThat(ticketCode).isEqualTo(generatedCode);
}
@Test
@DisplayName("then the ticket is stored")
void stores_the_ticket() {
verify(registeredTickets).store(generatedCode, ticketToRegister);
}
}
@Nested
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment