Skip to content

Commit f41ba6d

Browse files
author
Parvatam
committed
Test
1 parent ede544d commit f41ba6d

2 files changed

Lines changed: 20 additions & 3 deletions

File tree

src/main/java/com/example/Main.java

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,21 @@
2424
import org.springframework.boot.SpringApplication;
2525
import org.springframework.boot.autoconfigure.SpringBootApplication;
2626
import org.springframework.context.annotation.Bean;
27+
import org.springframework.http.HttpEntity;
28+
import org.springframework.http.ResponseEntity;
2729
import org.springframework.stereotype.Controller;
28-
import org.springframework.web.bind.annotation.*;
30+
import org.springframework.web.bind.annotation.RequestMapping;
31+
import org.springframework.web.bind.annotation.RequestParam;
32+
import org.springframework.web.bind.annotation.ResponseBody;
33+
import org.springframework.web.client.RestTemplate;
2934

3035
import javax.sql.DataSource;
3136
import java.sql.Connection;
3237
import java.sql.ResultSet;
3338
import java.sql.SQLException;
3439
import java.sql.Statement;
40+
import java.text.MessageFormat;
3541
import java.util.ArrayList;
36-
import java.util.List;
3742
import java.util.Map;
3843

3944
@Controller
@@ -43,6 +48,9 @@ public class Main {
4348
@Value("${spring.datasource.url}")
4449
private String dbUrl;
4550

51+
@Value("${test-app.url}")
52+
private String testUrl;
53+
4654
@Autowired
4755
private DataSource dataSource;
4856

@@ -76,7 +84,6 @@ String db(Map<String, Object> model) {
7684
}
7785
}
7886

79-
//Save a account to the postgres DB
8087
@RequestMapping(value = "/account")
8188
public @ResponseBody
8289
Result saveSfContact(@RequestParam(name = "name") String name, @RequestParam(name = "id")String id) {
@@ -95,6 +102,15 @@ Result saveSfContact(@RequestParam(name = "name") String name, @RequestParam(nam
95102
return result;
96103
}
97104

105+
@RequestMapping(value = "/get-account")
106+
public @ResponseBody
107+
Result getSfContact(@RequestParam(name = "name") String name, @RequestParam(name = "id")String id) {
108+
RestTemplate restTemplate = new RestTemplate();
109+
String formattedQuoteUrl = MessageFormat.format(testUrl, name, id);
110+
ResponseEntity<Result> result = restTemplate.getForEntity(formattedQuoteUrl, Result.class);
111+
return result.getBody();
112+
}
113+
98114
@Bean
99115
public DataSource dataSource() throws SQLException {
100116
if (dbUrl == null || dbUrl.isEmpty()) {

src/main/resources/application.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ logging.level.org.springframework=INFO
99
spring.profiles.active=production
1010

1111
server.port=${PORT:5000}
12+
test-app.url=https://af-app.herokuapp.com/account?name={0}&id={1}

0 commit comments

Comments
 (0)