Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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