Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 15

1* How u design rest appi

* to design api neede pojo class(Policy) ,one interface(Policyservice) in which curd method is
declaired,its imple (service)class(policyserviceimpl)

in which curd method impil adnd we inject policyservice repository I whichh extend curdrepository is
provided,one restcontroller(policycontroller)

in which design api

-when we design api two thing to be remeber produce-creating api and consume --that api calling to
anguler

ex.for save

* we have one restcontroller policycontroller in which we use @autowire to inject a service (interface
pilicyservice is which abstract save method is present)

@Restcontroller

policycontroller{

@Autowired

private PolicyService policyService;

*if he asked again how then

@PostMapping("/save")

public ResponseEntity<Policy> createPolicy(@RequestBody Policy policy, HttpServletRequest


request)

throws Exception {

Policy createdPolicy = this.policyService.savePolicy(policy);


logger.info("Policy Rest Controller Implementation : createPolicy() method");

return ResponseEntity.ok().body(createdPolicy);

where

*.ok().body()-Send response to the client with 200 http status code-200 satus code is success code

*policy-pojo class

*policyservice interface which have abstract method

* ResponseEntity -ResponseEntity represents the whole HTTP response: status code, headers, and body.
As a result, we can use it to fully configure

the HTTP response. If we want to use it, we have to return it from the endpoint; Spring takes care of the
res

*loggr- to track record of application

*saveolicy overide method which impl given in another class.

2*how u design ur pojo class

-mention 2,3 field and getter settr and tostring method and parameter constructor

-why toString --direct printing policy obj

@Entity

@Table(name="policy")

public class Policy{

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;

@Column(name="policynumber")

private String policyNumber;

*3 how to test api

-goto controller

-run project

-put url and unic identy /save

-select put,get,post,as per requirment

-for save u have to send request

-check responce

*4 how u manage database connection

-we manage in app.properties file and also configuration of logger

-in which we can change port by server.port -8080

#MysqL

spring.datasource.url=jdbc:mysql://localhost:3306/project?autoReconnect=true&useSSL=false

spring.datasource.username=root

spring.datasource.password=root

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.jpa.hibernate.ddl-auto=update

spring.jpa.show-sql=true

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

*5 how u design custom exp

@Responsestatus(http.status not found) to print msg

if id or somthing is not found in http request it will throw

-we design one calss extebds by runtime

@ResponseStatus(HttpStatus.NOT_FOUND)

public class PolicyTypeException extends RuntimeException {

private static final long serialVersionUID = 1L;

public PolicyTypeException(String message){

super(message); //calling

- for getting id design method and then it wiil chck in db if not found it will throw

@autowired

PolicyRepository repo;

@Override

public Policy getPolicyById(Integer Id) {

logger.info("Policy Service Implementation : getPolicyById() method");

Policy policy=repo.findById(Id);//6
if(policy==null) {

throw new PolicyTypeException("Policy id "+Id+" incorrect..");

return policy;

*6 which testing u have

we have work on unit tesing and used postman tool

we send daata from postman request and check it is came in method or not by debug point

same for id delete id is in method or not

*7 factory desiign pattern

-Design one interface InsuranceTypeService and in which method getinsurancetype

- design one class FactoryLifeGeneralnsurance in which one method which make validation and return
obj of iml class

-if useer put genralinsurace then it will return obj of genralinsu imp class

-and create two ipm classes and override method

*INterface

public interface InsuranceTypeService {

public String getInsuranceType();

*factorymethod

public class FactoryLifeGeneralnsurance {


public static InsuranceTypeService getUserType(String type) {

// Here type is life or general as per requirements

if (type == null) {

return null;

} else if (type.equalsIgnoreCase("life")) { //upper case or lower case

return new LifeInsurance(); //return LifeInsurance object only

//upper case or lower LIFE, life

} else if (type.equalsIgnoreCase("general")) {

return new GeneralInsurance(); //return generalinsurance object only

throw new PolicyTypeException("Invalid input"); //this is the custom exception

}}

*impl class

public class GeneralInsurance implements InsuranceTypeService {

@Override

public String getInsuranceType() {

return "General Insurance";

*9 how u handle transaction managment

if we got error like saving data and user data is saved but policy data is not saved to handel this
setuatiion we use
@EnableTransactionManagment in main service method

@Transaction in main save method of user /policy/class sevice

or in hibernate rollback cascascade we can use

*10 How to handle coonfigure logger

in properties file and in each method* private static final Logger logger =
LoggerFactory.getLogger(InsuranceRestApplication.class);

logging.level.root=WARN

loging,level.org.springframwork.web=DEBUG

logging.level.org.hibernate.ddl.auto=ERROR

logging.pattern.file= "%d{yyyy-MM-dd } [%thread] %-5level %logger{36} - %msg%n"

logging.file.name=F:/application.log

server.error.include-stacktrace=never

*11 How u write custom query

@Repository

public interface UserRepository extends JpaRepository<User, Serializable> {

public User findByUsername(String username);

@Query(value="select * from user c where city=?1", nativeQuery =true) c----part of quey


alice we put anything
List<

*12 archtecture

4 layer

-client layer in which presentation layer UI

-api layer in which restfull web service Web services(APi)

-service layer in which buissness logic policy service,claim service,nomeeni


srvice,payment service,

-middelware srvices logging service,tarsaction managment,security


managment

-Dao layer in which presentation logic reppository layer dao layer

-database layer mysql db

*13 what r the server u used to deploy

I have not worked on deployment, diffrant team is there and managment level people is handling this
things

1 Local machine --chek code on local mc

2 Development servrer -ip url live deployent 192.168.12.2 primary developer team will usee this

3 Test server -tetsing team use this server

4 user acceptance testing-client approved the projecct then deploy on this server

5 production server -final work is deploye live on this server

*14 flow of project


html--------------type script file----------------Services----------API call---------------Backend- API Layer(Rest
controller)----Service-DAO -Database

*15 how to connect frontend and backend

1-from html user can send requst then it will goto

2- ts file then it will call service layer of angular

3-then it will call diff api using url http//localhost/8882

4-then control wiil goto backend controller-service -daolayer-db

*16 TECHNOLOGY

programing laguag-java

front end-anguler

webservice-Restfull

framework-springboot hibernate

databse-mysql

server-apacheTomcat

version control-git

buuilding tool -maven

sdlc-Agile

Testing-unit tetsing

log managment tool-Logger

Api tesing -postman

IDE -Spring tool suit

Editor-vs code
Design pattern-factory

project managment tool-JIRA

*17 have u followed release notes

yes

in this what we are dilivering to client and by seeing he can understand what actuaal flow is

summery of project version/and improvement

in summery we have log in mangment(user should b able to log in) and policy managment(user shoould
be able to add /upadate\delete)

*18 known issue

sometimes we know the issue regarding app so

we have to mention in format issue like serch button is not working and give to client

*19 bug fixing

sometimes bugs like null pointer (sometimes ref varible is acccesed and not pioninting tpo obj)

or arrauindex out of bound(elemnet is going beyond size of arrau ) happen

****JIRA***

issue---story or task

*how to change server name

-server.port=8080

-server.context-path=/anyHost
* validation for spring security

-we have enable spring security we have user managment service(http) is there it takes(filter) username
and passward and check in db present or not

-if username is present we have checking encrypted pass with decrypting pass checking everything is
fine or not .if fine we creating jwt token and

we r sending back to user(filter) token consist of algorithm ,username, expiry time , authentication
pssing to user and whenever trying to hit another

api using that token .we checking authorization, header present or not in postman .if present we getting
that token converting into userdatails retriving

username from db,for every request it will not check

first u got authorization then it will create session context and then in session context authenticcate
username and passsword .

*sorting Project related

@Repository

public interface StudentRepository extends PagingAndSortingRepository<Student, Serializable> {

List<Student> findByUniversityOrderByNameAsc(String university);

List<Student> findAllByOrderByNameAsc();

@Query("select s from Student s")

List<Student> findAllAndSortByName(Sort sort);

@Query("select s from Student s where s.university = ?1")


List<Student> findByUniversityAndSortByNameLength(String university, Sort sort);

****In server side we have to added 1 dependency-Eureka Server Dependency

In client side we have to added 3 dependency-1:Spring boot actuator

2: Eureka discovery Client

3: Spring Web

*INTRODUCTION

“I worked with a 8 person team (4 developers, 2,tester,1 BA, 1 PM)

-on the life insurance domain

-It is web based application that keep track of policy details of each customer,

-there are diff type of policy such as retierment,medical,loan,children,

-there are diff pay modes like montholy,querterly,yearly,payment can be online or check

-it has facility to provide nomeenee details ,able to veiw transaction,claim details ,premium details .

-working as team member we devlope a rest web services


-main role was in backend like db and controller ,services

-analyze requirment , design codiing and testing

-Design user interface using anguler

-prepare test and perform manual testing

-bug fixing

-involved knowllage sharing activities with team

- the technology we have used like core java,restfull web service,spring boot
hibernate,mysql,tomcat,git,maven,angular

**do you use main method in your project?no

if you work with Web Applications, however, they don't have main method. The artifacts are Web
Archives (have extension .WAR). Instead of "main" method you're supposed to create a
SpringBootServletInitializer that will serve as an entry point of your WAR.

***How to merge two branches?

git checkout main

git merge local

***select name from emp whre salary>=10000;

**sending responce ---res.setStatus(nnn);

** The HTTP 409 status code (Conflict) indicates that the request could not be processed because of
conflict in the request,

***304--indicates that there is no need to retransmit the requested resources.


**How do I get a 409 error?

Conflicts are most likely to occur in response to a PUT request.

**What is a 500 response code?

The HyperText Transfer Protocol (HTTP) 500 Internal Server Error server error response code indicates
that the server encountered an unexpected condition that prevented it from fulfilling the request

**method in repository layr

findAll, findAllById, findById, deleteAll, deleteById, save, saveAll.

***send status to client

return Responceentity.ok.body(hhtp.status)

****ROLE

i have worked on 3 layers. But specifically i've worked on Service layer where i was delecating the
controller requests to DAO layer. Also there I write business logic like if I want to perform any operation
before sending out a call to the DAO.

**Immutable class

final calss A{

private String name;


private A(String name ){

this.name =name;

public String getName(){

return name;

}}

****************************************

PAcific iife secured system

fcci in group,

You might also like