use of com.eventyay.organizer.data.sponsor.Sponsor in project open-event-orga-app by fossasia.
the class SponsorRepositoryTest method shouldUpdateUpdatedSponsor.
@Test
public void shouldUpdateUpdatedSponsor() {
Sponsor updated = mock(Sponsor.class);
when(repository.isConnected()).thenReturn(true);
when(sponsorApi.updateSponsor(ID, SPONSOR)).thenReturn(Observable.just(updated));
when(repository.update(eq(Sponsor.class), eq(updated))).thenReturn(Completable.complete());
sponsorRepository.updateSponsor(SPONSOR).subscribe();
verify(repository).update(Sponsor.class, updated);
}
use of com.eventyay.organizer.data.sponsor.Sponsor in project open-event-orga-app by fossasia.
the class SponsorRepositoryTest method shouldSaveCreatedSponsor.
@Test
public void shouldSaveCreatedSponsor() {
Sponsor created = mock(Sponsor.class);
when(repository.isConnected()).thenReturn(true);
when(sponsorApi.postSponsor(SPONSOR)).thenReturn(Observable.just(created));
when(repository.save(eq(Sponsor.class), eq(created))).thenReturn(Completable.complete());
sponsorRepository.createSponsor(SPONSOR).subscribe();
verify(repository).save(Sponsor.class, created);
}
use of com.eventyay.organizer.data.sponsor.Sponsor in project open-event-orga-app by fossasia.
the class CreateSponsorViewModel method updateSponsor.
public void updateSponsor() {
nullifyEmptyFields(sponsor);
long eventId = ContextManager.getSelectedEvent().getId();
Event event = new Event();
event.setId(eventId);
sponsor.setEvent(event);
compositeDisposable.add(sponsorRepository.updateSponsor(sponsor).doOnSubscribe(disposable -> progress.setValue(true)).doFinally(() -> progress.setValue(false)).subscribe(updatedSponsor -> {
success.setValue("Sponsor Updated");
dismiss.call();
}, throwable -> error.setValue(ErrorUtils.getMessage(throwable).toString())));
}
use of com.eventyay.organizer.data.sponsor.Sponsor in project open-event-orga-app by fossasia.
the class SponsorsPresenterTest method testProgressbarOnSwipeRefreshNoItem.
@Test
public void testProgressbarOnSwipeRefreshNoItem() {
List<Sponsor> emptyList = new ArrayList<>();
when(sponsorRepository.getSponsors(ID, true)).thenReturn(Observable.fromIterable(emptyList));
sponsorsPresenter.loadSponsors(true);
InOrder inOrder = Mockito.inOrder(sponsorsView);
inOrder.verify(sponsorsView).showProgress(true);
inOrder.verify(sponsorsView).onRefreshComplete(true);
inOrder.verify(sponsorsView).showProgress(false);
}
use of com.eventyay.organizer.data.sponsor.Sponsor in project open-event-orga-app by fossasia.
the class CreateSponsorViewModelTest method shouldShowSuccessOnUpdate.
@Test
public void shouldShowSuccessOnUpdate() {
String successString = "Sponsor Updated";
Sponsor sponsor = createSponsorViewModel.getSponsor();
when(sponsorRepository.updateSponsor(sponsor)).thenReturn(Observable.just(sponsor));
ContextManager.setSelectedEvent(event);
InOrder inOrder = Mockito.inOrder(progress, dismiss, success);
createSponsorViewModel.getProgress().observeForever(progress);
createSponsorViewModel.getDismiss().observeForever(dismiss);
createSponsorViewModel.getSuccess().observeForever(success);
createSponsorViewModel.updateSponsor();
inOrder.verify(progress).onChanged(true);
inOrder.verify(success).onChanged(successString);
inOrder.verify(dismiss).onChanged(null);
inOrder.verify(progress).onChanged(false);
ContextManager.setSelectedEvent(null);
}
Aggregations