Formatting changes

This commit is contained in:
caroline 2019-03-18 14:35:22 +01:00
parent ea3fe7aab9
commit 4fece2266e
10 changed files with 151 additions and 157 deletions

View File

@ -9,7 +9,6 @@ import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableDiscoveryClient
@EnableCircuitBreaker

View File

@ -31,13 +31,11 @@ public class ClientController {
}
@GetMapping
public String load() throws UnknownHostException {
public String load() {
RestTemplate restTemplate = new RestTemplate();
String resourceUrl
= "http://travel-agency-service:8080";
ResponseEntity<String> response
= restTemplate.getForEntity(resourceUrl, String.class);
String resourceUrl = "http://travel-agency-service:8080";
ResponseEntity<String> response = restTemplate.getForEntity(resourceUrl, String.class);
String serviceList = "";
if (discoveryClient != null) {
@ -45,8 +43,7 @@ public class ClientController {
for (String service : services) {
List<ServiceInstance> instances = this.discoveryClient
.getInstances(service);
List<ServiceInstance> instances = this.discoveryClient.getInstances(service);
serviceList += ("[" + service + " : " + ((!CollectionUtils.isEmpty(instances)) ? instances.size() : 0) + " instances ]");
}

View File

@ -14,9 +14,8 @@ public class TravelAgencyService {
this.restTemplate = restTemplate;
}
@HystrixCommand(fallbackMethod = "getFallbackName", commandProperties = {
@HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1000")
})
@HystrixCommand(fallbackMethod = "getFallbackName", commandProperties =
{ @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "1000") })
public String getDeals() {
return this.restTemplate.getForObject("http://travel-agency-service:8080/deals", String.class);
}

View File

@ -14,5 +14,4 @@ public class SpringContextIntegrationTest {
@Test
public void contextLoads() {
}
}

View File

@ -27,7 +27,8 @@ public class TravelAgencyController {
List<TravelDeal> travelDealList = travelDealRepository.findAll();
if (!travelDealList.isEmpty()) {
int randomDeal = new Random().nextInt(travelDealList.size());
return travelDealList.get(randomDeal).toString();
return travelDealList.get(randomDeal)
.toString();
} else {
return "NO DEALS";
}
@ -38,9 +39,17 @@ public class TravelAgencyController {
public String get() throws UnknownHostException {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("Host: ").append(InetAddress.getLocalHost().getHostName()).append("<br/>");
stringBuilder.append("IP: ").append(InetAddress.getLocalHost().getHostAddress()).append("<br/>");
stringBuilder.append("Type: ").append("Travel Agency").append("<br/>");
stringBuilder.append("Host: ")
.append(InetAddress.getLocalHost()
.getHostName())
.append("<br/>");
stringBuilder.append("IP: ")
.append(InetAddress.getLocalHost()
.getHostAddress())
.append("<br/>");
stringBuilder.append("Type: ")
.append("Travel Agency")
.append("<br/>");
return stringBuilder.toString();
}
}

View File

@ -87,14 +87,6 @@ public class TravelDeal {
@Override
public String toString() {
return "TravelDeal{" +
"id=" + id +
", destination='" + destination + '\'' +
", description='" + description + '\'' +
", dealPrice=" + dealPrice +
", oldPrice=" + oldPrice +
", departureDate=" + departureDate +
", arrivalDate=" + arrivalDate +
'}';
return "TravelDeal{" + "id=" + id + ", destination='" + destination + '\'' + ", description='" + description + '\'' + ", dealPrice=" + dealPrice + ", oldPrice=" + oldPrice + ", departureDate=" + departureDate + ", arrivalDate=" + arrivalDate + '}';
}
}

View File

@ -9,5 +9,4 @@ public interface TravelDealRepository extends MongoRepository<TravelDeal, String
public List<TravelDeal> findByDestination(String destination);
}