ContentFragmentImpl implements ContentFragment { @Nullable @Override public String[] getParagraphs() { if (!"singleText".equals(displayMode)) { return null; } if (damContentFragment.getElements() == null || damContentFragment.getElements().isEmpty()) { return null; } DAMContentElement damContentElement = damContentFragment.getElements().get(0); if (!damContentElement.isMultiLine()) { return null; } String content = renderService.render(resource); if (content == null) { return null; } return content.split("(?=(<p>|<h1>|<h2>|<h3>|<h4>|<h5>|<h6>))"); }  @Nullable @Override String getTitle(); @Nullable @Override String getDescription(); @Nullable @Override String getType(); @Nullable @Override String getName(); @NotNull @Override String getGridResourceType(); @NotNull @Override String getEditorJSON(); @NotNull @Override Map<String, DAMContentElement> getExportedElements(); @NotNull @Override String[] getExportedElementsOrder(); @Nullable @Override List<DAMContentElement> getElements(); @Nullable @Override List<Resource> getAssociatedContent(); @NotNull @Override String getExportedType(); @NotNull @Override Map<String, ? extends ComponentExporter> getExportedItems(); @NotNull @Override String[] getExportedItemsOrder(); @Nullable @Override String[] getParagraphs(); static final String RESOURCE_TYPE; }
@Test void getParagraphsOfMultiDisplayModeIsNull() { ContentFragment fragment = getModelInstanceUnderTest(CF_STRUCTURED); assertNull(fragment.getParagraphs()); }
@Test void getParagraphOfSingleTextDisplayMode() { when(fragmentRenderService.render(any(Resource.class))).thenReturn(MAIN_CONTENT); ContentFragment contentFragment = getModelInstanceUnderTest(CF_STRUCTURED_SINGLE_ELEMENT_MAIN); assertArrayEquals(new String[]{MAIN_CONTENT}, contentFragment.getParagraphs()); }