Skip to main content

Posts

Showing posts from March, 2021

Base64 Encode and Decode password with Base64 Use with example

  😁 Base 64 Example: In this example, we are going to learn about How to encrypt a password and decodes the password in the java program language. With this article, we will understand What is encoding and decoding in java with the Base64 class. import java.util.Scanner; import java.util.Base64; class Test { public static void main(String[] args) { Scanner sc=new Scanner(System.in); System.out.println("Enter Password"); String password=sc.next(); System.out.println("Encode password: "+encode(password)); String encode=encode(password); System.out.println("Decode Password: "+decode(encode)); } //Encode: public static String encode(String input) { return Base64.getEncoder().encodeToString(input.getBytes()); } //Decode: public static String decode(String input) { byte[] decodedBytes = Base64.getDecoder().decode(input); return new String(decodedBytes); } }

How to create table in project realtime exprience

😂If you want to create a table in Oracle and MySql then this is for you . to create a database of our project.  If you want to know how to create a table for real projects like for the User table or the Register table then this article for you? Register table for sign up ============================== SQL> conn Enter user-name: techblog Enter password: Connected. --------------------users table----------------- SQL> create table users (   2      id           number(10) PRIMARY KEY ,   3      name     varchar2(50) NOT NULL,   4      email     varchar2(50) unique,   5      gender   varchar2(10) NOT NULL,   6      about      varchar2(200) DEFAULT 'hey ! I am using TechBlog',   7      password  varchar2(50) NOT NULL,   8      rdate         timestamp , profile default.png     9    ); Table created.   ---------create sequence---------------for useridseq SQL> CREATE SEQUENCE usersidseq    start with 1     increment by 1     minvalue 0    maxvalue 10000     cycle; Sequence cr

Spring Boot Curd Operation Without try, catch and If else inside the method 100% correct test

 package com.technoidentity.agastya.controller; import java.util.Date; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.technoidentity.agastya.model.TelemetryEvent; import com.technoidentity.ag

SpringBoot Curd Operation Controller Class

 package com.technoidentity.agastya.controller; import java.util.Date; import java.util.ArrayList; import java.util.List; import java.util.Optional; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.CrossOrigin; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import com.technoidentity.agastya.model.TelemetryEvent; import com.technoidentity.ag

How to Use Open API 3 tools in our Spring Boot Project | Its alternate of Swagger tools

 Setting up spring doc-open API To have springdoc-openapi automatically generate the OpenAPI 3 specification docs for our API, we simply add the springdoc-openapi-ui dependency to our pom.xml: <dependency>     <groupId>org.springdoc</groupId>     <artifactId>springdoc-openapi-ui</artifactId>     <version>1.5.2</version> </dependency> Then when we run our application, the OpenAPI descriptions will be available at the path /v3/api-docs by default: http://localhost:8080/v3/api-docs/ To use a custom path, we can indicate in the application.properties file: springdoc.api-docs.path=/api-docs Now we'll be able to access the docs at: http://localhost:8080/api-docs/ The OpenAPI definitions are in JSON format by default. For yaml format, we can obtain the definitions at: http://localhost:8080/api-docs.yaml ---------------------------------------------------------------------- If you want to test like post man then this is for you. Now we can ac

How to test Microservices' Controller with mokito and Junit

Add Dependency In your project ---------------------------------------------------- compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation group: 'junit', name: 'junit' testImplementation group: 'org.mockito', name: 'mockito-all', version: '1.10.19' implementation 'org.springframework.boot:spring-boot-starter-data-mongodb' implementation 'org.springframework.boot:spring-boot-starter-web' developmentOnly 'org.springframework.boot:spring-boot-devtools' testImplementation 'org.springframework.boot:spring-boot-starter-test' =====================================================  package com.technoidentity.agastya; import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.delete; import static org.springframew

How to push your project to remote repositery | how to send file in server

😂 Below the command, you follow and push your code into repositery. -----------------------------------------------------------------------------------------------  1.git clone -b <branch name> URL of repository 2.cd Inside the current file 3.git branch 4.git status 5.git add --a 6.clear 7.git commit -m "V1.0" 8.git push Dell@DESKTOP-Q0VP55V MINGW64 /p/prince $ git clone -b vitalz-assist-service https://Techno-Identity@dev.azure.com/Techno-Identity/Project%20Agasthya/_git/vitalz-assist-service Cloning into 'vitalz-assist-service'... remote: Azure Repos remote: Found 107 objects to send. (16 ms) Receiving objects: 100% (107/107), 72.30 KiB | 2.68 MiB/s, done. Resolving deltas: 100% (1/1), done. Dell@DESKTOP-Q0VP55V MINGW64 /p/prince $ cd vitalz-assist-service Dell@DESKTOP-Q0VP55V MINGW64 /p/prince/vitalz-assist-service (vitalz-assist-service) $ git status On branch vitalz-assist-service Your branch is up to date with 'origin/vitalz-assist-service'. Untra

How to Use swagger in your project | How to configure swagger in your project

 This is the Dependency you have to add =================================================== 1.Springfox Swagger UI  <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui --> <dependency>     <groupId>io.springfox</groupId>     <artifactId>springfox-swagger-ui</artifactId>     <version>2.6.1</version> </dependency> 2. springfox swagger2 <!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 --> <dependency>     <groupId>io.springfox</groupId>     <artifactId>springfox-swagger2</artifactId>     <version>2.6.1</version> </dependency> -------------------------------------------------------------------- 2. Write Controller class like that   package com.app.rest; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.a