use of com.eventyay.organizer.data.ticket.Ticket in project open-event-orga-app by fossasia.
the class TicketCreateViewModelTest method shouldInitializeTicket.
@Test
public void shouldInitializeTicket() {
Ticket ticket = createTicketViewModel.getTicket();
Assert.assertEquals("free", ticket.getType());
Assert.assertNotNull(ticket.getSalesStartsAt());
Assert.assertNotNull(ticket.getSalesEndsAt());
}
use of com.eventyay.organizer.data.ticket.Ticket in project open-event-orga-app by fossasia.
the class TicketCreateViewModelTest method shouldShowErrorOnFailure.
@Test
public void shouldShowErrorOnFailure() {
String errorString = "Error";
Ticket ticket = createTicketViewModel.getTicket();
ContextManager.setSelectedEvent(event);
when(ticketRepository.createTicket(ticket)).thenReturn(Observable.error(new Throwable("Error")));
String isoDateNow = DateUtils.formatDateToIso(LocalDateTime.now());
String isoDateThen = DateUtils.formatDateToIso(LocalDateTime.MAX);
ticket.setSalesStartsAt(isoDateNow);
ticket.setSalesEndsAt(isoDateThen);
InOrder inOrder = inOrder(progress, error);
createTicketViewModel.getProgress().observeForever(progress);
createTicketViewModel.getError().observeForever(error);
createTicketViewModel.createTicket();
inOrder.verify(progress).onChanged(true);
inOrder.verify(error).onChanged(errorString);
inOrder.verify(progress).onChanged(false);
ContextManager.setSelectedEvent(null);
}
use of com.eventyay.organizer.data.ticket.Ticket in project open-event-orga-app by fossasia.
the class TicketCreateViewModelTest method shouldRejectWrongSaleDates.
@Test
public void shouldRejectWrongSaleDates() {
Ticket ticket = createTicketViewModel.getTicket();
String isoDate = DateUtils.formatDateToIso(LocalDateTime.now());
ticket.setSalesStartsAt(isoDate);
ticket.setSalesEndsAt(isoDate);
InOrder inOrder = inOrder(error);
createTicketViewModel.getError().observeForever(error);
createTicketViewModel.createTicket();
inOrder.verify(error).onChanged(anyString());
verify(ticketRepository, never()).createTicket(any());
}
use of com.eventyay.organizer.data.ticket.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 com.eventyay.organizer.data.ticket.Ticket in project open-event-orga-app by fossasia.
the class TicketDetailFragment method doPrint.
private void doPrint() {
PrintManager printManager;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
printManager = (PrintManager) getActivity().getSystemService(Context.PRINT_SERVICE);
String jobName = this.getString(R.string.app_name) + " Document";
Ticket ticket = ticketDetailViewModel.getTicket().getValue();
printManager.print(jobName, new TicketPrintAdapter(getActivity(), ticket), null);
} else {
ViewUtils.showSnackbar(binding.getRoot(), "No Printing Support!");
}
}
Aggregations