use of com.eventyay.organizer.data.faq.Faq in project open-event-orga-app by fossasia.
the class CreateFaqViewModelTest method shouldShowSuccessOnCreated.
@Test
public void shouldShowSuccessOnCreated() {
String successString = "Faq Created";
Faq faq = createFaqViewModel.getFaq();
when(faqRepository.createFaq(faq)).thenReturn(Observable.just(faq));
ContextManager.setSelectedEvent(event);
InOrder inOrder = Mockito.inOrder(progress, dismiss, success);
createFaqViewModel.getProgress().observeForever(progress);
createFaqViewModel.getDismiss().observeForever(dismiss);
createFaqViewModel.getSuccess().observeForever(success);
createFaqViewModel.createFaq();
inOrder.verify(progress).onChanged(true);
inOrder.verify(success).onChanged(successString);
inOrder.verify(dismiss).onChanged(null);
inOrder.verify(progress).onChanged(false);
ContextManager.setSelectedEvent(null);
}
use of com.eventyay.organizer.data.faq.Faq in project open-event-orga-app by fossasia.
the class CreateFaqViewModelTest method shouldShowErrorOnFailure.
@Test
public void shouldShowErrorOnFailure() {
Faq faq = createFaqViewModel.getFaq();
when(faqRepository.createFaq(faq)).thenReturn(Observable.error(new Throwable("Error")));
ContextManager.setSelectedEvent(event);
InOrder inOrder = Mockito.inOrder(progress, error);
createFaqViewModel.getProgress().observeForever(progress);
createFaqViewModel.getError().observeForever(error);
createFaqViewModel.createFaq();
inOrder.verify(progress).onChanged(true);
inOrder.verify(error).onChanged("Error");
inOrder.verify(progress).onChanged(false);
ContextManager.setSelectedEvent(null);
}
use of com.eventyay.organizer.data.faq.Faq in project open-event-orga-app by fossasia.
the class CreateFaqViewModel method createFaq.
public void createFaq() {
long eventId = ContextManager.getSelectedEvent().getId();
Event event = new Event();
event.setId(eventId);
faq.setEvent(event);
compositeDisposable.add(faqRepository.createFaq(faq).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdFaq -> {
success.setValue("Faq Created");
dismiss.call();
}, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Aggregations