GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - MAARK/assertj-sling

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
src
src
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

AssertJ for Sling

Implemented to speed up testing of Sling applications.

Usage

  1. Asserting Resource Properties:

Assert that the resource has the specified resource type.

hasResourceType(String expectedResourceType)

assertThat(resource)
    .hasResourceType("sling:Folder");

Assert that the resource has the specified resource super type.

hasResourceSuperType(String expectedSuperType)

assertThat(resource)
   .hasResourceSuperType("sling:Folder");

Assert that the resource has the specified resource path.

hasResourcePath(String expectedPath)

assertThat(resource)
    .hasResourcePath("/content/sling/en");

Assert that the resource has the specified name.

hasResourceName(String expectedName)

assertThat(resource)
    .hasResourceName("jcr:content"); 
  1. Child Resource Assertions:

Assert that the resource has children.

hasChildren()

    assertThat(resource)
        .hasChildren();

Assert that the resource has a specific child resource.

hasChildResource(String childResourcePath)

assertThat(resource)
    .hasChildResource("jcr:content");           

Asserts properties or conditions on a child resource.

childResourceSatisfies(String childResourcePath, Consumer<Resource> assertion)

assertThat(resource)
    .childResourceSatisfies(
        "jcr:content", 
        content -> assertThat(content).hasProperty("jcr:title"));    
  1. Resource Property Assertions:

Assert that the resource has a specific property.

hasProperty(String propertyName)

assertThat(resource)
    .hasProperty("jcr:title");
  1. Resource Value Assertions (for ValueMap):

Assert that a property in the resource's ValueMap has a specific value.

hasPropertyValue(String propertyName, Object expectedValue)

assertThat(resource)
    .hasPropertyValue("jcr:title", "Sling");

Assert that a property in the ValueMap matches a given predicate.

propertyValueSatisfies(String propertyName, Class<PT> clazz, Consumer<PT> assertion)

assertThat(resource)
    .propertyValueSatisfies(
        "jcr:title", 
        String.class, 
        title -> assertThat(title).isEqualTo("Title"));

Extracting property values

extracting(Object... keys)

assertThat(resource)
    .extracting("jcr:title", "jcr:description")
    .containsExactly("Title", "Description");
  1. Resource Adaptation Assertions:

Assert that the resource can be adapted to a specific type.

canAdaptTo(Class<T> type)

assertThat(resource)
    .canAdaptTo(TitleModel.class);    
  1. Resource Existence Assertions:

Assert that the resource exists.

exists()

assertThat(resource)
    .exists();

About

No description, website, or topics provided.

Resources

Readme
CC0-1.0 license
Activity
Custom properties

Stars

0 stars

Watchers

2 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.