Skip to content

Commit

Permalink
changes made in the new branch
Browse files Browse the repository at this point in the history
  • Loading branch information
ajayvelagala committed Feb 18, 2020
1 parent 1026e87 commit 8097866
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,15 @@ public ResponseEntity<List<StockMasterDto>> getAllStockonHandsbyCostCenterId(){
StockMasterDto st =new StockMasterDto("1", "Ajay", "2000");
StockMasterDto st1 =new StockMasterDto("2", "Vijay", "2000");
StockMasterDto st2=new StockMasterDto("3", "Sanjay", "2000");
StockMasterDto st3=new StockMasterDto("3", "Veeru", "2000");

lt.add(st);
lt.add(st2);
lt.add(st1);
lt.add(st3);

System.out.println("StockMasterDto:"+lt.toString());

return ResponseEntity.ok().body(lt);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,21 @@ public ResponseEntity<List<StockMasterDto>> addedSecondService(){
return ResponseEntity.ok().body(lt);
}

@GetMapping("/getDataForEmp")
public ResponseEntity<List<Employee>> selectEmployee(){

List<Employee> lt = new ArrayList<Employee>();

Employee st =new Employee("1", "Ajay", "30");
Employee st1 =new Employee("2", "Vijay", "30");
Employee st2=new Employee("3", "Sanjay", "30");
Employee st3=new Employee("4", "Jaya Vansanthi", "25");
lt.add(st);
lt.add(st2);
lt.add(st1);
lt.add(st3);

return ResponseEntity.ok().body(lt);
}

}
38 changes: 38 additions & 0 deletions src/main/java/com/myeg/springBootDemo/controller/Employee.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.myeg.springBootDemo.controller;

public class Employee {

private String id;
private String name;
private String age;



public Employee(String id, String name, String age) {
super();
this.id = id;
this.name = name;
this.age = age;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getAge() {
return age;
}
public void setAge(String age) {
this.age = age;
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ public class StockMasterDto {
private String name;
private String sal;


public StockMasterDto() {
// TODO Auto-generated constructor stub
}

public StockMasterDto(String id, String name, String sal) {
super();
Expand All @@ -32,6 +34,12 @@ public String getSal() {
public void setSal(String sal) {
this.sal = sal;
}

@Override
public String toString() {
return "StockMasterDto [id=" + id + ", name=" + name + ", sal=" + sal + "]";
}




Expand Down

This file was deleted.

63 changes: 63 additions & 0 deletions src/test/java/com/myeg/springBootDemo/SpringRestClient.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.myeg.springBootDemo;

import java.util.Arrays;
import java.util.List;

import org.springframework.core.ParameterizedTypeReference;
///import org.apache.commons.codec.binary.Base64;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.client.RestTemplate;

import com.myeg.springBootDemo.controller.StockMasterDto;

public class SpringRestClient {

public static final String REST_SERVICE_URI = "http://172.17.100.200:32087/getData";


private static HttpHeaders getHeaders(){
HttpHeaders headers = new HttpHeaders();
headers.setAccept(Arrays.asList(MediaType.APPLICATION_JSON));
return headers;
}


/*
* Send a GET request to get a specific user.
*/
private static void getUser(){
// Assert.notNull(tokenInfo, "Authenticate first please......");
System.out.println("\nTesting getUser API----------");
RestTemplate restTemplate = new RestTemplate();
// HttpEntity<String> request = new HttpEntity<String>();
HttpEntity<String> request = new HttpEntity<String>(getHeaders());
// ResponseEntity<List<StockMasterDto>> response = (<List<StockMasterDto>>)restTemplate.exchange(REST_SERVICE_URI, HttpMethod.GET,request,StockMasterDto.class);
ResponseEntity<List<StockMasterDto>> restEntity = restTemplate.exchange(
REST_SERVICE_URI, HttpMethod.GET,request ,new ParameterizedTypeReference<List<StockMasterDto>>() {
});
List<StockMasterDto> inventoryVarianceBeforeClosing = restEntity.getBody();
System.out.println(inventoryVarianceBeforeClosing);
}

/*
* Send a POST request to create a new user.
*/

/*
* Send a DELETE request to delete a specific user.
*/


public static void main(String args[]){

for (int i=0;i<=10000;i++)
{
getUser();
}

}
}

0 comments on commit 8097866

Please sign in to comment.