use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.
the class CreateCopyrightViewModelTest method shouldShowErrorOnInvalidYear.
@Test
public void shouldShowErrorOnInvalidYear() {
Copyright copyright = createCopyrightViewModel.getCopyright();
copyright.setYear("25");
InOrder inOrder = Mockito.inOrder(error);
createCopyrightViewModel.getError().observeForever(error);
createCopyrightViewModel.createCopyright();
inOrder.verify(error).onChanged("Please Enter a Valid Year");
}
use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.
the class UpdateCopyrightViewModelTest method shouldShowErrorOnInvalidYear.
@Test
public void shouldShowErrorOnInvalidYear() {
Copyright copyright = updateCopyrightViewModel.getCopyright();
copyright.setYear("25");
InOrder inOrder = Mockito.inOrder(error);
updateCopyrightViewModel.getError().observeForever(error);
updateCopyrightViewModel.updateCopyright();
inOrder.verify(error).onChanged("Please Enter a Valid Year");
}
use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.
the class UpdateCopyrightViewModelTest method shouldAcceptCorrectYear.
@Test
public void shouldAcceptCorrectYear() {
ContextManager.setSelectedEvent(event);
Copyright copyright = updateCopyrightViewModel.getCopyright();
copyright.setYear("2018");
when(copyrightRepository.updateCopyright(copyright)).thenReturn(Observable.just(copyright));
InOrder inOrder = Mockito.inOrder(success);
updateCopyrightViewModel.getSuccess().observeForever(success);
updateCopyrightViewModel.updateCopyright();
inOrder.verify(success).onChanged(anyString());
ContextManager.setSelectedEvent(null);
}
use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.
the class UpdateCopyrightViewModelTest method shouldShowErrorOnFailure.
@Test
public void shouldShowErrorOnFailure() {
ContextManager.setSelectedEvent(event);
Copyright copyright = updateCopyrightViewModel.getCopyright();
when(copyrightRepository.updateCopyright(copyright)).thenReturn(Observable.error(new Throwable("Error")));
updateCopyrightViewModel.updateCopyright();
updateCopyrightViewModel.getProgress().observeForever(progress);
updateCopyrightViewModel.getError().observeForever(error);
InOrder inOrder = Mockito.inOrder(progress, error);
updateCopyrightViewModel.updateCopyright();
inOrder.verify(progress).onChanged(true);
inOrder.verify(error).onChanged("Error");
inOrder.verify(progress).onChanged(false);
ContextManager.setSelectedEvent(null);
}
use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.
the class CreateCopyrightViewModel method createCopyright.
public void createCopyright() {
nullifyEmptyFields(copyright);
if (!verifyYear(copyright))
return;
long eventId = ContextManager.getSelectedEvent().getId();
Event event = new Event();
event.setId(eventId);
copyright.setEvent(event);
compositeDisposable.add(copyrightRepository.createCopyright(copyright).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(createdTicket -> {
success.setValue("Copyright Created");
dismiss.call();
}, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Aggregations