Class RestUtils
- java.lang.Object
-
- com.redhat.parodos.examples.utils.RestUtils
-
public final class RestUtils extends Object
RestUtils is a utility class. All its methods must be declared as static so they can't be overridden.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.springframework.http.ResponseEntity<String>executePost(String urlString, String payload)Create a new resource by POSTing the given payload to the URL, and returns the response as ResponseEntity.static StringgetBase64Creds(String username, String password)Generates a Base64 encoding of username:password stringstatic org.springframework.http.HttpEntity<String>getRequestWithHeaders(String username, String password)Creates a new HttpHeader and set the Authorization object according to @see getBase64Credsstatic org.springframework.http.ResponseEntity<String>restExchange(String urlString, String username, String password)Execute the GET HTTP method to the given URL, writing the given request entity to the request, and returns the response as ResponseEntity.
-
-
-
Method Detail
-
executePost
public static org.springframework.http.ResponseEntity<String> executePost(String urlString, String payload)
Create a new resource by POSTing the given payload to the URL, and returns the response as ResponseEntity.- Parameters:
urlString- the URLpayload- object to post- Returns:
- See Also:
RestTemplate.postForEntity(URI, Object, Class),ResponseEntity
-
restExchange
public static org.springframework.http.ResponseEntity<String> restExchange(String urlString, String username, String password)
Execute the GET HTTP method to the given URL, writing the given request entity to the request, and returns the response as ResponseEntity.- Parameters:
urlString- the URLusername- the usernamepassword- the password- Returns:
- See Also:
RestTemplate.exchange(String, HttpMethod, HttpEntity, Class, Object...),ResponseEntity
-
getRequestWithHeaders
public static org.springframework.http.HttpEntity<String> getRequestWithHeaders(String username, String password)
Creates a new HttpHeader and set the Authorization object according to @see getBase64Creds- Parameters:
username- the usernamepassword- the password- Returns:
- the @see org.springframework.http.HttpEntity
-
-