Implemented to speed up testing of Sling applications.
- Asserting Resource Properties:
hasResourceType(String expectedResourceType)
assertThat(resource)
.hasResourceType("sling:Folder");
hasResourceSuperType(String expectedSuperType)
assertThat(resource)
.hasResourceSuperType("sling:Folder");
hasResourcePath(String expectedPath)
assertThat(resource)
.hasResourcePath("/content/sling/en");
hasResourceName(String expectedName)
assertThat(resource)
.hasResourceName("jcr:content");
- Child Resource Assertions:
hasChildren()
assertThat(resource)
.hasChildren();
hasChildResource(String childResourcePath)
assertThat(resource)
.hasChildResource("jcr:content");
childResourceSatisfies(String childResourcePath, Consumer<Resource> assertion)
assertThat(resource)
.childResourceSatisfies(
"jcr:content",
content -> assertThat(content).hasProperty("jcr:title"));
- Resource Property Assertions:
hasProperty(String propertyName)
assertThat(resource)
.hasProperty("jcr:title");
- Resource Value Assertions (for ValueMap):
hasPropertyValue(String propertyName, Object expectedValue)
assertThat(resource)
.hasPropertyValue("jcr:title", "Sling");
propertyValueSatisfies(String propertyName, Class<PT> clazz, Consumer<PT> assertion)
assertThat(resource)
.propertyValueSatisfies(
"jcr:title",
String.class,
title -> assertThat(title).isEqualTo("Title"));
extracting(Object... keys)
assertThat(resource)
.extracting("jcr:title", "jcr:description")
.containsExactly("Title", "Description");
- Resource Adaptation Assertions:
canAdaptTo(Class<T> type)
assertThat(resource)
.canAdaptTo(TitleModel.class);
- Resource Existence Assertions:
exists()
assertThat(resource)
.exists();