Skip to content

Instantly share code, notes, and snippets.

@Pacane
Last active February 12, 2016 19:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pacane/e92854d51788ef8eecd2 to your computer and use it in GitHub Desktop.
Save Pacane/e92854d51788ef8eecd2 to your computer and use it in GitHub Desktop.
public class ApplicationPresenter
extends Presenter<ApplicationPresenter.MyView, ApplicationPresenter.MyProxy> {
interface MyView extends View {
void displayUsername(String username);
}
@ProxyStandard
@NameToken(NameTokens.HOME)
interface MyProxy extends ProxyPlace<ApplicationPresenter> {
}
public static final NestedSlot SLOT_MAIN = new NestedSlot();
private final UserService userService;
@Inject
ApplicationPresenter(
EventBus eventBus,
MyView view,
MyProxy proxy,
UserService userService) {
super(eventBus, view, proxy, RevealType.Root);
this.userService = userService;
}
@Override
protected void onBind() {
String username = userService.getUsername();
getView().displayUsername(username);
}
}
package com.arcbees.client.application;
import javax.inject.Inject;
import org.jukito.JukitoRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.arcbees.client.application.services.UserService;
import static org.mockito.BDDMockito.given;
import static org.mockito.Matchers.same;
import static org.mockito.Mockito.verify;
@RunWith(JukitoRunner.class)
public class ApplicationPresenterTest {
private static final String A_USERNAME = "bobby";
@Inject
private ApplicationPresenter presenter;
@Inject
private ApplicationPresenter.MyView view;
@Inject
private UserService userService;
@Test
public void onBind_displayUsername() {
given(userService.getUsername()).willReturn(A_USERNAME);
presenter.onBind();
verify(view).displayUsername(A_USERNAME);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment