CustomerServive Testing

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

Customer Service:

Application Structure:
Build:

Run the 19 Test cases and application is build successfully.

Run the SpringBoot Application:


Login to H2 DB:

http://localhost:8081/h2

Use Password : admin

Customer and address table


Postman : to test our application
1) Functionality: adding a new Customer
Service url: http://localhost:8081/customer
Method name: POST

Input: Customer info

"custId":2,

"fname": "A Gopi",

"lname": "AKula",

"age": 26,

"address": {

"street": "Street1",

"city": "City1",

"zipCode": "123456",

"country": "India"

}
Adding:

From Customer table:


From address Table:

Validations used:
In adding customer info:

From Customer: custId, fname, lname and address are mandatory.

From Address: City, zipCode and country are mandatory.


In the absence of custid:

In the absence of fname:

In the absence of fname value: i.e empty


Same for remaining validations too.
2) Functionality: Retrieve a Customer based on customer id.
Service url: http://localhost:8081/customer/2
Method name: GET

Input: Customer id by url

If customer info is not available for the given customer id: 6


3) Functionality: Retrieve all the Customers
Service url: http://localhost:8081/customers
Method name: GET

Input: Not required

Add a new customer with customer id 3 as below,


Now check retrieve all customers,
4) Functionality: search by Customer name
Service url: http://localhost:8081/customerNames/ A Gopi/akula
Method name: GET

Input: fname and lname by url

From input :

fname: A Gopi (space between A and Gopi)

lname: Akula
From input :

fname : AGopi (No space between A and Gopi)

lname: Akula

http://localhost:8081/customerNames/ AGopi/akula
From input : fname or lame

fname : Raju ( not available in DB)

lname: Akula ( lname matches for 2 records)

http://localhost:8081/customerNames/ Raju/akula
5) Functionality: update customer address by customer id
Service url: http://localhost:8081/customerNames/ A Gopi/akula
Method name: PUT

Input: customer id and address json

Cust id : 2

Address: Here in updating address, address mandatory

"id": 1,

"street": "Streetupdatedio",

"city": "HYD",

"zipCode": "123456ui",

"country": "Indiau"

Without addressing id:

Successful l update as below,


. Documentation generation with Swagger by postman tool:

From post man tool use the url with get method as

http://localhost:8081/v2/api-docs
Complete documentation in json format as:

"swagger": "2.0",

"info": {

"description": "Manages the customer information.",

"version": "1.0",

"title": "CustomerService",

"termsOfService": "Terms of service",

"contact": {

"name": "Goparaju Akula",

"url": "Infosys",

"email": "[email protected]"

},

"license": {

"name": "License of API",

"url": "API license URL"

},

"host": "localhost:8081",

"basePath": "/",

"tags": [

"name": "customer-service-controller",
"description": "Customer Service Controller"

],

"paths": {

"/customer": {

"post": {

"tags": [

"customer-service-controller"

],

"summary": "New Customer registration",

"description": "Add the customer to DB",

"operationId": "addCustomerUsingPOST",

"consumes": [

"application/json"

],

"produces": [

"*/*"

],

"parameters": [

"in": "body",

"name": "customer",

"description": "customer",

"required": true,
"schema": {

"$ref": "#/definitions/CustomerModel"

],

"responses": {

"200": {

"description": "OK",

"schema": {

"type": "string"

},

"201": {

"description": "Created"

},

"401": {

"description": "Unauthorized"

},

"403": {

"description": "Forbidden"

},

"404": {

"description": "Not Found"

}
},

"deprecated": false

},

"/customer/{id}": {

"get": {

"tags": [

"customer-service-controller"

],

"summary": "Retrieves single customer information",

"description": "Based on given customer id, customer information is retrieved",

"operationId": "getCustomerUsingGET",

"produces": [

"application/json"

],

"parameters": [

"name": "id",

"in": "path",

"description": "id",

"required": true,

"type": "integer",

"format": "int32"

}
],

"responses": {

"200": {

"description": "OK",

"schema": {

"$ref": "#/definitions/WildcardType"

},

"401": {

"description": "Unauthorized"

},

"403": {

"description": "Forbidden"

},

"404": {

"description": "Not Found"

},

"deprecated": false

},

"/customerNames/{fname}/{lname}": {

"get": {

"tags": [
"customer-service-controller"

],

"summary": "Retrieves customer information by fname and/or lname",

"description": "Based on given customer fname and/or lanme, customer


information is retrieved",

"operationId": "searchCustomerNameByUsingGET",

"produces": [

"application/json"

],

"parameters": [

"name": "fname",

"in": "path",

"description": "fname",

"required": true,

"type": "string"

},

"name": "lname",

"in": "path",

"description": "lname",

"required": true,

"type": "string"

}
],

"responses": {

"200": {

"description": "OK",

"schema": {

"type": "array",

"items": {

"type": "object"

},

"401": {

"description": "Unauthorized"

},

"403": {

"description": "Forbidden"

},

"404": {

"description": "Not Found"

},

"deprecated": false

},
"/customers": {

"get": {

"tags": [

"customer-service-controller"

],

"summary": "Retrieves all the customers information",

"description": "All the customers information available in is retrieved",

"operationId": "getAllCustomersUsingGET",

"produces": [

"application/json"

],

"responses": {

"200": {

"description": "OK",

"schema": {

"type": "array",

"items": {

"type": "object"

},

"401": {

"description": "Unauthorized"

},
"403": {

"description": "Forbidden"

},

"404": {

"description": "Not Found"

},

"deprecated": false

},

"/updateAddress/{id}": {

"put": {

"tags": [

"customer-service-controller"

],

"summary": "Updates the customer living address",

"description": "Based on given customer id and address, address is updated for the
given customer id",

"operationId": "updateLivingAddressUsingPUT",

"consumes": [

"application/json"

],

"produces": [

"*/*"
],

"parameters": [

"in": "body",

"name": "address",

"description": "address",

"required": true,

"schema": {

"$ref": "#/definitions/AddressModel"

},

"name": "id",

"in": "path",

"description": "id",

"required": true,

"type": "integer",

"format": "int32"

],

"responses": {

"200": {

"description": "OK",

"schema": {
"type": "string"

},

"201": {

"description": "Created"

},

"401": {

"description": "Unauthorized"

},

"403": {

"description": "Forbidden"

},

"404": {

"description": "Not Found"

},

"deprecated": false

},

"definitions": {

"AddressModel": {

"type": "object",

"properties": {
"city": {

"type": "string"

},

"country": {

"type": "string"

},

"id": {

"type": "integer",

"format": "int32"

},

"street": {

"type": "string"

},

"zipCode": {

"type": "string"

},

"title": "AddressModel"

},

"CustomerModel": {

"type": "object",

"properties": {

"address": {

"$ref": "#/definitions/AddressModel"
},

"age": {

"type": "integer",

"format": "int32"

},

"custId": {

"type": "integer",

"format": "int32"

},

"fname": {

"type": "string"

},

"lname": {

"type": "string"

},

"title": "CustomerModel"

},

"Optional«CustomerModel»": {

"type": "object",

"properties": {

"present": {

"type": "boolean"

}
},

"title": "Optional«CustomerModel»"

},

"WildcardType": {

"type": "object",

"properties": {

"present": {

"type": "boolean"

},

"title": "WildcardType"

Documentation generation with Swagger by swagger - UI:

From browser: http://localhost:8081/swagger-ui.html

Swagger for customer service as below,


Swagger UI with all rest end points as below,

You might also like