Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Who Me Too'd this topic


Level 10

Hi Team,


I have written a custom getData() method overlayed as per the below documentation to extend and customize the Adobe Client Data Layer.

public String getCustomData() {
Resource accordionResource = this.request.getResource();

if (ComponentUtils.isDataLayerEnabled(accordionResource)) {
Map<String, Object> accordionProperties = new HashMap<>();
accordionProperties.put("@type", accordionResource.getResourceType());
accordionProperties.put("repo:modifyDate", PlatformUtils.isoDateFormat(accordion.getData().getLastModifiedDate(), dateutil));
accordionProperties.put("parentId", accordion.getData().getParentId());

//Adding New Custom Properties
accordionProperties.put("Component Name", "Accordion");

String bylineComponentID = ComponentUtils.getId(accordionResource, this.currentPage, this.componentContext);
try {
return String.format("{\"%s\":%s}",
// Use the ObjectMapper to serialize the bylineProperties to a JSON string
new ObjectMapper().writeValueAsString(accordionProperties));
} catch (JsonProcessingException e) {
log.error("Unable to generate dataLayer JSON string", e);
return null;

I want to now write a JUnit for the same. The challenge here is that the JSON object does not have customData as other properties.

Can you please help with this ?


@arunpatidar, @Vijayalakshmi_S, @Gaurav-Behl, @B_Sravan, @Mohit_KBansal, @kautuk_sahni 


The problem is primarily with the method - if (ComponentUtils.isDataLayerEnabled(accordionResource)) {

For a mocked resource this always evaluates to false.

Tried using - lenient().when(ComponentUtils.isDataLayerEnabled(resource)).thenReturn(true) but this is not working as well.


Rohan Garg

Who Me Too'd this topic