From b58f8202a884715d58f6a3ac68ee28e0ecae0cea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marten=20Prie=C3=9F?= Date: Thu, 5 Jul 2018 16:17:21 +0200 Subject: [PATCH] added some new constructors for simpler restTemplate injection --- .../commons/resource/ForgotPasswordResource.java | 11 +++++++++-- .../commons/resource/RegistrationResource.java | 11 +++++++++-- .../commons/resource/ValidationResource.java | 11 +++++++++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ForgotPasswordResource.java b/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ForgotPasswordResource.java index 7ca31ded..dfa31693 100644 --- a/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ForgotPasswordResource.java +++ b/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ForgotPasswordResource.java @@ -5,16 +5,23 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.util.Assert; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; public class ForgotPasswordResource implements BaseRestResource { - private String baseAuthApiUrl; - private RestTemplate restTemplate; + protected String baseAuthApiUrl; + protected RestTemplate restTemplate; public ForgotPasswordResource(String baseAuthApiUrl) { + this(baseAuthApiUrl, null); + } + + public ForgotPasswordResource(String baseAuthApiUrl, RestTemplate restTemplate) { + Assert.hasText(baseAuthApiUrl, "baseAuthApiUrl is required"); this.baseAuthApiUrl = baseAuthApiUrl; + this.restTemplate = restTemplate; } protected RestTemplate getRestTemplate() { diff --git a/commons-auth-api/src/main/java/io/rocketbase/commons/resource/RegistrationResource.java b/commons-auth-api/src/main/java/io/rocketbase/commons/resource/RegistrationResource.java index d4afd0d9..39c202fa 100644 --- a/commons-auth-api/src/main/java/io/rocketbase/commons/resource/RegistrationResource.java +++ b/commons-auth-api/src/main/java/io/rocketbase/commons/resource/RegistrationResource.java @@ -6,16 +6,23 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.util.Assert; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; public class RegistrationResource implements BaseRestResource { - private String baseAuthApiUrl; - private RestTemplate restTemplate; + protected String baseAuthApiUrl; + protected RestTemplate restTemplate; public RegistrationResource(String baseAuthApiUrl) { + this(baseAuthApiUrl, null); + } + + public RegistrationResource(String baseAuthApiUrl, RestTemplate restTemplate) { + Assert.hasText(baseAuthApiUrl, "baseAuthApiUrl is required"); this.baseAuthApiUrl = baseAuthApiUrl; + this.restTemplate = restTemplate; } protected RestTemplate getRestTemplate() { diff --git a/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ValidationResource.java b/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ValidationResource.java index 9eba43ba..9fa5f6aa 100644 --- a/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ValidationResource.java +++ b/commons-auth-api/src/main/java/io/rocketbase/commons/resource/ValidationResource.java @@ -8,16 +8,23 @@ import org.springframework.http.HttpEntity; import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; +import org.springframework.util.Assert; import org.springframework.web.client.RestTemplate; import org.springframework.web.util.UriComponentsBuilder; public class ValidationResource implements BaseRestResource { - private String baseAuthApiUrl; - private RestTemplate restTemplate; + protected String baseAuthApiUrl; + protected RestTemplate restTemplate; public ValidationResource(String baseAuthApiUrl) { + this(baseAuthApiUrl, null); + } + + public ValidationResource(String baseAuthApiUrl, RestTemplate restTemplate) { + Assert.hasText(baseAuthApiUrl, "baseAuthApiUrl is required"); this.baseAuthApiUrl = baseAuthApiUrl; + this.restTemplate = restTemplate; } protected RestTemplate getRestTemplate() {