Last active
September 1, 2016 06:15
-
-
Save SeongUgJung/65d18ae4c442f69a2fe18ff18d097b69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testUpdateSelectTeam() throws Exception { | |
// Given | |
long originSelectedTeamId = AccountRepository.getRepository().getSelectedTeamId(); | |
long newTeamId = getNewTeamId(originSelectedTeamId); | |
// When | |
accountHomeModel.updateSelectTeam(newTeamId); | |
// Then | |
long newSavedTeamId = AccountRepository.getRepository().getSelectedTeamId(); | |
assertThat(originSelectedTeamId, is(not(equalTo(newSavedTeamId)))); | |
assertThat(newTeamId, is(equalTo(newSavedTeamId))); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onJoinedTeamSelect(long teamId) { | |
view.showProgressWheel(); | |
Observable.defer(() -> { | |
accountHomeModel.updateSelectTeam(teamId); | |
try { | |
InitialInfo initialInfo = accountHomeModel.getEntityInfo(teamId); | |
return Observable.just(initialInfo); | |
} catch (RetrofitException e) { | |
return Observable.error(e); | |
} | |
}) | |
.doOnNext(initialInfo -> { | |
accountHomeModel.updateEntityInfo(initialInfo); | |
TeamInfoLoader.getInstance().refresh(); | |
accountHomeModel.refreshPollList(teamId); | |
JandiPreference.setSocketConnectedLastTime(initialInfo.getTs()); | |
accountHomeModel.trackLaunchTeamSuccess(teamId); | |
}) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(it -> { | |
view.dismissProgressWheel(); | |
view.moveSelectedTeam(); | |
}, t -> { | |
if (t instanceof RetrofitException) { | |
RetrofitException t1 = (RetrofitException) t; | |
accountHomeModel.trackLaunchTeamFail(t1.getResponseCode()); | |
} else { | |
accountHomeModel.trackLaunchTeamFail(-1); | |
} | |
view.dismissProgressWheel(); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testOnJoinedTeamSelect() throws Exception { | |
final boolean[] finish = {false}; | |
doAnswer(invocationOnMock -> { | |
finish[0] = true; | |
return invocationOnMock; | |
}).when(viewMock).dismissProgressWheel(); | |
long selectedTeamId = AccountRepository.getRepository().getSelectedTeamId(); | |
accountHomePresenter.onJoinedTeamSelect(selectedTeamId); | |
Awaitility.await().until(() -> finish[0]); | |
verify(viewMock, times(1)).dismissProgressWheel(); | |
verify(viewMock, times(1)).moveSelectedTeam(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void testMoveSelectedTeam() throws Throwable { | |
rule.runOnUiThread(() -> activity.moveSelectedTeam()); | |
assertThat(activity.isFinishing(), is(true)); | |
intending(IntentMatchers.hasComponent(MainTabActivity.class.getName())); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment