Package com.google.sitebricks

Examples of com.google.sitebricks.Renderable


        : "@Post method was not fired, on doPost() with the right arg, instead: " + bound.post;
  }

  @Test(expectedExceptions = InvalidEventHandlerException.class)
  public final void errorOnPostMethodWithUnnamedArgs() {
    Renderable mock = new Renderable() {
      public void render(Object bound, Respond respond) {

      }

      public <T extends Renderable> Set<T> collect(Class<T> clazz) {
View Full Code Here


    assert page.widget().equals(mock);
  }

  @Test
  public final void firePostMethodOnPage() {
    Renderable mock = new Renderable() {
      public void render(Object bound, Respond respond) {

      }

      public <T extends Renderable> Set<T> collect(Class<T> clazz) {
View Full Code Here

  @Test(dataProvider = URI_TEMPLATES_AND_MATCHES)
  public final void matchPageByUriTemplate(final String template, final String toMatch) {
    final Respond respond = new MockRespond();

    Renderable mock = new Renderable() {
      public void render(Object bound, Respond respond) {

      }

      public <T extends Renderable> Set<T> collect(Class<T> clazz) {
        return null;
      }
    };

    final PageBook pageBook = new DefaultPageBook(injector);
    pageBook.at(template, MyPage.class);

    PageBook.Page page = pageBook.get(toMatch);
    final MyPage myPage = new MyPage();

    page.apply(mock);
    page.widget().render(myPage, respond);

    assert mock.equals(page.widget());
  }
View Full Code Here

  }

  public void loadAll(Set<Descriptor> templates) {
    // If in production mode, force load all the templates.
    for (Descriptor template : templates) {
      Renderable compiled = compilers.compile(template.clazz);
      Preconditions.checkArgument(null != compiled, "No template found attached to: %s",
          template.clazz);

      this.templates.put(template.clazz, compiled);
    }
View Full Code Here

      this.templates.put(template.clazz, compiled);
    }
  }

  public String render(Class<?> clazz, Object context) {
    Renderable compiled;
    if (reloadTemplates) {
      compiled = compilers.compile(clazz);

      templates.put(clazz, compiled);
    } else {
      compiled = templates.get(clazz);
    }
    Preconditions.checkArgument(null != compiled, "No template found attached to: %s", clazz);

    StringBuilderRespond respond = new StringBuilderRespond();
    //noinspection ConstantConditions
    compiled.render(context, respond);

    return respond.toString();
  }
View Full Code Here

    pageName = pageName.toLowerCase();

    final PageBook pageBook = createMock(PageBook.class);
    final PageBook.Page page = createMock(PageBook.Page.class);
    final Respond respond = RespondersForTesting.newRespond();
    final Renderable widget = createMock(Renderable.class);

    expect(pageBook.forName(pageName))
        .andReturn(page);


    //mypage does?
    final MyEmbeddedPage myEmbeddedPage = new MyEmbeddedPage();
    expect(page.instantiate())
        .andReturn(myEmbeddedPage);

    expect(page.doMethod(isA(String.class), anyObject(), isA(String.class),
        isA(HttpServletRequest.class)))
        .andReturn(null);
    expect(page.widget())
        .andReturn(widget);

    widget.render(eq(myEmbeddedPage), isA(Respond.class));


    replay(pageBook, page, widget);

    final MvelEvaluator evaluator = new MvelEvaluator();
View Full Code Here

          put("class", "pretty");
          put("id", "a-p-tag");
        }}));
    widget.addWidget(new ShowIfWidget(targetWidgetChain, "true", evaluator));

    Renderable bodyWrapper = new XmlWidget(widget, "body", createMock(EvaluatorCompiler.class), Collections.<String, String>emptyMap());

    expect(pageBook.forName(pageName))
        .andReturn(page);

View Full Code Here

          put("class", "pretty");
          put("id", "a-p-tag");
        }}));
    widget.addWidget(new ShowIfWidget(targetWidgetChain, "true", evaluator));

    Renderable bodyWrapper = new XmlWidget(widget, "body", createMock(EvaluatorCompiler.class), Collections.<String, String>emptyMap());

    expect(pageBook.forName(targetPageName))
        .andReturn(page);

View Full Code Here

    pageName = pageName.toLowerCase();

    final PageBook pageBook = createMock(PageBook.class);
    final PageBook.Page page = createMock(PageBook.Page.class);
    final Respond mockRespond = createNiceMock(Respond.class);
    final Renderable widget = createMock(Renderable.class);

    expect(pageBook.forName(pageName))
        .andReturn(page);


    //mypage does?
    final MyEmbeddedPage myEmbeddedPage = new MyEmbeddedPage();
    expect(page.instantiate())
        .andReturn(myEmbeddedPage);


    expect(page.doMethod(isA(String.class), anyObject(), isA(String.class),
        isA(HttpServletRequest.class)))
        .andReturn(null);
    expect(page.widget())
        .andReturn(widget);

    widget.render(eq(myEmbeddedPage), isA(Respond.class));


    replay(pageBook, page, mockRespond, widget);

    final EmbedWidget embedWidget = new EmbedWidget(Collections.<String, ArgumentWidget>emptyMap(), expression, new MvelEvaluator(), pageBook, pageName);
View Full Code Here

    pageName = pageName.toLowerCase();

    final PageBook pageBook = createMock(PageBook.class);
    final PageBook.Page page = createMock(PageBook.Page.class);
    final Respond mockRespond = createMock(Respond.class);
    final Renderable widget = createMock(Renderable.class);

    expect(pageBook.forName(pageName))
        .andReturn(page);


    //mypage does?
    final MyEmbeddedPage myEmbeddedPage = new MyEmbeddedPage();
    expect(page.instantiate())
        .andReturn(myEmbeddedPage);

    expect(page.doMethod(isA(String.class), anyObject(), isA(String.class),
        isA(HttpServletRequest.class)))
        .andReturn(null);

    expect(page.widget())
        .andReturn(widget);

    widget.render(myEmbeddedPage, mockRespond);


    replay(pageBook, page, mockRespond, widget);

    new EmbedWidget(Collections.<String, ArgumentWidget>emptyMap(), expression, new MvelEvaluator(), pageBook, pageName)
View Full Code Here

TOP

Related Classes of com.google.sitebricks.Renderable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.