Skip to content

Commit 8097866

Browse files
committed
changes made in the new branch
1 parent 1026e87 commit 8097866

File tree

6 files changed

+131
-17
lines changed

6 files changed

+131
-17
lines changed

src/main/java/com/myeg/springBootDemo/LoginRestController.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,15 @@ public ResponseEntity<List<StockMasterDto>> getAllStockonHandsbyCostCenterId(){
2121
StockMasterDto st =new StockMasterDto("1", "Ajay", "2000");
2222
StockMasterDto st1 =new StockMasterDto("2", "Vijay", "2000");
2323
StockMasterDto st2=new StockMasterDto("3", "Sanjay", "2000");
24+
StockMasterDto st3=new StockMasterDto("3", "Veeru", "2000");
2425

2526
lt.add(st);
2627
lt.add(st2);
2728
lt.add(st1);
29+
lt.add(st3);
2830

31+
System.out.println("StockMasterDto:"+lt.toString());
32+
2933
return ResponseEntity.ok().body(lt);
3034
}
3135

src/main/java/com/myeg/springBootDemo/controller/CommentController.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,21 @@ public ResponseEntity<List<StockMasterDto>> addedSecondService(){
5656
return ResponseEntity.ok().body(lt);
5757
}
5858

59+
@GetMapping("/getDataForEmp")
60+
public ResponseEntity<List<Employee>> selectEmployee(){
61+
62+
List<Employee> lt = new ArrayList<Employee>();
63+
64+
Employee st =new Employee("1", "Ajay", "30");
65+
Employee st1 =new Employee("2", "Vijay", "30");
66+
Employee st2=new Employee("3", "Sanjay", "30");
67+
Employee st3=new Employee("4", "Jaya Vansanthi", "25");
68+
lt.add(st);
69+
lt.add(st2);
70+
lt.add(st1);
71+
lt.add(st3);
72+
73+
return ResponseEntity.ok().body(lt);
74+
}
75+
5976
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.myeg.springBootDemo.controller;
2+
3+
public class Employee {
4+
5+
private String id;
6+
private String name;
7+
private String age;
8+
9+
10+
11+
public Employee(String id, String name, String age) {
12+
super();
13+
this.id = id;
14+
this.name = name;
15+
this.age = age;
16+
}
17+
public String getId() {
18+
return id;
19+
}
20+
public void setId(String id) {
21+
this.id = id;
22+
}
23+
public String getName() {
24+
return name;
25+
}
26+
public void setName(String name) {
27+
this.name = name;
28+
}
29+
public String getAge() {
30+
return age;
31+
}
32+
public void setAge(String age) {
33+
this.age = age;
34+
}
35+
36+
37+
38+
}

src/main/java/com/myeg/springBootDemo/controller/StockMasterDto.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ public class StockMasterDto {
66
private String name;
77
private String sal;
88

9-
9+
public StockMasterDto() {
10+
// TODO Auto-generated constructor stub
11+
}
1012

1113
public StockMasterDto(String id, String name, String sal) {
1214
super();
@@ -32,6 +34,12 @@ public String getSal() {
3234
public void setSal(String sal) {
3335
this.sal = sal;
3436
}
37+
38+
@Override
39+
public String toString() {
40+
return "StockMasterDto [id=" + id + ", name=" + name + ", sal=" + sal + "]";
41+
}
42+
3543

3644

3745

src/test/java/com/myeg/springBootDemo/SpringBootDemoApplicationTests.java

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package com.myeg.springBootDemo;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
import org.springframework.core.ParameterizedTypeReference;
7+
///import org.apache.commons.codec.binary.Base64;
8+
import org.springframework.http.HttpEntity;
9+
import org.springframework.http.HttpHeaders;
10+
import org.springframework.http.HttpMethod;
11+
import org.springframework.http.MediaType;
12+
import org.springframework.http.ResponseEntity;
13+
import org.springframework.web.client.RestTemplate;
14+
15+
import com.myeg.springBootDemo.controller.StockMasterDto;
16+
17+
public class SpringRestClient {
18+
19+
public static final String REST_SERVICE_URI = "http://172.17.100.200:32087/getData";
20+
21+
22+
private static HttpHeaders getHeaders(){
23+
HttpHeaders headers = new HttpHeaders();
24+
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
25+
return headers;
26+
}
27+
28+
29+
/*
30+
* Send a GET request to get a specific user.
31+
*/
32+
private static void getUser(){
33+
// Assert.notNull(tokenInfo, "Authenticate first please......");
34+
System.out.println("\nTesting getUser API----------");
35+
RestTemplate restTemplate = new RestTemplate();
36+
// HttpEntity<String> request = new HttpEntity<String>();
37+
HttpEntity<String> request = new HttpEntity<String>(getHeaders());
38+
// ResponseEntity<List<StockMasterDto>> response = (<List<StockMasterDto>>)restTemplate.exchange(REST_SERVICE_URI, HttpMethod.GET,request,StockMasterDto.class);
39+
ResponseEntity<List<StockMasterDto>> restEntity = restTemplate.exchange(
40+
REST_SERVICE_URI, HttpMethod.GET,request ,new ParameterizedTypeReference<List<StockMasterDto>>() {
41+
});
42+
List<StockMasterDto> inventoryVarianceBeforeClosing = restEntity.getBody();
43+
System.out.println(inventoryVarianceBeforeClosing);
44+
}
45+
46+
/*
47+
* Send a POST request to create a new user.
48+
*/
49+
50+
/*
51+
* Send a DELETE request to delete a specific user.
52+
*/
53+
54+
55+
public static void main(String args[]){
56+
57+
for (int i=0;i<=10000;i++)
58+
{
59+
getUser();
60+
}
61+
62+
}
63+
}

0 commit comments

Comments
 (0)