コード例 #1
0
  @Test
  public void testInstructionRenderByName() throws Exception {
    RendererFactory rendererFactory = newRendererFactory("<b>part content</b>");
    ComponentService componentService = Mockito.mock(ComponentService.class);

    Component component = createPartComponent();
    doReturn(component)
        .when(componentService)
        .getByName(isA(ApplicationKey.class), isA(ComponentName.class));
    ComponentInstruction instruction = new ComponentInstruction();
    instruction.setRendererFactory(rendererFactory);
    instruction.setComponentService(componentService);

    PortalRequest portalRequest = new PortalRequest();
    Content content = createPage("content-id", "content-name", "myapplication:content-type");
    portalRequest.setContent(content);
    Site site = createSite("site-id", "site-name", "myapplication:content-type");
    portalRequest.setSite(site);
    PageTemplate pageTemplate = createPageTemplate();
    portalRequest.setPageTemplate(pageTemplate);

    String outputHtml =
        instruction.evaluate(portalRequest, "COMPONENT module:myPartComponent").getAsString();
    assertEquals("<b>part content</b>", outputHtml);
  }
コード例 #2
0
  @Test
  public void testInstruction() throws Exception {
    RendererFactory rendererFactory = newRendererFactory("<b>part content</b>");
    ComponentService componentService = Mockito.mock(ComponentService.class);
    ComponentInstruction instruction = new ComponentInstruction();
    instruction.setRendererFactory(rendererFactory);
    instruction.setComponentService(componentService);

    PortalRequest portalRequest = new PortalRequest();
    Content content = createPage("content-id", "content-name", "myapplication:content-type");
    portalRequest.setContent(content);
    Site site = createSite("site-id", "site-name", "myapplication:content-type");
    portalRequest.setSite(site);

    String outputHtml = instruction.evaluate(portalRequest, "COMPONENT myRegion/0").getAsString();
    assertEquals("<b>part content</b>", outputHtml);
  }