Mockito 101 – Unit Testing in Java Apps

Mockito is an open source framework that allows you to easily create mocks (test doubles). Mocks are objects that have return values to method executions made during the test and has recorded expectations of these executions. Mocks can also throw an exception if they receive a call they don’t expect. They are checked during verification to ensure … Continue reading Mockito 101 – Unit Testing in Java Apps

Advertisement

How to deploy your node.js web application with AWS Beanstalk?

This post will show you how we can quickly create a node.js web aplication based on express framework and how to deploy that application on AWS using AWS BeanStalk service. Now first you need to know what is AWS BeanStalk? Some information about AWS BeanStalk: AWS BeanStalk is the fastest and simplest way to deploy … Continue reading How to deploy your node.js web application with AWS Beanstalk?

Java-Spring or JavaScript-Node.js?

Spring Framework for Java has been around past 15 years since its initial release. Most of the web developers prefer spring to build enterprise level web apps. But since last 3-4 years the Javascript has become more popular not only in the client-side development(Angular and React) but also towards the server-side development, thanks to nodejs. … Continue reading Java-Spring or JavaScript-Node.js?

Web Development Trends in 2018 and for future!

Since the launch of the first website made by Tim Berners-Lee  in 1991, the website development practice have come a long way and every year new web design and development trends are coming. Developers are becoming more agile in learning about these new trends. In 2018,  we'll look at the new trends which are hot … Continue reading Web Development Trends in 2018 and for future!

Dynamic String Conversion in JAVA

Input: 2B Output: 2000000000 Code : import java.math.BigDecimal; import java.util.Scanner; public class DyanamicConversion { public static void main(String args[]){ //Scanner scan = new Scanner(System.in); String a ="2M"; String[][] conversion = {{"K","1000"},{"M","1000000"},{"B","1000000000"}}; for(int i=0;i<conversion.length;i++){ if(a.endsWith(conversion[i][0])){ BigDecimal temp = new BigDecimal(a.substring(0, a.indexOf(conversion[i][0]))); temp.multiply(new BigDecimal(conversion[i][1])); a = temp.toBigInteger().toString(); System.out.println(a); break; } } } }

Sending HTTP GET Request to a REST API in JAVA

HTTP/HTTPS Get/Post request /response using JAVA below. For detailed visit here: https://www.mkyong.com/java/how-to-send-http-request-getpost-in-java/ Code: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import javax.net.ssl.HttpsURLConnection; public class HttpURLConnection { public static void main(String[] args) throws IOException { String response = httpGet("https://services.groupkt.com/state/get/IND/all"); } public static String httpGet(String urlStr) throws IOException { URL obj = new URL(urlStr); HttpsURLConnection con … Continue reading Sending HTTP GET Request to a REST API in JAVA