コード例 #1
0
  @Test
  public void testGetPayloadProperties_NullResource() throws Exception {

    Resource payloadRes = mock(Resource.class);
    Map<String, String> props = SendTemplatedEmailUtils.getPayloadProperties(payloadRes, sdf);
    assertEquals(0, props.size());
  }
コード例 #2
0
  @Test
  public void testGetPayloadProperties_Asset() throws Exception {

    // set up jcr properties
    mockJcrProperties();

    Resource payloadRes = mock(Resource.class);
    Resource mdRes = mock(Resource.class);
    when(DamUtil.isAsset(payloadRes)).thenReturn(true);

    when(payloadRes.getChild(JcrConstants.JCR_CONTENT + "/" + DamConstants.METADATA_FOLDER))
        .thenReturn(mdRes);

    // mock valueMap
    when(mdRes.getValueMap()).thenReturn(vmap);
    Map<String, String> props = SendTemplatedEmailUtils.getPayloadProperties(payloadRes, sdf);

    assertEquals(props.get(PN_CALENDAR), CALENDAR_TOSTRING);
    assertEquals(props.get(PN_TITLE), STR_TOSTRING);
    assertEquals(props.get(PN_LONG), LONG_TOSTRING);
    assertEquals(props.get(PN_STR_ARRAY), STR_ARRAY_TOSTRING);
  }
コード例 #3
0
  @Test
  public void testGetPayloadProperties_Page() throws Exception {

    // set up jcr properties
    mockJcrProperties();

    Resource payloadRes = mock(Resource.class);
    Resource jcrRes = mock(Resource.class);
    when(DamUtil.isAsset(payloadRes)).thenReturn(false);

    Page payloadPage = mock(Page.class);
    when(payloadRes.adaptTo(Page.class)).thenReturn(payloadPage);
    when(payloadPage.getContentResource()).thenReturn(jcrRes);

    // mock valueMap
    when(jcrRes.getValueMap()).thenReturn(vmap);
    Map<String, String> props = SendTemplatedEmailUtils.getPayloadProperties(payloadRes, sdf);

    assertEquals(props.get(PN_CALENDAR), CALENDAR_TOSTRING);
    assertEquals(props.get(PN_TITLE), STR_TOSTRING);
    assertEquals(props.get(PN_LONG), LONG_TOSTRING);
    assertEquals(props.get(PN_STR_ARRAY), STR_ARRAY_TOSTRING);
  }