Search in sources :

Example 11 with Copyright

use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.

the class UpdateCopyrightViewModel method updateCopyright.

public void updateCopyright() {
    nullifyEmptyFields(copyright);
    if (!verifyYear(copyright))
        return;
    long eventId = ContextManager.getSelectedEvent().getId();
    Event event = new Event();
    event.setId(eventId);
    copyright.setEvent(event);
    compositeDisposable.add(copyrightRepository.updateCopyright(copyright).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedTicket -> {
        success.setValue("Copyright Updated");
        dismiss.call();
    }, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
Also used : Inject(javax.inject.Inject) LiveData(androidx.lifecycle.LiveData) SingleEventLiveData(com.eventyay.organizer.common.livedata.SingleEventLiveData) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Event(com.eventyay.organizer.data.event.Event) Copyright(com.eventyay.organizer.data.copyright.Copyright) ViewModel(androidx.lifecycle.ViewModel) CopyrightRepository(com.eventyay.organizer.data.copyright.CopyrightRepository) ContextManager(com.eventyay.organizer.common.ContextManager) ErrorUtils(com.eventyay.organizer.utils.ErrorUtils) StringUtils(com.eventyay.organizer.utils.StringUtils) Event(com.eventyay.organizer.data.event.Event)

Example 12 with Copyright

use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.

the class CopyrightRepositoryTest method shouldSetEventOnCreatedCopyright.

@Test
public void shouldSetEventOnCreatedCopyright() {
    Copyright created = mock(Copyright.class);
    when(repository.isConnected()).thenReturn(true);
    when(copyrightApi.postCopyright(COPYRIGHT)).thenReturn(Observable.just(created));
    when(repository.save(eq(Copyright.class), eq(created))).thenReturn(Completable.complete());
    copyrightRepository.createCopyright(COPYRIGHT).subscribe();
    verify(created).setEvent(EVENT);
}
Also used : Copyright(com.eventyay.organizer.data.copyright.Copyright) Test(org.junit.Test)

Example 13 with Copyright

use of com.eventyay.organizer.data.copyright.Copyright in project open-event-orga-app by fossasia.

the class CopyrightRepositoryTest method shouldSaveCreatedCopyright.

@Test
public void shouldSaveCreatedCopyright() {
    Copyright created = mock(Copyright.class);
    when(repository.isConnected()).thenReturn(true);
    when(copyrightApi.postCopyright(COPYRIGHT)).thenReturn(Observable.just(created));
    when(repository.save(eq(Copyright.class), eq(created))).thenReturn(Completable.complete());
    copyrightRepository.createCopyright(COPYRIGHT).subscribe();
    verify(repository).save(Copyright.class, created);
}
Also used : Copyright(com.eventyay.organizer.data.copyright.Copyright) Test(org.junit.Test)

Aggregations

Copyright (com.eventyay.organizer.data.copyright.Copyright)13 Test (org.junit.Test)11 InOrder (org.mockito.InOrder)8 LiveData (androidx.lifecycle.LiveData)2 ViewModel (androidx.lifecycle.ViewModel)2 ContextManager (com.eventyay.organizer.common.ContextManager)2 SingleEventLiveData (com.eventyay.organizer.common.livedata.SingleEventLiveData)2 CopyrightRepository (com.eventyay.organizer.data.copyright.CopyrightRepository)2 Event (com.eventyay.organizer.data.event.Event)2 ErrorUtils (com.eventyay.organizer.utils.ErrorUtils)2 StringUtils (com.eventyay.organizer.utils.StringUtils)2 CompositeDisposable (io.reactivex.disposables.CompositeDisposable)2 Inject (javax.inject.Inject)2 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)2