Last active
February 12, 2016 19:12
-
-
Save Pacane/e92854d51788ef8eecd2 to your computer and use it in GitHub Desktop.
This file contains 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
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); | |
} | |
} |
This file contains 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
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