예제 #1
0
  @Test
  public void placeManagerRevealRelativePlaceWithZeroLevelShouldGoToDefaultPlace() {
    // Given
    doAnswer(
            invocation -> {
              Object[] args = invocation.getArguments();
              deferredCommandManager.addCommand(
                  () ->
                      placeManager.updateHistory(
                          new PlaceRequest.Builder().nameToken("defaultPlace").build(), true));
              ((PlaceRequestInternalEvent) args[0]).setHandled();
              return null;
            })
        .when(eventBus)
        .fireEventFromSource(isA(PlaceRequestInternalEvent.class), eq(placeManager));

    // When
    placeManager.revealRelativePlace(0);
    deferredCommandManager.pump();

    // Then
    PlaceRequest placeRequest = placeManager.getCurrentPlaceRequest();
    assertEquals("defaultPlace", placeRequest.getNameToken());
    assertEquals(0, placeRequest.getParameterNames().size());

    verify(gwtWindowMethods).setBrowserHistoryToken(any(String.class), eq(false));
  }
예제 #2
0
  @Test
  public void placeManagerUserCallUpdateHistoryWhenRevealingPlace() {
    // Given
    doAnswer(
            invocation -> {
              Object[] args = invocation.getArguments();
              deferredCommandManager.addCommand(
                  () ->
                      placeManager.updateHistory(
                          new PlaceRequest.Builder()
                              .nameToken("dummyNameToken")
                              .with("dummyParam", "dummyValue")
                              .build(),
                          true));
              ((PlaceRequestInternalEvent) args[0]).setHandled();
              return null;
            })
        .when(eventBus)
        .fireEventFromSource(isA(PlaceRequestInternalEvent.class), eq(placeManager));

    // When
    placeManager.revealPlace(new PlaceRequest.Builder().nameToken("dummyNameToken").build());
    deferredCommandManager.pump();

    // Then
    PlaceRequest placeRequest = placeManager.getCurrentPlaceRequest();
    assertEquals("dummyNameToken", placeRequest.getNameToken());
    assertEquals(1, placeRequest.getParameterNames().size());
    assertEquals("dummyValue", placeRequest.getParameter("dummyParam", null));

    verify(gwtWindowMethods).setBrowserHistoryToken(any(String.class), eq(false));
  }
예제 #3
0
파일: Places.java 프로젝트: hal/hal.next
 /** Returns a new place request with the a new value for the specified parameter. */
 public PlaceRequest.Builder replaceParameter(
     PlaceRequest placeRequest, String parameter, String newValue) {
   PlaceRequest.Builder builder =
       new PlaceRequest.Builder().nameToken(placeRequest.getNameToken());
   for (String p : placeRequest.getParameterNames()) {
     if (parameter.equals(p)) {
       builder.with(parameter, newValue);
     } else {
       builder.with(p, placeRequest.getParameter(p, ""));
     }
   }
   return builder;
 }
예제 #4
0
  @Override
  public void prepareFromRequest(PlaceRequest request) {
    super.prepareFromRequest(request);

    String idString = request.getParameter(ParameterTokens.TOKEN_ID, null);
    try {
      id = Integer.parseInt(idString);
    } catch (NumberFormatException e) {
      id = 0;
    }
  }
  @Override
  public void prepareFromRequest(PlaceRequest request) {
    super.prepareFromRequest(request);
    // fireEvent(new
    // ChangeTabEvent(ApplicationPresenter.SLOT_ChangeTab,getProxy()));

    stories.clear();
    getView().showPublish(false);

    newsDesk = null;
    String desk = request.getParameter("desk", "inbox");
    getView().selectTab(desk);

    if (desk.equals("inbox")) {
      newsDesk = null;
    } else {
      newsDesk = StringUtils.searchEnum(NewsDesk.class, desk);
    }

    SearchFilter searchFilter = getView().getSearchFilter();
    searchFilter.setDesk(newsDesk);
    loadSearchParams();
    loadStories(searchFilter);
  }
예제 #6
0
파일: Places.java 프로젝트: hal/hal.next
 public boolean isExternal(PlaceRequest placeRequest) {
   return Boolean.parseBoolean(placeRequest.getParameter(EXTERNAL_PARAM, String.valueOf(false)));
 }
예제 #7
0
 @Override
 public void prepareFromRequest(final PlaceRequest request) {
   federation = request.getParameter(FEDERATION_REQUEST_PARAM, null);
   serviceProvider = request.getParameter(SERVICE_PROVIDER_REQUEST_PARAM, null);
 }