Search in sources :

Example 6 with Ticket

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);
}
Also used : Ticket(org.fossasia.openevent.app.data.models.Ticket) Test(org.junit.Test)

Example 7 with Ticket

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);
}
Also used : Ticket(org.fossasia.openevent.app.data.models.Ticket) InOrder(org.mockito.InOrder) ObservableString(org.fossasia.openevent.app.data.models.dto.ObservableString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 8 with Ticket

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);
}
Also used : Ticket(org.fossasia.openevent.app.data.models.Ticket) ObservableString(org.fossasia.openevent.app.data.models.dto.ObservableString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 9 with 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());
}
Also used : Ticket(org.fossasia.openevent.app.data.models.Ticket) ObservableString(org.fossasia.openevent.app.data.models.dto.ObservableString) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Example 10 with Ticket

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());
}
Also used : Ticket(org.fossasia.openevent.app.data.models.Ticket) Test(org.junit.Test)

Aggregations

Ticket (org.fossasia.openevent.app.data.models.Ticket)10 Test (org.junit.Test)8 ObservableString (org.fossasia.openevent.app.data.models.dto.ObservableString)4 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)4 InOrder (org.mockito.InOrder)3 JsonIgnore (com.fasterxml.jackson.annotation.JsonIgnore)1 ArrayList (java.util.ArrayList)1 DatabaseRepository (org.fossasia.openevent.app.data.db.DatabaseRepository)1 Attendee (org.fossasia.openevent.app.data.models.Attendee)1 Event (org.fossasia.openevent.app.data.models.Event)1 TicketRepository (org.fossasia.openevent.app.data.repository.TicketRepository)1