<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Eddie Y on Medium]]></title>
        <description><![CDATA[Stories by Eddie Y on Medium]]></description>
        <link>https://medium.com/@eddiey?source=rss-48ee35d31c00------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Eddie Y on Medium</title>
            <link>https://medium.com/@eddiey?source=rss-48ee35d31c00------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 09:26:20 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@eddiey/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Solution Overview and Architecture for an Okta Based Customer Identity and Access Management]]></title>
            <link>https://medium.com/@eddiey/a-solution-overview-and-architecture-for-an-okta-based-customer-identity-and-access-management-452159c01127?source=rss-48ee35d31c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/452159c01127</guid>
            <category><![CDATA[architectural-design]]></category>
            <category><![CDATA[okta]]></category>
            <category><![CDATA[identity-management]]></category>
            <category><![CDATA[access-management]]></category>
            <category><![CDATA[solution-architecture]]></category>
            <dc:creator><![CDATA[Eddie Y]]></dc:creator>
            <pubDate>Mon, 18 May 2020 14:22:14 GMT</pubDate>
            <atom:updated>2020-05-18T14:22:14.977Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s information-packed, multi-channel yet more and more regulated digital world, whether you just started a new business and are building your product, or you are a large business that has many applications, customer identity is always the fundamental and shared service in the application architecture. This is especially true in a cloud based architecture where you have multiple tenants in a distributed system. You need a unified customer identity solution to gain insights of your customers and provide them the best digital experience.</p><h3>Okta as a SaaS Based Identity Platform</h3><p>Among many workforce and customer identity solutions, platform services and integrations <a href="https://support.okta.com/help/s/article/What-is-Okta">Okta</a> offered as a SaaS, or Identity as a Service (IDaaS), solution, I will mainly focus on <strong>Authentication</strong>, <strong>Self Service Registration (SSR)</strong> and <strong>Authorization</strong> in the <strong>Customer Identity and Access Management (CIAM)</strong>.</p><p>Okta not only offers a cloud based application for customer organizations to launch SSO applications and administrate the instance, it also provides multiple integration options (you will need to <a href="https://help.okta.com/en/prod/Content/Topics/Directory/eu-self-service.htm">enable SSR</a> if you use #1 and #2 below).</p><ol><li><strong>Okta Hosted Sign In Page</strong></li></ol><p>This means you will use the OOTB sign in page Okta provides for your application. Okta will host and manage the sign in and sign up experience. You can customize the experience by customizing the URL domain, sign in page HTML, labels and links. You can simply create your application in Okta and put it behind Okta’s authentication page. This is the least flexible options of the three but is also a completely managed cloud based option, which means fastest time to market and least codes to manage.</p><p><strong>2. Sign In Widget</strong></p><p>The second option is to embed the <a href="https://github.com/okta/okta-signin-widget#okta-sign-in-widget">Okta Sign-In Widget</a> into your application. The Okta sign-in widget is a Javascript code that is available either through Okta CDN or NPM. You can customize the widget or develop custom event handlers based on your needs. With this option, you still follow the same Okta default flows and procedures underneath, but you have more flexibility on where and how the sign in widget display in your application and you don’t need to develop all the codes that connect to Okta.</p><p><strong>3. Custom UI with Okta SDK and API</strong></p><p>That last option is to develop your custom sign in and sign up UI for your applications with <a href="https://developer.okta.com/code/">Okta SDK</a> and/or <a href="https://developer.okta.com/docs/reference/">API</a>. This is the most flexible option, you have the max control over the use case (i.e. <a href="https://www.okta.com/passwordless-authentication">passwordless sign up and authentication</a>), user experience (i.e. <a href="https://www.okta.com/blog/2019/01/configuring-progressive-profiling-for-your-custom-apps/">progressive profiling</a>, fields, messages, internationalization), business logic (i.e. send custom email from your email server when user is locked out) and tech stack of your choice, but of course you will need to develop those.</p><h3>Solution Architecture</h3><p>The solution architecture I build here is a sample reference for you to consider with your own circumstances.</p><p>The use case here is that I am building a new web application for my B2B business and it needs a user sign up and sign in experience. There’s also an admin section in my app that only customer admins can have access.</p><p>There are three main components in this architecture: <strong><em>AEM (Adobe Experience Manager)</em></strong>, <strong><em>AWS (Amazon Web Services)</em></strong> and <strong><em>Okta</em></strong>.</p><h4>Web/ UI</h4><p>I choose to develop the web application as a SPA (that includes the custom sign up, sign in and admin experience) because I want to have full control over the look and feel/branding, flow and business logic of the experience. Leveraged <strong>AEM</strong> as a headless Content Management System for the SPA, I can let the same content management team to manage all the content authoring, publish workflows and translations in one place.</p><h4>AWS</h4><p>The SPA will be cached and served over the edge by <strong>Amazon CloudFront</strong> and deployed in <strong>Amazon S3</strong>.</p><p>The REST APIs for the SPA will be developed and deployed in different serverless <strong>Lambda</strong> functions, like this <a href="https://developer.okta.com/blog/2017/12/21/spread-serverless-holiday-cheer">example</a>. They are fronted by a <strong>Amazon API Gateway</strong> to manage all API accesses, rate limits, authentication and authorization etc.</p><p>For a more frictionless and fast sign up experience, I want to provide the least minimum attributes for user to sign up at first. But since I am a B2B business, there may be many regulations, business processes and workflows that need to happen after a user account has been created (in Okta in this case).</p><p>So after the registration is complete and user account is created in Okta, I will send a message/signal (I am doing it in registration API, but I can also do it via Okta event hook and have Okta called a Lambda service) to a <strong>AWS SNS (Simple Notification Service)</strong>, it will then fan out to all the business services subscribed to the account registration topic, like an email service to send out a welcome message to the user, an account validation service to ensure the registered account is compliant with business policy, a marketing systems integration service to push a new lead to the marketing automation system like Marketo, and then sync to Salesforce for my sales team to follow up. To enable fault tolerance and performance, I will front each of those services with a <strong>AWS SQS (Simple Queue Service)</strong> so that these message payloads can be cached and queued before they are delivered and consumed by the downstream services.</p><p>Moreover, for the account validation service, I will have a <strong>AWS Step Functions</strong> to handle all the steps and workflow required to validate the user account. For example, first of all I will call a third party identity compliance check service API. If it comes back as pass, I will update the user record in Okta and also Marketo lead to indicate the same; if it comes back as fail, I will have a manual step to review the account internally and confirm compliance. Below is a workflow diagram for the same.</p><figure><img alt="Account validation workflow diagram" src="https://cdn-images-1.medium.com/max/1024/1*UTiXvYe4iymPXko9sh8dWQ.png" /><figcaption>Account validation workflow diagram</figcaption></figure><h4>Okta</h4><p>Okta will be the source of truth for user identity (<strong>Universal Directory</strong>), IDP (identity provider) and engine for user lifecycle management, policies (sign on, password, MFA and IdP discovery) and <strong>API Access Management</strong>.</p><p>The authorization of the application will follow OIDC standard and it will allow/deny access. Since SPA is a browser based application, the OAuth group recommends to use <a href="https://oauth.net/2/browser-based-apps/">Authorization Code flow with the PKCE</a> as the code flow to exchange ID and access tokens.</p><p>I will create a custom authorization server for my application in Okta. The customer admins will be put into a admin group for the customer, so that the access policy can be associated with a group instead of a specific person and align with best practice. Then in the authorization server, I will create a new admin scope. After that, I will also set up an access policy and rule that only the customer admin groups can have access to the admin scope. Furthermore, I can create custom attributes in the Okta user profile schema to identify what kind of admin role the user is, i.e. org admin role can manage everything for the organization, group admin role that can only manage specific groups within the organization etc. Then I can set up a claim for the admin scope and output this user attribute into the access token jwt using Okta expression language. Now my admin screen and customer administrative REST APIs can have a role based access control (RBAC) to the person that is logged in.</p><h4>Architecture Diagram</h4><figure><img alt="Okta Base IAM Architecture Diagram" src="https://cdn-images-1.medium.com/max/1024/1*1Wvclw1Cd1kg81Jcw5gIVw.png" /><figcaption>Okta Base IAM Architecture Diagram</figcaption></figure><h3>What is New?</h3><p>There are some upcoming new Okta features to look out for and will make a difference for CIAM.</p><p><strong>Workflows</strong></p><p><a href="https://www.okta.com/platform/workflows/">Okta Workflows</a> provides workflow engine for identity centric processes automation. It’s <a href="https://www.okta.com/press-room/press-releases/introducing-okta-lifecycle-management-workflows/">currently GA</a> for workforce identity. When it’s rolled out to customer identity, it should accelerate some of the common CIAM lifecycle management use cases.</p><p><strong>Identity Engine</strong></p><p><a href="https://www.okta.com/platform/identity-engine/">Okta Identity Engine</a> separates the core identity lifecycle (from registration to authentication to authorization) into four steps: Identity, Authorize, Enroll and Issue, so that you can customize and extend each individual component to achieve tailored experience like passwordless authentication and progressive profiling.</p><h3>Ready to Build Your Own?</h3><p>CIAM is never an easy task, especially for large enterprises, it needs to be built with <strong>performance</strong>, <strong>scalability</strong>, <strong>resiliency</strong>, <strong>security</strong> and <strong>user experience</strong> in mind. I hope this blog sheds some lights on your design and architecture. You can sign up for a free Okta developer instance and AWS account and start to play with different components mentioned in this blog. There are also tons helpful blogs, tutorials, videos and webinars online.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=452159c01127" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Design Considerations for REST APIs in AEM Applications]]></title>
            <link>https://medium.com/@eddiey/design-considerations-for-rest-apis-in-aem-applications-6014e89e3ab?source=rss-48ee35d31c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/6014e89e3ab</guid>
            <category><![CDATA[architectural-design]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[application-architecture]]></category>
            <dc:creator><![CDATA[Eddie Y]]></dc:creator>
            <pubDate>Mon, 11 May 2020 14:20:54 GMT</pubDate>
            <atom:updated>2020-05-11T14:20:54.880Z</atom:updated>
            <content:encoded><![CDATA[<p>If you are looking to develop and deploy <a href="https://en.wikipedia.org/wiki/Representational_state_transfer">REST APIs</a> for your AEM and/or other web/mobile applications/services, and want to know the options, design considerations and places to be mindful of, you are in the right place.</p><h3>The Options</h3><p>Depends on the REST API framework of your choice (and I will walk through them in the section below), there are several options to develop and deploy REST APIs for your AEM applications. The most obvious one is <a href="https://sling.apache.org/"><strong><em>Apache Sling</em></strong></a>. AEM uses Apache Sling as the REST web application framework, hence to implement REST API with Sling, you will create <a href="https://sling.apache.org/documentation/the-sling-engine/servlets.html">Sling servlets</a>. If you want to develop and deploy your REST APIs inside AEM, but also not limit to AEM in the future, <strong><em>JAX-RS based Jersey</em></strong> is a good choice. I will demonstrate the JAX-RS and Jersey architecture below as well. If you are not bound to AEM and going to develop and deploy your REST APIs outside, you are free to choose any API framework and tech stack. You can choose a popular Java API framework like <strong><em>Spring or Spring Boot</em></strong>, or you can choose a serverless and GraphQL approach with <strong><em>AWS AppSync and AWS Lambda</em></strong>.</p><h3>The Design Considerations</h3><p>There are several design considerations when you choose a REST API framework for your team and applications:</p><p><strong>1. Where do you want to deploy your REST API?</strong></p><p>The important factors come into play in your architecture are the existing infrastructures/platforms/services/tools you already own or using for your applications versus the buffer and agility to set them up new for your REST APIs. Say currently you only have AEM and it’s managed by AMS (Adobe Managed Services), you may want to leverage the existing managed services they provide (including VPC cloud hosting and scaling, cloud manager, CI/CD pipeline, infrastructure level logging, monitoring, alerts and production support). Setting up new infrastructure, CI/CD pipeline and tooling for a large scale production level REST APIs can take time, effort and add cost.</p><p><strong>2. What language and tech stack is your team familiar with?</strong></p><p>If your team are AEM engineers, they are probably more familiar with Java and the AEM tech stack.</p><p><strong>3. What use cases does your REST API have?</strong></p><p>Your API use cases will affect your choice of API framework, whether it needs to communicate with AEM, provide abstraction of other APIs, or perform CRUD operations to an external database (like Amazon DynamoDB, Amazon Aurora). For example, Apache Sling is a content based REST framework that is built into AEM. AEM uses CRX Content Repository (on top of Apache Jackrabbit). So if your REST API does not deal with content in a content repository, you may not leverage the best of Sling.</p><p><strong>4. What features do you need from the API framework?</strong></p><p>You want to develop REST API in a well established framework because you want the framework to handle most (if not all) plumbing and abstraction for you, so you can just focus on writing codes for the business logics you care about and ship it to production quickly. The features an API framework can provide include development (like annotations, customization via config file, environment variables, HATEOAS support), serialization and de-serialization (like integrate with Gson or Jackson), performance (like caching), security (like encryption, authentication and authorization, vulnerability), API documentation (like integrate with Swagger), developer community and activities.</p><p><strong>5. How much fault tolerance, performance and scalability does your REST API need?</strong></p><p>If your REST API provides mission critical functionality for your business or applications, you will want to avoid any single point of failure or tight coupling in your API architecture, you will want high availability and fault tolerance (like adding AWS CloudFront, ELB, Auto Scaling, SQS) and low latency. Make sure you run rigorous performance testing on those APIs and test if they meet the SLA.</p><p><strong>6. Does it follow REST architectural constraints?</strong></p><p>In another word, is it a RESTful framework? Since REST is an architectural style, you should implement REST and follow the principals and best practices in your code as well.</p><h3>The JAX-RS Based Jersey REST API Architecture in AEM</h3><p>If you decide to develop and deploy your REST API inside AEM, you can do so with a JAX-RS based Jersey architecture. All you need is a <a href="https://github.com/hstaudacher/osgi-jax-rs-connector">connector</a> that can publish a normal OSGI service as a Jersey REST web service, and the Jersey bundles to be deployed in AEM. The OSGI Jersey connector allows your JAX-RS REST APIs to be served within the same Apache Felix container that your other OSGI services are in. In fact, you will use the same OSGI annotations you already familiar with to register and manage the service lifecycle, plus the JAX-RS annotations.</p><p>The benefit you will get from this architecture is that you can leverage existing AEM architecture, pipeline, knowledge and managed services (if applicable), but also provide flexibility in the future if you need to lift and shift and deploy the REST APIs somewhere else (like Spring Boot Jersey).</p><p>Below is a sample architecture diagram designed with the AWS stacks.</p><figure><img alt="Jersey REST API with AEM and AWS Architecture Diagram" src="https://cdn-images-1.medium.com/max/1024/1*oMghWkgzv-hGM2BJuqO73A.png" /><figcaption>Jersey REST API with AEM and AWS Architecture Diagram</figcaption></figure><h3>The Places to Be Mindful of</h3><p>First, probably most important one, scalability. If your API evolves to have a much higher request volumes and you need to scale, you will need to either scale up (vertically) the resources in the AEM infrastructure or you will scale out (horizontally) to have more AEM servers. You cannot scale just for your REST APIs. Now it’s good to know that with <a href="https://docs.adobe.com/content/help/en/experience-manager-learn/cloud-service/overview.html"><strong><em>AEM as a Cloud Service</em></strong></a>, things get a little better, your AEM publish servers will be separated from the large content repository, blob storage and some OOTB AEM services, so the publish server can scale a bit more independently. There’s auto scaling capability as well.</p><p>Second, your REST API framework needs to be AEM compatible, if you deploy it in AEM. In that case, A well established framework that is not only compatible with AEM but also provides easy shift and lift in the future should be considered.</p><p>Third, API gateway and management. Serving mission critical REST APIs that communicates to your databases directly require a different level of management, network settings and server configurations than serving your typical static web pages, whether it’s Transport Layer Security (TLS) and rate limiting/throttling or is authentication and authorization.</p><p>Fourth, security. API security is such an important topic that every developer/architect should pay attention to. You should consider incorporating DevSecOps, which is building automated information security, ‘Security as Code’, into your traditional DevOps process and shift security left in your SDLC.</p><p>Last but not least, testing. Quality assurance is critical for each REST API to cover all the scenarios it’s designed to do (including errors) before it’s deployed to production, and validates the technical requirements like latency, fault tolerance (in infrastructure, network and application levels), recovery and handling of chaotic situations.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6014e89e3ab" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Quality in AEM Applications — Automated Authoring Testing]]></title>
            <link>https://medium.com/@eddiey/building-quality-in-aem-applications-automated-authoring-testing-baddd7e24ef2?source=rss-48ee35d31c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/baddd7e24ef2</guid>
            <category><![CDATA[cucumber]]></category>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[bobcat]]></category>
            <dc:creator><![CDATA[Eddie Y]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 14:21:00 GMT</pubDate>
            <atom:updated>2019-03-04T14:21:00.753Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Quality in AEM Applications — Automated Authoring Testing</h3><p>Authoring is the process of content creation in <a href="https://www.adobe.com/marketing/experience-manager.html">Adobe Experience Manager </a>(AEM). It allows content authors to make changes to content without a code release. A good AEM application should consist of components and pages that are easy to author for non-technical content authors. To ensure the AEM application meets the content authoring requirements, authoring testing is needed. Quality Assurance (QA) engineers usually prepare a set of test cases for authoring testing. Like any other type of testing, automation helps test cases run quickly and consistently across all environments, it saves company a lot of operational cost. QA engineers don’t need to repeat tedious manual testing in different environments and different phases, but can focus on writing and improving automation test suites. In this second post of Building Quality in AEM Applications series, I am going to demonstrate automated authoring testing in AEM with <a href="https://cognifide.github.io/bobcat/">Bobcat</a> and <a href="https://docs.cucumber.io/">Cucumber</a> framework.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-QdEVK2IWm9wwBgm-fs-4g.png" /><figcaption>AEM Meets Bobcat and Cucumber</figcaption></figure><h3>Bobcat</h3><p>You probably heard of <a href="https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/hobbes.html">Hobbes.js</a> for automated UI and authoring testing in AEM. It’s OOTB UI and authoring testing framework shipped with AEM. You can view and run Hobbes.js test cases by navigating to the <a href="http://localhost:4502/libs/granite/testing/hobbes.html">testing console</a> in AEM. If you want some references, AEM core components have implemented Hobbes.js authoring testing. For example, you can find a test suite for Title component <a href="https://github.com/adobe/aem-core-wcm-components/blob/master/testing/it/ui-js/src/content/jcr_root/apps/core/wcm/tests/test-suites/Title/v2/Title.js">here</a>, and test cases <a href="https://github.com/adobe/aem-core-wcm-components/blob/master/testing/it/ui-js/src/content/jcr_root/apps/core/wcm/tests/test-cases/Title/v1/Title.js">here</a>.</p><p>But what is Bobcat? Bobcat is an <a href="https://github.com/Cognifide/bobcat">open source</a> automated testing framework for web applications, built on top of <a href="https://www.seleniumhq.org/">Selenium</a>, and it provides features and support for AEM authoring testing.</p><h3>Cucumber and BDD</h3><p>And what is Cucumber? Cucumber is an <a href="https://github.com/cucumber/cucumber">open source</a> framework for <a href="https://docs.cucumber.io/bdd/overview/">Behaviour-Driven Development (BDD)</a> that executes scenarios written in plain English and generates reports.</p><p>BDD is a development practice that fosters collaboration and communication among the agile team three amigos (BA/PO, developer and QA), records product requirements in behavioral specifications and automates tests.</p><p>With BDD and Cucumber framework, BA/PO can write requirements in the story in a format that can be reused directly in test cases. It improves application quality by having a thorough discussion of how the application should behave and having test cases in requirement phase, even before development starts.</p><h3>Bobcat vs. Hobbes.js</h3><p>If you are choosing between <a href="https://cognifide.github.io/bobcat/docs/getting-started/">Bobcat</a> and <a href="https://helpx.adobe.com/experience-manager/6-4/sites/developing/using/reference-materials/test-api/index.html">Hobbes.js</a> for automated AEM authoring testing, below is a side by side comparison.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3cSOTRDPJCURkeGznJcCGA.png" /><figcaption>Side by side comparison between Bobcat and Hobbes.js</figcaption></figure><h3>Get Started with Bobcat and Cucumber</h3><p>Since there is few public documentation on using Bobcat and Cucumber frameworks for AEM authoring testing, if you decide to go with or just try these two frameworks, I hope this blog can give you some guidance and code reference on how to them.</p><p>I am going to integrate Bobcat and Cucumber frameworks into my <a href="https://github.com/guangweiyao/blog"><strong><em>demo Blog repository</em></strong></a>, and I will write a simple BDD automated authoring test case for title component with the latest Bobcat modules and APIs. All the codes are written and tested for <strong><em>AEM 6.4</em></strong>.</p><p>To start, Bobcat has built a <a href="https://github.com/Cognifide/bobcat-gradle-template">Gradle template for AEM BDD</a>, which includes the latest Bobcat core API, Cucumber and AEM 6.4 specific codes. It creates necessary structures and wirings (although you’ll need to make some tweaks for Maven and older AEM versions, there’s a separate documentation for older AEM versions <a href="https://github.com/Cognifide/bobcat/wiki">here</a>) for you. You can put them into the it.tests module in your AEM maven project. See below an anatomy of the generated code structures.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yd3oMXPRTlf7vCarh-oDvg.png" /><figcaption>Anatomy of Bobcat AEM BDD code structures</figcaption></figure><p>Since the Bobcat framework is built on top of Selenium, You’ll also need to download and install a webdriver of your choice (default is <a href="https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver">Chrome driver</a>) for your test case to run.</p><h3>Write Automated Authoring Test Case</h3><p>After you’ve created a sample AEM BDD project from the template, you are ready to write your own automated authoring test case with Bobcat and Cucumber.</p><p>First, you’ll write or copy feature test cases in Cucumber features folder. You define feature, rule, background, scenario and steps etc with <a href="https://docs.cucumber.io/gherkin/reference/">Gherkin language</a>. If you are use IntelliJ, there’re some plugins, like Gherkin and Cucumber for Java that help you write Cucumber BDD test cases as well.</p><p>Next, you will need to translate the scenarios and steps in your feature file into codes that can be run. This is the core of developing automated authoring tests. You will write logic and implementations for each step, a missing step implementation will lead to failure of the test case. You will also incorporate Bobcat and Selenium APIs in the step implementation. There’s a <a href="https://cognifide.github.io/bobcat/docs/guides/first-aem-test/">sample AEM authoring test tutorial</a> in Bobcat documentation. Even though the tutorial is specific for Bobcat and JUnit, it should give you some insights on how to use the latest Bobcat modules and APIs.</p><p>You may notice the <a href="https://github.com/Cognifide/bobcat/releases">latest Bobcat core and AEM 6.4 modules</a> have changed the framework architecture and <a href="https://cognifide.github.io/bobcat/docs/modules/aem/compatibility/">support for AEM</a>, as a lot of the previous Classic UI and Touch UI helper classes are deprecated and don’t work in AEM 6.4. One of the main differences is that it now encapsulates a lot of reusable classes and methods into AEM actions. These Bobcat AEM actions can be executed with or without data. And they can be extended or you can develop custom action for your use case. The other major change is the introduction of PageObject and PageObjectInterface, these are models for page and components, to encapsulate common logics and to be reused in different test cases.</p><p>You may also notice the current OOTB AEM actions don’t have strong support for BDD framework yet, as there’re <a href="http://www.javadoc.io/doc/com.cognifide.qa.bb/bb-aem-64/2.0.3">only a few</a> right now and not modular enough for a step implementation in BDD. So you can either develop your own action that can pass in modular parameters, or use Selenium APIs.</p><p>Lastly, you will need to write a test runner to trigger the BDD authoring test cases.</p><h3>Run Automated Authoring Test Case</h3><p>To run the automated authoring test cases, simply run mvn clean test.</p><p>If you don’t want to run those tests every build, you can create a integration test specific Maven profile.</p><p>Finally, let’s see what it looks like when it runs.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Esl3w3kCx3bHL4KT5o2NmA.gif" /><figcaption>AEM BDD authoring test case run</figcaption></figure><h3>Summary</h3><p>As you are looking for automated AEM authoring test solutions, I recommend you review your use cases, business, development and testing processes carefully with the pros and cons of the two frameworks.</p><p>I can definitely see the benefits of using Bobcat and Cucumber frameworks when your team can work together and adapt to the process changes, and you have the right people to design and set up the foundation for the frameworks to work and scale in your project. It’s a great concept and adds value to both business and technical teams.</p><p>At the same time, as I write this blog and went through all the documentations and APIs of Bobcat, I think there should be a much better documentation on the APIs. I can also use more tutorials on how to use the framework with Cucumber in AEM. Also, given the 2.0.0 release was fairly recent and there is active development, I hope it will finalize on AEM support model, provide more backward compatible changes for easier migration and add more OOTB support for BDD use case soon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=baddd7e24ef2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building Quality in AEM Applications —  Unit Testing]]></title>
            <link>https://medium.com/@eddiey/building-quality-in-aem-applications-unit-testing-f58eeecaae4f?source=rss-48ee35d31c00------2</link>
            <guid isPermaLink="false">https://medium.com/p/f58eeecaae4f</guid>
            <category><![CDATA[aem]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[guidelines]]></category>
            <category><![CDATA[code-quality]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Eddie Y]]></dc:creator>
            <pubDate>Wed, 02 Jan 2019 14:40:38 GMT</pubDate>
            <atom:updated>2019-01-02T14:40:38.333Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building Quality in AEM Applications — Unit Testing</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Y9TCtr_sXNtkS76Z" /><figcaption>Photo by <a href="https://unsplash.com/@bekirdonmeez?utm_source=medium&amp;utm_medium=referral">Bekir Dönmez</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Code quality is one of the essentials in software development. I shouldn’t need to re-emphasize how important it is. It reduces production defects, protects application for security, builds concrete foundation for future features and much more. A good engineering team should make code quality core of their culture and always look for ways to improve application quality iteratively. In the <a href="https://www.adobe.com/experience-cloud/articles/adobe-experience-manager-platform.html"><strong>Adobe Experience Manager (AEM)</strong></a> realm, application code quality is even more imperative, since it is built on top of many open source frameworks, like Apache Sling, JCR, OSGI. You can develop and deploy all kinds of applications within these frameworks. So in this blog series, I am going to focus on different areas you can build quality in AEM applications. To start off the series, I will talk about unit testing. I will cover the benefits of unit testing, general guidelines you can follow, some practical tips and code snippets, how to enable unit testing in AEM application and a reference to my blog code repository. Let’s get it started.</p><h3>Benefits of Unit Testing</h3><p>In the modern DevOps software delivery model, it’s all about automation and shifting left. Unit testing fits into both. You integrate unit test in your build and CI deployment process, you automate build and deployment so your codes will build successfully only when all unit test cases are passed and code artifact will be deployed only when certain code coverage threshold is met. Also, with unit testing, you shift left by writing set of tests in development phase, so that potential bugs can be identified and fixed early on. It saves company cost and helps integration tests in the future state.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i7lfJMB-RvQd6zv1ugYKmw.png" /><figcaption>Shift left in DevOps model</figcaption></figure><p>Other than the two benefits above, I find writing unit test cases helpful for other developers to understand your code. If you happen to have some technical debt and need to write unit test for existing codes, it’s a good opportunity for another developer in your team to write the unit test and learn about the existing codes. When it comes to future development, unit test helps developer to understand existing functionality and business requirements by providing a fail fast methodology. So your stories can be distributed among your team. Both of them make writing unit test a good practice for cross functional knowledge sharing.</p><h3><strong>General Guidelines</strong></h3><p>I have published how to write unit test for AEM component before, and there are tons of online resources for that, so I won’t repeat here. Instead, I’ll share general guidelines I find useful and follow.</p><p>1. Unit test case should be written/updated for each story</p><p>You should always have a unit test task for each new feature you develop. Include unit test into your story estimation. Create a tech story for codes that are not covered by unit test yet.</p><p>2. Create meaningful, human readable test case names</p><p>Test case name helps people understand what is tested and what is failed easily without looking into the code. It also falls into a good and consistent naming convention practice an engineering team should establish. Use comment to provide more detail if need to. On the same, I like the <a href="https://junit.org/junit5/docs/current/api/org/junit/jupiter/api/DisplayName.html">display name</a> enhancement on Junit5.</p><p>3. Keep test case small, simple and straightforward</p><p>Write one assertion for each test case. Separate test cases if you need to assert different scenarios. Each scenario may contain a different set of inputs or states. And trust me, it’s not that time consuming, most of it is just copy and paste. :)</p><p>4. Change scope from private to protected if you want to unit test that method.</p><p>5. Set up an acceptable code coverage for your team</p><p>Usually 80% and above line coverage is the standard. If you have small code base or have bandwidth, I would encourage you to shoot for 100%.</p><p>6. Use tools or plugins to automate</p><p>There are many tools and plugins out there to help you integrate unit testing and automate the process. For example, Sonarqube, Clover, Maven surefire plugin, Karma and Istanbul for JS application.</p><p>Configure the tool or the plugin the way your application codes work to enforce the process.</p><p>7. Use annotations as much as possible</p><p>Annotations make your code easy to read and write.</p><p>For example, using the mock annotation you can have below one liner:</p><pre>@Mock<br>private Logger logger;</pre><p>Instead of</p><pre>private Logger logger;<br>logger = <em>mock</em>(Logger.class);</pre><p>Put @RunWith(MockitoJUnitRunner.class) on top of your test class if you want to use the @Mock annotation.</p><p>8. Package naming convention</p><p>Package name of your test class should be the same as the class you are testing. Also, in this way, protected methods can be seen in your test class.</p><p>9. Use mock or spy adequately</p><p>Generally, you would use mock objects to test the logic inside the method. You should not test the other methods called in the method you are testing, write code to mock the value of those methods instead.</p><p>But sometimes if you need to wire a lot of mock methods in order to test something, and it’s much easier to spy a real class and run a specific method, or if you want to perform calling the real dependency, service or method, then spy would make sense.</p><p>Or, if you are using AemContext, you can load a mock json file and use it as your mock resource or page like I have in my TitleModelTest class below.</p><p>10. Positive/negative test cases</p><p>Many developers tend to either write positive test cases only or write just enough test cases to meet line coverage. A good unit test class should cover both positive and negative scenarios of the method and should consider all possible data and inputs for the method.</p><p>11. Keep execution time in mind</p><p>Entire application test cases should finish running quickly.</p><p>12. Peer review with QA engineers</p><p>Review your unit test cases with your QA engineer so they can provide feedback. It will help them understand the function of the code and write better test cases/automation scripts as well.</p><p>13. Leverage mocking libraries to help you accelerate unit testing</p><p>There are many open source libraries out there you can use for unit testing your AEM application, either it’s backend Java, clientside or server JavaScript.</p><p>For example, there’s <a href="http://wcm.io/testing/aem-mock/">wcm.io</a> to provide convenient mock context and objects for your backend AEM code. Consider using/upgrading to <a href="https://junit.org/junit5/">JUnit 5</a>.</p><p>For JS, there’re <a href="https://mochajs.org/">Mocha</a>, <a href="https://jasmine.github.io/">Jasmine</a> and <a href="https://reactjs.org/community/testing.html">React JS libraries</a> for your various unit testing needs.</p><h3><strong>Practical Tips/Code Snippets</strong></h3><p>In this section, I listed practical unit testing tips that I found useful.</p><p>To test expected and unexpected exceptions in JUnit 4</p><pre>@Test<br> public void testValidateNullMap() {<br>  correlationIdMap = null;<br>  try {<br>   classUnderTest.validate(correlationIdMap);<br>  } catch (NullPointerException npe) {<br>   <em>assertEquals</em>(NullPointerException.class, npe.getClass());<br>  } catch (DataSwapException dwe) {<br>   <em>fail</em>(&quot;it should not have thrown DataSwapException&quot;);<br>  }<br> }</pre><p>In JUnit5, there’s an enhancement, where you can directly use <a href="https://junit.org/junit5/docs/current/api/org/junit/jupiter/api/Assertions.html#assertThrows(java.lang.Class,org.junit.jupiter.api.function.Executable)">assertThrows</a> or <a href="https://junit.org/junit5/docs/current/api/org/junit/jupiter/api/Assertions.html#assertDoesNotThrow(org.junit.jupiter.api.function.Executable)">assertDoesNotThrow</a>.</p><h3><strong>Enable Unit Testing in AEM App</strong></h3><p>To enable unit testing in AEM app, the first step is to design your application with separation of concerns and MVC pattern. Don’t put all your back-end business logics, front-end JS, CSS and HTML into one JSP file. Write modular unit testable codes in each layer with Sightly, Sling Models, OSGI services, Clientlibs and JS frameworks etc.</p><h3><strong>Code Reference</strong></h3><p>For your reference, I have updated my <a href="https://github.com/guangweiyao/blog/blob/master/core/src/test/java/org/myorg/blog/core/models/TitleModelTest.java">example blog code repository</a> with the guidelines mentioned above. The code is in master branch, where is AEM 6.4 compatible.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uf1NWGBELJX_k4Qr89b3Sg.gif" /><figcaption>Enhanced TitleModelTest run with coverage</figcaption></figure><h3><strong>Conclusion</strong></h3><p>There’s no set way of unit testing, if you already have a working unit test implementation for your AEM application, and it meets the guidelines above and can easily scale, you may not need to redo everything. But if you have poor unit testing codes or don’t have any unit test at all, I hope you can consider writing unit test codes with the guidelines above.</p><p>I hope this post gives you new ideas to review your unit testing and provides guidelines you can follow with your team. Feel free to highlight, comment on the statement you like. I’d like to hear your thoughts and feedback. I will update the post as I find anything new.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f58eeecaae4f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>