Comment test out and add null check for tenant and baseUrl

Signed-off-by: Jonathan Philip Knoblauch <JonathanPhilip.Knoblauch@bosch-si.com>
This commit is contained in:
Jonathan Philip Knoblauch
2016-04-26 11:14:23 +02:00
parent d67e0c6381
commit 05d9536cae
3 changed files with 18 additions and 20 deletions

View File

@@ -71,6 +71,12 @@
<groupId>com.google.guava</groupId> <groupId>com.google.guava</groupId>
<artifactId>guava</artifactId> <artifactId>guava</artifactId>
</dependency> </dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.3</version>
</dependency>
<!-- Test --> <!-- Test -->

View File

@@ -8,6 +8,7 @@
*/ */
package org.eclipse.hawkbit.ddi.client; package org.eclipse.hawkbit.ddi.client;
import org.apache.commons.lang.Validate;
import org.eclipse.hawkbit.ddi.client.resource.RootControllerResourceClient; import org.eclipse.hawkbit.ddi.client.resource.RootControllerResourceClient;
import feign.Feign; import feign.Feign;
@@ -17,7 +18,7 @@ import feign.Logger.Level;
import feign.jackson.JacksonEncoder; import feign.jackson.JacksonEncoder;
/** /**
* @author Jonathan Knoblauch * TODO
* *
*/ */
public class DdiDefaultFeignClient { public class DdiDefaultFeignClient {
@@ -32,18 +33,10 @@ public class DdiDefaultFeignClient {
feignBuilder = Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract()) feignBuilder = Feign.builder().contract(new IgnoreMultipleConsumersProducersSpringMvcContract())
.requestInterceptor(new ApplicationJsonRequestHeaderInterceptor()).logLevel(Level.FULL) .requestInterceptor(new ApplicationJsonRequestHeaderInterceptor()).logLevel(Level.FULL)
.logger(new Logger.ErrorLogger()).encoder(new JacksonEncoder()).decoder(new DdiDecoder()); .logger(new Logger.ErrorLogger()).encoder(new JacksonEncoder()).decoder(new DdiDecoder());
Validate.notNull(baseUrl, "A baseUrl has to be set");
if (baseUrl == null) { Validate.notNull(tenant, "A tenant has to be set");
throw new IllegalStateException("A baseUrl has to be set");
}
if (tenant == null) {
throw new IllegalStateException("A tenant has to be set");
}
this.baseUrl = baseUrl; this.baseUrl = baseUrl;
this.tenant = tenant; this.tenant = tenant;
} }
public Builder getFeignBuilder() { public Builder getFeignBuilder() {
@@ -52,12 +45,9 @@ public class DdiDefaultFeignClient {
public RootControllerResourceClient getRootControllerResourceClient() { public RootControllerResourceClient getRootControllerResourceClient() {
// TODO tenant null throw exception
if (rootControllerResourceClient == null) { if (rootControllerResourceClient == null) {
String rootControllerResourcePath = this.baseUrl + RootControllerResourceClient.PATH; String rootControllerResourcePath = this.baseUrl + RootControllerResourceClient.PATH;
rootControllerResourcePath = rootControllerResourcePath.replace("{tenant}", tenant); rootControllerResourcePath = rootControllerResourcePath.replace("{tenant}", tenant);
rootControllerResourceClient = feignBuilder.target(RootControllerResourceClient.class, rootControllerResourceClient = feignBuilder.target(RootControllerResourceClient.class,
rootControllerResourcePath); rootControllerResourcePath);
} }

View File

@@ -1,6 +1,5 @@
package org.eclipse.hawkbit.example.ddi.client; package org.eclipse.hawkbit.example.ddi.client;
import org.eclipse.hawkbit.ddi.client.DdiExampleClient;
import org.junit.Test; import org.junit.Test;
/** /**
@@ -10,11 +9,14 @@ public class AppTest {
@Test @Test
public void AppTest() { public void AppTest() {
// final DdiExampleClient ddiClient = new
final DdiExampleClient ddiClient = new DdiExampleClient("http://localhost:8080/", "jktest", "DEFAULT"); // DdiExampleClient("http://localhost:8080/", "Einstein1", "DEFAULT",
ddiClient.run(); // 2000,
// new SaveArtifactsStrategy());
System.out.println("next steps........................"); // final Thread thread = new Thread(ddiClient);
// thread.run();
//
// System.out.println("next steps........................");
} }
} }