Search in sources :

Example 1 with ContentNode

use of org.onehippo.forge.content.pojo.model.ContentNode in project hippo by NHS-digital-website.

the class DatasetTransformerTest method createsContentNodeForABareBonesDatasetWithLinks.

@Test
public void createsContentNodeForABareBonesDatasetWithLinks() {
    // * given
    DatasetTransformer transformer = buildASimpleDatasetTransformer(listOfThings("resource"), null);
    // * when
    ContentNode node = transformer.process();
    // * then
    assertEquals(TITLE, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_TITLE_UC).getValue());
    assertEquals(SUMMARY, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_SUMMARY).getValue());
    assertEquals(LONG_DATE, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_NOMINALDATE).getValue());
    List<ContentNode> nodes = node.getNodes();
    assertCountOfNodesIs(nodes, AbstractTransformer.PUBLICATIONSYSTEM_RELATEDLINK, 2);
    assertCountOfNodesIs(nodes, AbstractTransformer.PUBLICATION_SYSTEM + "Files-v3", 0);
}
Also used : ContentNode(org.onehippo.forge.content.pojo.model.ContentNode) Test(org.junit.Test)

Example 2 with ContentNode

use of org.onehippo.forge.content.pojo.model.ContentNode in project hippo by NHS-digital-website.

the class DatasetTransformerTest method createsContentNodeForADatasetWithAttachmentsAndLinks.

@Test
public void createsContentNodeForADatasetWithAttachmentsAndLinks() {
    // * given
    DatasetTransformer transformer = buildASimpleDatasetTransformer(listOfThings("resource"), listOfThings("file"));
    given(mockStorageManager.uploadFileToS3(any(), any())).willReturn(mockS3ObjectMetaData);
    // * when
    ContentNode node = transformer.process();
    // * then
    assertEquals(TITLE, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_TITLE_UC).getValue());
    assertEquals(SUMMARY, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_SUMMARY).getValue());
    assertEquals(LONG_DATE, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_NOMINALDATE).getValue());
    List<ContentNode> nodes = node.getNodes();
    assertCountOfNodesIs(nodes, AbstractTransformer.PUBLICATIONSYSTEM_RELATEDLINK, 2);
    assertCountOfNodesIs(nodes, AbstractTransformer.PUBLICATIONSYSTEM_EXTATTACHMENT, 2);
}
Also used : ContentNode(org.onehippo.forge.content.pojo.model.ContentNode) Test(org.junit.Test)

Example 3 with ContentNode

use of org.onehippo.forge.content.pojo.model.ContentNode in project hippo by NHS-digital-website.

the class DatasetTransformerTest method createsContentNodeForABareBonesDataset.

@Test
public void createsContentNodeForABareBonesDataset() {
    // * given
    DatasetTransformer transformer = buildASimpleDatasetTransformer(null, null);
    // * when
    ContentNode node = transformer.process();
    // * then
    assertEquals(TITLE, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_TITLE_UC).getValue());
    assertEquals(SUMMARY, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_SUMMARY).getValue());
    assertEquals(LONG_DATE, node.getProperty(AbstractTransformer.PUBLICATIONSYSTEM_NOMINALDATE).getValue());
    assertNull(node.getNode(AbstractTransformer.PUBLICATION_SYSTEM + "Files-v3"));
}
Also used : ContentNode(org.onehippo.forge.content.pojo.model.ContentNode) Test(org.junit.Test)

Example 4 with ContentNode

use of org.onehippo.forge.content.pojo.model.ContentNode in project hippo by NHS-digital-website.

the class WebsiteIconListTransformerTest method testExternalLinkCreatesApporopriateNodes.

@Test
public void testExternalLinkCreatesApporopriateNodes() throws RepositoryException {
    // given
    WebsiteIconListTransformer transformer = getWebsiteIconlistTransformer(false);
    // when
    ContentNode response = transformer.process();
    // then - main node proprties
    assertEquals(TITLE, response.getProperty(AbstractSectionTransformer.WEBSITE_TITLE).getValue());
    assertEquals(MAIN, response.getProperty(AbstractSectionTransformer.WEBSITE_HEADINGLEVEL).getValue());
    // then - introduction node properties
    ContentNode introNode = response.getNode(AbstractSectionTransformer.WEBSITE_INTRODUCTION);
    assertNotNull(introNode);
    // then  - item nodes - one per icon list item
    assertThereAreExactly(response, AbstractSectionTransformer.WEBSITE_ICONLISTITEMS, 1);
    ContentNode iconListItemsNode = assertNodeNotNull(response, AbstractSectionTransformer.WEBSITE_ICONLISTITEMS);
    // then - one description per node
    ContentNode descrNode = assertNodeNotNull(iconListItemsNode, AbstractSectionTransformer.WEBSITE_DESCRIPTION);
    assertEquals(ITEM_DESCRIPTION, descrNode.getProperty(AbstractSectionTransformer.HIPPOSTD_CONTENT).getValue());
    // then - one image per node
    assertThereAreExactly(iconListItemsNode, AbstractSectionTransformer.WEBSITE_IMAGE, 1);
    ContentNode imageNode = assertNodeNotNull(iconListItemsNode, AbstractSectionTransformer.WEBSITE_IMAGE);
    assertEquals("abcdef", imageNode.getProperty(AbstractSectionTransformer.HIPPO_DOCBASE).getValue());
    assertForExternalLinks(iconListItemsNode);
}
Also used : ContentNode(org.onehippo.forge.content.pojo.model.ContentNode) Test(org.junit.Test)

Example 5 with ContentNode

use of org.onehippo.forge.content.pojo.model.ContentNode in project hippo by NHS-digital-website.

the class WebsiteIconListTransformerTest method assertForInternalLinks.

private void assertForInternalLinks(ContentNode iconListItemsNode) {
    // then one itemlink per node (or type internal) - which itself contains one link
    assertThereAreExactly(iconListItemsNode, AbstractSectionTransformer.WEBSITE_ITEMLINK, 1);
    ContentNode itemLinkNode = assertNodeNotNull(iconListItemsNode, AbstractSectionTransformer.WEBSITE_ITEMLINK);
    assertEquals(AbstractSectionTransformer.WEBSITE_INTERNALLINK, itemLinkNode.getPrimaryType());
    // then - there should be just one link beneath the internal link node
    assertThereAreExactly(itemLinkNode, AbstractSectionTransformer.WEBSITE_LINK, 1);
    ContentNode linkNode = assertNodeNotNull(itemLinkNode, AbstractSectionTransformer.WEBSITE_LINK);
    assertEquals(AbstractSectionTransformer.WEBSITE_INTERNALLINK, itemLinkNode.getPrimaryType());
}
Also used : ContentNode(org.onehippo.forge.content.pojo.model.ContentNode)

Aggregations

ContentNode (org.onehippo.forge.content.pojo.model.ContentNode)39 Test (org.junit.Test)7 RepositoryException (javax.jcr.RepositoryException)4 ArcFileData (uk.nhs.digital.arc.storage.ArcFileData)4 Node (javax.jcr.Node)3 BinaryValue (org.onehippo.forge.content.pojo.model.BinaryValue)3 PublicationBodyItem (uk.nhs.digital.arc.json.PublicationBodyItem)3 IOException (java.io.IOException)2 PublicationsystemChartSection (uk.nhs.digital.arc.json.publicationsystem.PublicationsystemChartSection)2 PublicationsystemResourceOrExternalLink (uk.nhs.digital.arc.json.publicationsystem.PublicationsystemResourceOrExternalLink)2 AbstractSectionTransformer (uk.nhs.digital.arc.transformer.abs.AbstractSectionTransformer)2 FilePathData (uk.nhs.digital.arc.util.FilePathData)2 Binary (javax.jcr.Binary)1 DocumentManager (org.onehippo.forge.content.exim.core.DocumentManager)1 WorkflowDocumentManagerImpl (org.onehippo.forge.content.exim.core.impl.WorkflowDocumentManagerImpl)1 WorkflowDocumentVariantImportTask (org.onehippo.forge.content.exim.core.impl.WorkflowDocumentVariantImportTask)1 Archive (uk.nhs.digital.arc.json.Archive)1 PublicationsystemChangeNotice (uk.nhs.digital.arc.json.publicationsystem.PublicationsystemChangeNotice)1 PublicationsystemInteractivetool (uk.nhs.digital.arc.json.publicationsystem.PublicationsystemInteractivetool)1 WebsiteExternalLink (uk.nhs.digital.arc.json.website.WebsiteExternalLink)1