Menu

AEM as Cloud Service does not support custom runmode config

Adobe Experience Manager as Cloud Service (AEM as CS) doesn't support custom run mode configuration. The supported runmode configurations are:

  • config (The default, applies to all AEM Services)
  • config.author (Applies to all AEM Author service)
  • config.author.dev (Applies to AEM Dev Author service)
  • config.author.stage (Applies to AEM Staging Author service)
  • config.author.prod (Applies to AEM Production Author service)
  • config.publish (Applies to AEM Publish service)
  • config.publish.dev (Applies to AEM Dev Publish service)
  • config.publish.stage (Applies to AEM Staging Publish service)
  • config.publish.prod (Applies to AEM Production Publish service)
  • config.dev (Applies to AEM Dev services)
  • config.stage (Applies to AEM Staging services)
  • config.prod (Applies to AEM Production services)

fatal: unable to access 'https://jorvee.bitbucket.com/branch/src/': SSL certificate problem: unable to get local issuer certificate

Error: 

fatal: unable to access 'https://jorvee.bitbucket.com/branch/src/': SSL certificate problem: unable to get local issuer certificate

Resolution: 

There is a workaround to disable the ssl and bypass the check. Use the below command to overcome from this error. 

For only current repository

git config http.sslVerify false

For disable the ssl at global level 

git config --global http.sslVerify false


Now you can run your git commands without any trouble. Thank you! 

JUnit for Java getter and setter methods

 

POJO class

public class ColleagueDetails {
private String colleagueID;
private String colleagueEmail;
public ColleagueDetails(String colleagueID, String colleagueEmail) {
this.colleagueID = colleagueID;
this.colleagueEmail = colleagueEmail;
}
public String getColleagueID() { return colleagueID; }
public void setColleagueID(String colleagueID) { this.colleagueID = colleagueID; }
public String getColleagueEmail() { return colleagueEmail; }
public void setColleagueEmail(String colleagueEmail) { this.colleagueEmail = colleagueEmail; }
}

Test class
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class ColleagueDetailsTest {
ColleagueDetails colleagueDetails = new ColleagueDetails("1234", "email@jorvee.com");

@BeforeEach
void setUp() { }

@Test
void getColleagueIDTest() {
colleagueDetails.setColleagueID("1234");
assertEquals("1234", colleagueDetails.getColleagueID());
}

@Test
void getColleagueEmailTest() {
colleagueDetails.setColleagueEmail("email@jorvee.com");
assertEquals("email@jorvee.com", colleagueDetails.getColleagueEmail());
}

}

JUnit for AEM sling model class with adaptables SlingHttpServletRequest

Sling Model class

We have this sling model class for that we are going to write unit test using JUnit5.


@Model(adaptables = SlingHttpServletRequest.class, 
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class LinkCheckerModel {
@Inject
@Named("link")
@Source("request-attributes")
private String link;

@Inject
@Source("sling-object")
private ResourceResolver resolver;

private boolean isExternal;

private String updatedLink;
    private final static String DOT_HTML = ".html";
private final Logger logger = LoggerFactory.getLogger(getClass());

@PostConstruct
public void init() {
try {
isExternal = false;
if(StringUtils.isNotBlank(link)) {
if (!isInternal(link)) {
isExternal = true;
updatedLink = link;
} else {
link = link.contains(DOT_HTML) ? link : (link + DOT_HTML);
updatedLink = resolver.map(link);
}
}
} catch (Exception e) {
logger.error("Exception occurs while checking link:{}", e.getMessage());
}
logger.info("Exit init method of Linkchecker Model");
}

private boolean isInternal(String linkStr) {
return linkStr.startsWith("/content") && !linkStr.startsWith("/content/dam");
}
public boolean isExternal() {
return isExternal;
}
public String getUpdatedLink() {
return updatedLink;
}
}

Test class

Generate or create the test class of our sling model class. In this case we have class LinkCheckerModel and created Test class LinkCheckerModelTest.java.

Note: Right click on the class name and choose the option to generate the test. Then select the methods for that you want to create test methods.


import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
import org.apache.commons.lang3.StringUtils;
import org.apache.sling.api.SlingHttpServletRequest;
import org.apache.sling.api.resource.Resource;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;

import static org.junit.jupiter.api.Assertions.*;

@ExtendWith(AemContextExtension.class)
class LinkCheckerModelTest {
private AemContext context = new AemContext();
@Mock
private SlingHttpServletRequest request;
LinkCheckerModel linkCheckerModel = new LinkCheckerModel();
@BeforeEach
void setUp() {
context.load().json("/linkChecker.json", "/content/jorvee/en");
context.addModelsForClasses(LinkCheckerModel.class);
Resource resource = context.resourceResolver().
getResource("/content/jorvee/en/jcr:content/parsys/linkCheckerNode");
        linkCheckerModel = context.request().adaptTo(LinkCheckerModel.class);

linkCheckerModel.init();
}

@Test
void initTest() {

}

@Test
void isExternalTest() {
assertNotNull(linkCheckerModel.isExternal());
}

@Test
void getUpdatedLinkTest() {
assertNull(linkCheckerModel.getUpdatedLink());
}
}


JSON data [linkChecker.json]

The JSON data on which we will mock the request. Create a JSON file with name linkChecker.json and add this json object into that.

{
"jcr:primaryType": "cq:Page",
"jcr:content": {
"cq:contextHubPath": "/etc/cloudsettings/default/contexthub",
"cq:contextHubSegmentsPath": "/etc/segmentation/contexthub",
"cq:designPath": "/etc/designs/jorvee",
"cq:lastModified": "{Date}2020-04-14T19:23:41.457+05:30",
"cq:lastModifiedBy": "admin",
"cq:lastReplicated": "{Date}2020-02-10T19:55:14.981Z",
"cq:lastReplicatedBy": "admin",
"cq:lastReplicationAction": "Activate",
"cq:template": "/apps/jorvee/templates/basic",
"jcr:primaryType": "cq:PageContent",
"jcr:title": "Jorvee | Homepage",
"releaseDate": "Wed Apr 01 2020 00:00:00 GMT+0530",
"sling:resourceType": "jorvee/components/pages/basic/v1/basic",
"section": "sect",
"parsys": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "wcm/foundation/components/parsys",
"linkCheckerNode": {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType": "jorvee/components/buttons/linkChecker",
"link": "/content/jorvee"
}
}
}
}

Run the test

You are all set and now it's time to test the class and methods. You can run the testclass from run option of the IDE. also you can run the test calss using maven command for just a single class.

mvn test -Dtest=<className>

e.g. mvn test -Dtest=LinkCheckerModelTest


Junit Tutorials

 

Difference between s.t() and s.tl() send data | Analytics

- s.t(): Send data to Adobe Analytics and treat it as a page view

- s.tl(): Send data to Adobe Analytics and do not treat it as a page view


Learn Analytics Basic to Advance

WCAG guidelines for contrast ratios

When designing readable interface then we need to take care of the contrast ratio between background and foreground color. Below table explain the contrast ratio suggested under the WCAG guideline.

Contrast ratio WCAG guidelines


How to increase the layout size of a dialog in aem

We can increase the height and width of a dialog by adding properties height and width on the dialog node.

height="{Long}700"

width="{Long}500"






 

How to get bundle information from AEM

We can access the detail on an AEM bundle outside the Apache Felix console using the bundle symbolic name and JSON extension with system console bundle path. http://localhost:4502/system/console/bundles/<bundle-symbolic-name>.json 

e.g. http://localhost:4502/system/console/bundles/com.adobe.aem.graphql.api.json

Above URL will generate and provide all the detail of the bundle in json format, that we could anywhere. Result will be like below json.

{
  status: "Bundle information: 628 bundles in total - all 628 bundles active.",
  s: [
    628,
    624,
    4,
    0,
    0
  ],
  data: [
    {
      id: 588,
      name: "GraphQL - API",
      fragment: false,
      stateRaw: 32,
      state: "Active",
      version: "0.0.1.CQ650-B0004",
      symbolicName: "com.adobe.aem.graphql.api",
      category: "adobe,aem",
      props: [
        {
          key: "Symbolic Name",
          value: "com.adobe.aem.graphql.api"
        },
        {
          key: "Version",
          value: "0.0.1.CQ650-B0004"
        },
        {
          key: "Bundle Location",
          value: "bundle582:com.adobe.aem.graphql.api-0.0.1-CQ650-B0004.jar"
        },
        {
          key: "Last Modification",
          value: "Thu Sep 01 15:19:02 IST 2022"
        },
        {
          key: "Bundle Documentation",
          value: "https://docs.adobe.com"
        },
        {
          key: "Vendor",
          value: "Adobe"
        },
        {
          key: "Description",
          value: "The parent project to the Adobe Experience Manager parts"
        },
        {
          key: "Start Level",
          value: 20
        },
        {
          key: "Exported Packages",
          value: [
            "com.adobe.aem.graphql.api,version=1.0.0"
          ]
        },
        {
          key: "Imported Packages",
          value: [
            "org.apache.sling.api.resource,version=2.12.1 from <a href='/system/console/bundles/77'>org.apache.sling.api (77)</a>"
          ]
        },
        {
          key: "Importing Bundles",
          value: [
            "<a href='/system/console/bundles/589'>com.adobe.aem.graphql.impl (589)</a>",
            "<a href='/system/console/bundles/591'>com.adobe.aem.graphql.sites-base (591)</a>"
          ]
        },
        {
          key: "Manifest Headers",
          value: [
            "Bnd-LastModified: 1627451068224",
            "Build-Jdk: 11",
            "Built-By: maji",
            "Bundle-Category: adobe, aem",
            "Bundle-Description: The parent project to the Adobe Experience Manager parts",
            "Bundle-DocURL: https://docs.adobe.com",
            "Bundle-ManifestVersion: 2",
            "Bundle-Name: GraphQL - API",
            "Bundle-SymbolicName: com.adobe.aem.graphql.api",
            "Bundle-Vendor: Adobe",
            "Bundle-Version: 0.0.1.CQ650-B0004",
            "Created-By: Apache Maven Bundle Plugin",
            "Export-Package: com.adobe.aem.graphql.api; version="1.0.0"; uses:="org.apache.sling.api.resource"",
            "Import-Package: org.apache.sling.api.resource; version="[
              2.12,
              3)"",
              "Include-Resource: META-INF/LICENSE=target/maven-shared-archive-resources/META-INF/LICENSE",
              "Manifest-Version: 1.0",
              "Private-Package: com.adobe.aem.graphql.api",
              "Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.8))"",
              "Tool: Bnd-4.2.0.201903051501"
            ]
          },
          {
            key: "nfo",
            value: {
              
            }
          }
        ]
      }
    ]
  }