defect commit

This commit is contained in:
gexce
2017-09-11 17:14:39 +02:00
parent 2c1542c4f3
commit 9a658f5491
5 changed files with 168 additions and 18 deletions
@@ -0,0 +1,31 @@
package com.bayer.edam.migration;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.hateoas.MediaTypes;
import org.springframework.hateoas.client.Traverson;
public class Application {
private static final Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String args[]) {
Map<String, Object> parameters = new HashMap<>();
parameters.put("user", 27);
Traverson traverson;
try {
traverson = new Traverson(new URI("http://localhost:8080/api/"), MediaTypes.HAL_JSON);
String name = traverson.follow("movies", "movie", "actor").withTemplateParameters(parameters).toObject("$.name");
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
@@ -0,0 +1,18 @@
package hello;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.client.RestTemplate;
public class Application {
private static final Logger log = LoggerFactory.getLogger(Application.class);
public static void main(String args[]) {
RestTemplate restTemplate = new RestTemplate();
Quote quote = restTemplate.getForObject("http://gturnquist-quoters.cfapps.io/api/random", Quote.class);
restTemplate.
log.info(quote.toString());
}
}
+34
View File
@@ -0,0 +1,34 @@
package hello;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Quote {
private String type;
private Value value;
public Quote() {
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Value getValue() {
return value;
}
public void setValue(Value value) {
this.value = value;
}
@Override
public String toString() {
return "Quote{" + "type='" + type + '\'' + ", value=" + value + '}';
}
}
+34
View File
@@ -0,0 +1,34 @@
package hello;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
@JsonIgnoreProperties(ignoreUnknown = true)
public class Value {
private Long id;
private String quote;
public Value() {
}
public Long getId() {
return this.id;
}
public String getQuote() {
return this.quote;
}
public void setId(Long id) {
this.id = id;
}
public void setQuote(String quote) {
this.quote = quote;
}
@Override
public String toString() {
return "Value{" + "id=" + id + ", quote='" + quote + '\'' + '}';
}
}