use of io.knotx.dataobjects.Fragment in project knotx by Cognifide.
the class KnotxCoercers method provideFragment.
public Fragment provideFragment(String fragmentContentFileWithDefinedSnippetTagName) throws IOException {
final String[] params = fragmentContentFileWithDefinedSnippetTagName.split("\\|");
final String fragmentContentFile = params[0];
final String snippetTagName;
if (params.length > 1) {
snippetTagName = params[1];
} else {
snippetTagName = FragmentConstants.DEFAULT_SNIPPET_TAG_NAME;
}
final String fragmentContent = FileReader.readText(fragmentContentFile);
final SnippetPatterns patterns = new SnippetPatterns(snippetTagName);
Fragment fragmentMock = Mockito.mock(Fragment.class);
when(fragmentMock.content()).thenReturn(fragmentContent);
when(fragmentMock.isRaw()).thenReturn(!patterns.getAnySnippetPattern().matcher(fragmentContent).matches());
return fragmentMock;
}
use of io.knotx.dataobjects.Fragment in project knotx by Cognifide.
the class FragmentContentExtractorTest method provideFragment.
@Coercion
public Fragment provideFragment(String fragmentContentFile) throws IOException {
final String fragmentContent = readText(fragmentContentFile);
Fragment fragmentMock = Mockito.mock(Fragment.class);
when(fragmentMock.isRaw()).thenReturn(!fragmentContent.contains(FragmentConstants.SNIPPET_IDENTIFIER_NAME));
when(fragmentMock.content()).thenReturn(fragmentContent);
return fragmentMock;
}
Aggregations