<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Fazeem Mohammed</title>
    <description>The latest articles on Forem by Fazeem Mohammed (@fazeem).</description>
    <link>https://forem.com/fazeem</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F946194%2F1e19daf7-e57c-433c-8c26-02be6f426678.jpeg</url>
      <title>Forem: Fazeem Mohammed</title>
      <link>https://forem.com/fazeem</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/fazeem"/>
    <language>en</language>
    <item>
      <title>Tricks to Increase your productivity</title>
      <dc:creator>Fazeem Mohammed</dc:creator>
      <pubDate>Sun, 13 Nov 2022 09:24:19 +0000</pubDate>
      <link>https://forem.com/fazeem/tricks-to-increase-the-productivity-3eo3</link>
      <guid>https://forem.com/fazeem/tricks-to-increase-the-productivity-3eo3</guid>
      <description>&lt;p&gt;Is anybody faced a scenario where they found it's efficient to automate the code generation so that eliminate monotonous work,&lt;br&gt;
here a few scenarios I faced and how few tricks helped me to increase the productivity&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Creating Database domain class from Schema&lt;/strong&gt;, most of the time the database columns will be in snake case (eg: COLUMN_NAME), it will be error prone to create domain object of Table which have more than 20 columns manually. There are tools available in Hibernate and other ORM frame work to do it, but if don't want to use it  please use the following snippet.&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static void printSnakeListToJavaVar(List&amp;lt;String&amp;gt; snakeList) {
    for (String columnName : snakeList) {
        columnName = columnName.trim();
        System.out.println("@Column(name=\"" + columnName + "\")");
        System.out.println("String " + snakeToJavaVar(columnName.toLowerCase()) + ";");
    }

}
public static String snakeToJavaVar(String str) {
    str=str.toLowerCase();
    // Run a loop till string
    return capitalizeFirstCharAfterDelimiter(str, "_");
}
private static String capitalizeFirstCharAfterDelimiter(String str, String deLimiter) {
    // string contains delimiter
    while (str.matches(".*" + deLimiter + ".*")) {

        str = str.replaceFirst(
                deLimiter + "[a-z0-9]",
                String.valueOf(
                        Character.toUpperCase(
                                str.charAt(
                                        str.indexOf(deLimiter) + 1))));
    }

    return str;
}
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Schema from Domain object&lt;/strong&gt; like in the first example there might situations a dev will be encountering to create a schema from domain object, the following code snippet will be helpful in this scenario&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public static String camelToSnake(String str) {
    String result = "";
    char c = str.charAt(0);
    result = result + Character.toLowerCase(c);
    for (int i = 1; i &amp;lt; str.length(); i++) {

        char ch = str.charAt(i);
        if (Character.isUpperCase(ch)) {
            result = result + '_';
            result
                    = result
                    + Character.toLowerCase(ch);
        }else {
            result = result + ch;
        }
    }

    return result;
}
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;li&gt;

&lt;p&gt;&lt;strong&gt;Delimited String to Upper Camel Case&lt;/strong&gt;  this is used when situation when dev has to Transform a String  or set of String's which are Saved in ERP,DB etc. to a String presentable in UI&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CaseConvertor.stringToUpperCamelIncludeDelimiter("12 DAYS"," ")
public static String stringToUpperCamelIncludeDelimiter(String str, String delimiter) {
    return Arrays.stream(str.toLowerCase().split(delimiter))
            .map(CaseConvertor::capitalize)
            .collect(Collectors.joining(delimiter));
}

public static String capitalize(String str) {
    if (str == null || str.length() &amp;lt;= 1) return str;
    return str.substring(0, 1).toUpperCase() + str.substring(1);
}
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Want more tricks?&lt;br&gt;
Please comment here &lt;/p&gt;

</description>
      <category>java</category>
      <category>productivity</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>[Solution] Elastic Integration issue of Apollo server Graph QL program deployed as AWS lambda</title>
      <dc:creator>Fazeem Mohammed</dc:creator>
      <pubDate>Mon, 07 Nov 2022 22:02:15 +0000</pubDate>
      <link>https://forem.com/fazeem/solution-elastic-integration-issue-of-apollo-server-graph-ql-program-deployed-as-aws-lambda-21g</link>
      <guid>https://forem.com/fazeem/solution-elastic-integration-issue-of-apollo-server-graph-ql-program-deployed-as-aws-lambda-21g</guid>
      <description>&lt;p&gt;Hi,&lt;/p&gt;

&lt;p&gt;Anybody facing Elastic Integration issue with Apollo server GraphQL program deployed as AWS lambda?&lt;br&gt;
with error message &lt;br&gt;
&lt;code&gt;Unable to instrument Lambda handler \"graphql.graphqlHandler\" due to name conflict with \"graphql\", please choose a different Lambda handler name&lt;/code&gt;&lt;br&gt;
here is the solution for it -&amp;gt;&lt;br&gt;
&lt;a href="https://github.com/trentm/example-apollo-lambda/tree/v1.0.0#notes--troubleshooting"&gt;https://github.com/trentm/example-apollo-lambda/tree/v1.0.0#notes--troubleshooting&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>graphql</category>
      <category>elasticsearch</category>
    </item>
    <item>
      <title>Open source e-commerce project?</title>
      <dc:creator>Fazeem Mohammed</dc:creator>
      <pubDate>Wed, 26 Oct 2022 17:44:25 +0000</pubDate>
      <link>https://forem.com/fazeem/open-source-e-commerce-project-20fh</link>
      <guid>https://forem.com/fazeem/open-source-e-commerce-project-20fh</guid>
      <description>&lt;p&gt;I am looking for an e-commerce open source project, preferred Techstack is php/react, could you please comment here if you have any suggestions&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Tools and Web Site helpful for Java folks</title>
      <dc:creator>Fazeem Mohammed</dc:creator>
      <pubDate>Tue, 25 Oct 2022 10:09:18 +0000</pubDate>
      <link>https://forem.com/fazeem/tools-and-web-site-helpful-for-java-folks-3gd</link>
      <guid>https://forem.com/fazeem/tools-and-web-site-helpful-for-java-folks-3gd</guid>
      <description>&lt;h4&gt;
  
  
  Websites
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://json2csharp.com/code-converters/json-to-pojo"&gt;json2csharp.com&lt;/a&gt; - this website  helps to convert JSON string to Java Classes&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.yamllint.com/"&gt;yamllint&lt;/a&gt; - now a days Yml/Yaml is used across java projects as config tool, it's really hard to validate yml file structure as a single space can make yml corrupted, yaml lint helps to validate formatting of yml file&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  InteliJ Idea Plugins
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://plugins.jetbrains.com/plugin/8183-gitlink"&gt;GitLink &lt;/a&gt;- Gitlink Plugin Integrates most of the popular Git Based platform (GitLab, Bitbucket etc) to InteliJ Idea so Developers can open Web console directly from IDE&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://aws.amazon.com/intellij/"&gt;AWS toolkit&lt;/a&gt; - Rather than logging into aws console dev's can Trigger lambda, ecs tasks directly from IDE using this plugin&lt;/li&gt;
&lt;/ol&gt;

&lt;h4&gt;
  
  
  Tools
&lt;/h4&gt;

&lt;p&gt;NotePad++ - NotePad++ Regulars expression Search/Replace functionality and Column Mode (Alt+select) helped me to improve my productivity significantly&lt;/p&gt;

&lt;p&gt;Along with these tools using various shortcut's in InteliJ helped me to improve my productivity and speed of the development&lt;/p&gt;

&lt;p&gt;more suggestion please ?&lt;/p&gt;

</description>
      <category>java</category>
      <category>aws</category>
    </item>
    <item>
      <title>Enhanced Dynamo DB and Integration Test Using Dynamo Local</title>
      <dc:creator>Fazeem Mohammed</dc:creator>
      <pubDate>Sun, 16 Oct 2022 23:03:35 +0000</pubDate>
      <link>https://forem.com/fazeem/enhanced-dynamo-db-and-integration-test-using-dynamo-local-4kai</link>
      <guid>https://forem.com/fazeem/enhanced-dynamo-db-and-integration-test-using-dynamo-local-4kai</guid>
      <description>&lt;p&gt;AWS Released new Enhanced Dynamo Client &lt;a href="https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/dynamodb-enhanced-client.html"&gt;Enhanced Dynamo Client&lt;/a&gt; which helps Java developers to easily Implement DAO Implementation without writing the mapping logic and AWS provides &lt;a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html"&gt;Downloadable DynamoDb&lt;/a&gt; which helps developers to do the Integration testing with Dynamo DB without connecting to the Cloud.&lt;/p&gt;

&lt;p&gt;This post explains how to Implement a generic &lt;strong&gt;DynamoDBService&lt;/strong&gt; Class using &lt;a href="https://docs.aws.amazon.com/sdk-for-java/latest/developer-guide/dynamodb-enhanced-client.html"&gt;Enhanced Dynamo Client&lt;/a&gt; and Write Unit/Integration Test Cases using &lt;a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html"&gt;Downloadable DynamoDb&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The full source code can be found under following &lt;a href="https://github.com/fazeem84/DynamoDbLocal"&gt;repo&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I have used following links and github repos to build this example&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://www.baeldung.com/dynamodb-local-integration-testsl"&gt;baeldung&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://github.com/redskap/aws-dynamodb-java-example-local-testing"&gt;redskap GitRepository&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Prerequisite
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Java &amp;gt; 11&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Gradle &amp;gt; 5&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Setting Enhanced Client in Gradle
&lt;/h2&gt;

&lt;p&gt;To set up enhanced Client in Gradle following dependencies needs to be added&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  implementation 'com.amazonaws:aws-java-sdk-dynamodb:1.11.434'
  implementation 'software.amazon.awssdk:dynamodb:2.17.28'
   implementation 'software.amazon.awssdk:dynamodb-enhanced:2.17.28'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Setting up DynamoDb Local
&lt;/h2&gt;

&lt;p&gt;Aws documentation provides steps to setting up &lt;a href="https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.DownloadingAndRunning.html"&gt;maven build&lt;/a&gt; but Gradle setting up is not provided by AWS and this library is not available central maven repo, so users needs to set up aws maven repo for setting DynamoDb Local&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;repositories {
    maven {
        name
         url "https://s3-us-west-2.amazonaws.com/dynamodb-local/release"
    }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;following dependency will add DynamoDbLocal to the gradle project&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;testImplementation group: 'com.amazonaws', name: 'DynamoDBLocal', version: '1.11.119'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;you can find more info about the set up in &lt;a href="https://github.com/redskap/aws-dynamodb-java-example-local-testing/blob/master/README.md"&gt;https://github.com/redskap/aws-dynamodb-java-example-local-testing/blob/master/README.md&lt;/a&gt; . As a part of test setup copy &lt;a href="https://github.com/redskap/aws-dynamodb-java-example-local-testing/blob/master/src/test/java/io/redskap/java/aws/dynamodb/example/local/testing/AwsDynamoDbLocalTestUtils.java"&gt;AwsDynamoDbLocalTestUtils&lt;/a&gt; and call &lt;a href="https://github.com/redskap/aws-dynamodb-java-example-local-testing/blob/master/src/test/java/io/redskap/java/aws/dynamodb/example/local/testing/AwsDynamoDbLocalTestUtils.java#L30"&gt;AwsDynamoDbLocalTestUtils#initSqLite()&lt;/a&gt; during setup function of JUnit Test class&lt;/p&gt;

&lt;h3&gt;
  
  
  DynamoDb Domain POJO
&lt;/h3&gt;

&lt;p&gt;This class is POJO representation of Dynamo DB schema, I have used &lt;a href="https://projectlombok.org/"&gt;lombok&lt;/a&gt; to avoid boiler plating of Getter and Setter methods, @DynamoDbBean represents dynamo db structure and @DynamoDbPartitionKey represents primary key id&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; @Data
@DynamoDbBean
public class Student {
    private String studentId;
    private String studentName;
    private String department;
    @DynamoDbPartitionKey
    @DynamoDbAttribute("studentId")
    public String getStudentId() {
        return studentId;
    }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  DynamoDb Service Implementation
&lt;/h3&gt;

&lt;p&gt;This class has full DAO implementation&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;CreateTable&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Insert/Update Item based on partitions key&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get Item by Id&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://github.com/fazeem84/DynamoDbLocal/blob/main/src/main/java/com/dynamo/local/service/DynamoDBService.java"&gt;DynamoDBService.java&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up JUnit Test class
&lt;/h2&gt;

&lt;p&gt;During the startup JUnit will spin up a local dynamo DB instance and following code shows how to establish DynamoClient connectivity to local instance&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private static final String TABLE\_NAME = "Student";
private static  DynamoDBProxyServer server;
private static final String port = "8000";
private static final String uri = "http://localhost:"+port;

 @BeforeEach
    public void setUpTest() throws Exception {

        AwsDynamoDbLocalTestUtils.initSqLite();

        server = ServerRunner.createServerFromCommandLineArgs(
                new String\[\]{"-inMemory", "-port", port});
        server.start();
        client=DynamoDbClient.builder()
                .endpointOverride(URI.create(uri))
                .region(Region.AF\_SOUTH\_1)                .credentialsProvider(StaticCredentialsProvider.create(
                        AwsBasicCredentials.create("fakeMyKeyId","fakeSecretAccessKey")))
                .build();
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>java</category>
      <category>aws</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
