Expand my Community achievements bar.

Create par with AEM Mocks API

Avatar

Level 4

Hello guys,

I want to create the following tree structure with the builder api from AEM Mocks.

1359983_pastedImage_0.png

The problem is the it does not create the parsys.

This my actual code:

context.pageManager().create("/", "content", "cq:Page", "content");
context.pageManager().create("/content", "de", "cq:Page", "de");
context.pageManager().create("/content/de", "ueber-uns", "cq:Page", "ueber-uns");
context.pageManager().create("/content/de/ueber-uns", "presse", "cq:Page", "presse");
context.pageManager().create("/content/de/ueber-uns/presse", "press-releases", "cq:Page", "press-releases");
context.pageManager().create("/content/de/ueber-uns/presse/press-releases", "2017", "cq:Page", "2017");
context.pageManager().create("/content/de/ueber-uns/presse/press-releases/2017", "release1", "/apps/test/foundation/templates/basepage", "release1");
context.pageManager().create("/content/de/ueber-uns/presse/press-releases/2017/release1", "par", "foundation/components/parsys", "par");
context.pageManager().create("/content/de/ueber-uns/presse/press-releases/2017/release1", "jcr:content", "test/test-com/components/common/basepage", "jcr:content");
context.pageManager().create("/content/de/ueber-uns/presse/press-releases/2017/release1/par", "gridcontrol", "test/test-com/components/content/gridcontrol", "gridcontrol");
context.pageManager().create("/content/de/ueber-uns/presse/press-releases/2017/release1/par/gridcontrol", "col-6-6-1", "foundation/components/parsys", "col-6-6-1");
context.pageManager().create("/content/de/ueber-uns/presse/press-releases/2017/release1/par/gridcontrol/col-6-6-1", "headline", "test/test-com/components/content/headline", "headline");

context.build().resource("/content/de/ueber-uns/presse/press-releases/jcr:content", "jcr:created", date);
context.build().

  resource("/content/de/ueber-uns/presse/press-releases/2017/release1/jcr:content", "jcr:created", date).

  resource("/content/de/ueber-uns/presse/press-releases/2017/release1/jcr:content", "pageTitle", "release1-title").

  resource("/content/de/ueber-uns/presse/press-releases/2017/release1/jcr:content/par/gridcontrol/col-6-6-1/headline", "headlinetext", "Technik bringt mehr Stress in Europas Haushalte");

In the servlet I want to test calling subPage.getContentResource().getChild("par").adaptTo(Node.class); returns just null. So I think I am initializing the pages the wrong way.

Best regards,

Tim

1 Reply

Avatar

Level 4

Hello I found a solution.

It is very easy to load the content from AEM as a JSON and load it in your test case.

Go to your Page and add the extension: press-releases.html.infinity.json

Once you have your JSON tree structure you can load it:

context.load().json("/press-release-test-data/pressrelease1-testdata.json", "/content/de/ueber-uns/presse/press-releases/2017/release1");

Thanks for listening