use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketRepositoryTest method shouldSaveCreatedTicket.
@Test
public void shouldSaveCreatedTicket() {
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(databaseRepository).save(Ticket.class, created);
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketCreatePresenterTest method shouldShowSuccessOnCreated.
@Test
public void shouldShowSuccessOnCreated() {
Ticket ticket = createTicketPresenter.getTicket();
when(ticketRepository.createTicket(ticket)).thenReturn(Observable.just(ticket));
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).onSuccess(anyString());
inOrder.verify(ticketsView).dismiss();
inOrder.verify(ticketsView).showProgress(false);
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketsPresenterTest method testProgressbarOnSwipeRefreshNoItem.
@Test
public void testProgressbarOnSwipeRefreshNoItem() {
List<Ticket> emptyList = new ArrayList<>();
when(ticketRepository.getTickets(ID, true)).thenReturn(Observable.fromIterable(emptyList));
ticketsPresenter.loadTickets(true);
InOrder inOrder = Mockito.inOrder(ticketsView);
inOrder.verify(ticketsView).showProgress(true);
inOrder.verify(ticketsView).onRefreshComplete(true);
inOrder.verify(ticketsView).showProgress(false);
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class TicketTest method setUp.
@Override
public void setUp() {
RxJavaPlugins.setIoSchedulerHandler(scheduler -> Schedulers.trampoline());
RxAndroidPlugins.setInitMainThreadSchedulerHandler(schedulerCallable -> Schedulers.trampoline());
Event event = new Event();
event.setId(Long.valueOf(12));
Ticket ticket1 = Ticket.builder().id(1L).quantity(120L).type(FREE).event(event).build();
Ticket ticket2 = Ticket.builder().id(2L).quantity(20L).type(PAID).price(25.99f).event(event).build();
Ticket ticket3 = Ticket.builder().id(3L).quantity(30L).type(DONATION).event(event).build();
Ticket ticket4 = Ticket.builder().id(4L).quantity(10L).type(DONATION).event(event).build();
Ticket ticket5 = Ticket.builder().id(5L).quantity(50L).type(PAID).price(99.99f).event(event).build();
Attendee attendee = Attendee.builder().id(1L).ticket(ticket1).event(event).build();
Attendee attendee2 = Attendee.builder().id(2L).ticket(ticket1).event(event).build();
Attendee attendee3 = Attendee.builder().id(3L).ticket(ticket1).event(event).build();
Attendee attendee4 = Attendee.builder().id(4L).ticket(ticket2).event(event).build();
Attendee attendee5 = Attendee.builder().id(5L).ticket(ticket2).event(event).build();
Attendee attendee6 = Attendee.builder().id(6L).ticket(ticket4).event(event).build();
Attendee attendee7 = Attendee.builder().id(7L).ticket(ticket5).event(event).build();
event.setTickets(Arrays.asList(ticket1, ticket2, ticket3, ticket4, ticket5));
DatabaseRepository databaseRepository = new DatabaseRepository();
databaseRepository.save(Event.class, event).subscribe();
databaseRepository.saveList(Attendee.class, Arrays.asList(attendee, attendee2, attendee3, attendee4, attendee5, attendee6, attendee7)).subscribe();
ticketRepository = new TicketRepository(null, databaseRepository, null);
}
use of org.fossasia.openevent.app.data.models.Ticket in project open-event-orga-app by fossasia.
the class EventDelegate method getEventTickets.
@Override
@JsonIgnore
public List<Ticket> getEventTickets() {
List<Ticket> tickets = event.getTickets();
if (tickets != null && !tickets.isEmpty()) {
for (Ticket ticket : tickets) ticket.setEvent(event);
return tickets;
}
event.setTickets(SQLite.select().from(Ticket.class).where(Ticket_Table.event_id.eq(event.getId())).queryList());
return tickets;
}
Aggregations