use of com.enonic.xp.portal.postprocess.PostProcessInjection in project xp by enonic.
the class PostProcessEvaluatorTest method testEvaluateDuplicatedContributions.
@Test
public void testEvaluateDuplicatedContributions() throws Exception {
final PostProcessInjection contributionsInjection = (portalRequest, portalResponse, tag) -> {
switch(tag) {
case HEAD_BEGIN:
return Arrays.asList("<!-- HEAD BEGIN-->", "<!-- HEAD BEGIN DUPLICATED-1 -->", "<!-- HEAD BEGIN DUPLICATED-2 -->");
case HEAD_END:
return Arrays.asList("<!-- HEAD END -->");
case BODY_BEGIN:
return Arrays.asList("<!-- BODY BEGIN -->");
case BODY_END:
return Arrays.asList("<!-- BODY END -->");
default:
return null;
}
};
final PostProcessInjection contributionsInjection2 = (portalRequest, portalResponse, tag) -> {
switch(tag) {
case HEAD_BEGIN:
return Arrays.asList("<!-- HEAD BEGIN DUPLICATED-2 -->", "<!-- HEAD BEGIN DUPLICATED-1 -->");
case BODY_END:
return Arrays.asList("<!-- BODY END -->");
default:
return null;
}
};
final PostProcessEvaluator evaluator = new PostProcessEvaluator();
evaluator.input = readResource("postProcessEvalSource5.html");
evaluator.injections = List.of(contributionsInjection, contributionsInjection2);
evaluator.instructions = Collections.emptyList();
evaluator.portalResponse = PortalResponse.create().build();
final PortalResponse result = evaluator.evaluate();
assertEqualsTrimmed(readResource("postProcessEvalResult5.html"), result.getAsString());
}
use of com.enonic.xp.portal.postprocess.PostProcessInjection in project xp by enonic.
the class PostProcessEvaluatorTest method testEvaluateMultipleContributions.
@Test
public void testEvaluateMultipleContributions() throws Exception {
final PostProcessInjection contributionsInjection = (portalRequest, portalResponse, tag) -> {
switch(tag) {
case HEAD_BEGIN:
return Arrays.asList("<!-- HEAD BEGIN -->");
case HEAD_END:
return Arrays.asList("<!-- HEAD END -->");
case BODY_BEGIN:
return Arrays.asList("<!-- BODY BEGIN -->");
case BODY_END:
return Arrays.asList("<!-- BODY END -->");
default:
return null;
}
};
final PostProcessInjection contributionsInjection2 = (portalRequest, portalResponse, tag) -> {
switch(tag) {
case HEAD_BEGIN:
return Arrays.asList("<!-- HEAD BEGIN EXTRA-->");
case BODY_END:
return Arrays.asList("<!-- BODY END EXTRA-->");
default:
return null;
}
};
final PostProcessEvaluator evaluator = new PostProcessEvaluator();
evaluator.input = readResource("postProcessEvalSource4.html");
evaluator.injections = List.of(contributionsInjection, contributionsInjection2);
evaluator.instructions = Collections.emptyList();
evaluator.portalResponse = PortalResponse.create().build();
final PortalResponse result = evaluator.evaluate();
assertEqualsTrimmed(readResource("postProcessEvalResult4.html"), result.getAsString());
}
use of com.enonic.xp.portal.postprocess.PostProcessInjection in project xp by enonic.
the class PostProcessEvaluatorTest method testEvaluateContributions.
@Test
public void testEvaluateContributions() throws Exception {
final PostProcessInjection contributionsInjection = (portalRequest, portalResponse, tag) -> {
switch(tag) {
case HEAD_BEGIN:
return Arrays.asList("<!-- HEAD BEGIN -->");
case HEAD_END:
return Arrays.asList("<!-- HEAD END -->");
case BODY_BEGIN:
return Arrays.asList("<!-- BODY BEGIN -->");
case BODY_END:
return Arrays.asList("<!-- BODY END -->");
default:
return null;
}
};
final PostProcessEvaluator evaluator = new PostProcessEvaluator();
evaluator.input = readResource("postProcessEvalSource2.html");
evaluator.injections = List.of(contributionsInjection);
evaluator.instructions = Collections.emptyList();
evaluator.portalResponse = PortalResponse.create().build();
final PortalResponse result = evaluator.evaluate();
assertEqualsTrimmed(readResource("postProcessEvalResult2.html"), result.getAsString());
}
use of com.enonic.xp.portal.postprocess.PostProcessInjection in project xp by enonic.
the class PostProcessEvaluatorTest method testEvaluateInstructionsAndContributions.
@Test
public void testEvaluateInstructionsAndContributions() throws Exception {
final PostProcessInjection contributionsInjection = (portalRequest, portalResponse, tag) -> {
switch(tag) {
case HEAD_BEGIN:
return Arrays.asList("<!-- HEAD BEGIN -->");
case HEAD_END:
return Arrays.asList("<!-- HEAD END -->");
case BODY_BEGIN:
return Arrays.asList("<!-- BODY BEGIN -->");
case BODY_END:
return Arrays.asList("<!-- BODY END -->");
default:
return null;
}
};
final PostProcessEvaluator evaluator = new PostProcessEvaluator();
evaluator.input = readResource("postProcessEvalSource2.html");
evaluator.injections = List.of(contributionsInjection);
evaluator.instructions = Collections.emptyList();
evaluator.portalResponse = PortalResponse.create().build();
evaluator.evaluateInstructions();
final PortalResponse result = evaluator.evaluateContributions();
assertEqualsTrimmed(readResource("postProcessEvalResult2.html"), result.getAsString());
}
Aggregations