use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketRepositoryTest method shouldSetEventOnCreatedTicket.
@Test
public void shouldSetEventOnCreatedTicket() {
Ticket created = mock(Ticket.class);
when(utilModel.isConnected()).thenReturn(true);
when(eventService.postTicket(TICKET)).thenReturn(Observable.just(created));
when(databaseRepository.save(eq(Ticket.class), eq(created))).thenReturn(Completable.complete());
ticketRepository.createTicket(TICKET).subscribe();
verify(created).setEvent(EVENT);
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketCreatePresenterTest method shouldShowErrorOnFailure.
@Test
public void shouldShowErrorOnFailure() {
Ticket ticket = createTicketPresenter.getTicket();
when(ticketRepository.createTicket(ticket)).thenReturn(Observable.error(new Throwable("Error")));
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateThen = DateUtils.formatDateToIso(LocalDateTime.MAX);
ticket.getSalesStartsAt().set(isoDateNow);
ticket.getSalesEndsAt().set(isoDateThen);
createTicketPresenter.createTicket();
InOrder inOrder = Mockito.inOrder(ticketsView);
inOrder.verify(ticketsView).showProgress(true);
inOrder.verify(ticketsView).showError("Error");
inOrder.verify(ticketsView).showProgress(false);
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketCreatePresenterTest method shouldAcceptCorrectSaleDates.
@Test
public void shouldAcceptCorrectSaleDates() {
Ticket ticket = createTicketPresenter.getTicket();
when(ticketRepository.createTicket(ticket)).thenReturn(Observable.empty());
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateThen = DateUtils.formatDateToIso(LocalDateTime.MAX);
ticket.getSalesStartsAt().set(isoDateNow);
ticket.getSalesEndsAt().set(isoDateThen);
createTicketPresenter.createTicket();
verify(ticketsView, never()).showError(anyString());
verify(ticketRepository).createTicket(ticket);
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketCreatePresenterTest method shouldRejectWrongSaleDates.
@Test
public void shouldRejectWrongSaleDates() {
Ticket ticket = createTicketPresenter.getTicket();
String isoDate = DateUtils.formatDateToIso(LocalDateTime.now());
ticket.getSalesStartsAt().set(isoDate);
ticket.getSalesEndsAt().set(isoDate);
createTicketPresenter.createTicket();
verify(ticketsView).showError(anyString());
verify(ticketRepository, never()).createTicket(any());
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketCreatePresenterTest method shouldInitializeTicket.
@Test
public void shouldInitializeTicket() {
Ticket ticket = createTicketPresenter.getTicket();
assertEquals("free", ticket.getType());
assertNotNull(ticket.getSalesStartsAt());
assertNotNull(ticket.getSalesEndsAt());
}
Aggregations