BAEL-19988: Migrate rest-testing module to the com.baeldung package
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.rest.jbehave;
|
||||
|
||||
public class GitHubUser {
|
||||
|
||||
private String login;
|
||||
|
||||
public GitHubUser() {
|
||||
super();
|
||||
}
|
||||
|
||||
// API
|
||||
|
||||
public String getLogin() {
|
||||
return login;
|
||||
}
|
||||
|
||||
public void setLogin(final String login) {
|
||||
this.login = login;
|
||||
}
|
||||
|
||||
}
|
||||
-5
@@ -1,11 +1,6 @@
|
||||
package com.baeldung.rest.jbehave;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.baeldung.rest.GitHubUser;
|
||||
import org.baeldung.rest.RetrieveUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.jbehave.core.annotations.Given;
|
||||
import org.jbehave.core.annotations.Then;
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.baeldung.rest.jbehave;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class RetrieveUtil {
|
||||
|
||||
// API
|
||||
|
||||
public static <T> T retrieveResourceFromResponse(final HttpResponse response, final Class<T> clazz) throws IOException {
|
||||
final String jsonFromResponse = EntityUtils.toString(response.getEntity());
|
||||
final ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
return mapper.readValue(jsonFromResponse, clazz);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user