JAVA-960: Migrate spring-resttemplate to com.baeldung
This commit is contained in:
parent
137ff8d5ea
commit
25e76cdb88
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate;
|
||||
package com.baeldung.resttemplate;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.configuration;
|
||||
package com.baeldung.resttemplate.configuration;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.configuration;
|
||||
package com.baeldung.resttemplate.configuration;
|
||||
|
||||
import org.springframework.boot.web.client.RestTemplateCustomizer;
|
||||
import org.springframework.web.client.RestTemplate;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.configuration;
|
||||
package com.baeldung.resttemplate.configuration;
|
||||
|
||||
import static org.apache.commons.lang3.RandomStringUtils.randomAlphabetic;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import java.net.URI;
|
|||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.baeldung.resttemplate.web.dto.Foo;
|
||||
import com.baeldung.resttemplate.web.dto.Foo;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.configuration;
|
||||
package com.baeldung.resttemplate.configuration;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.configuration;
|
||||
package com.baeldung.resttemplate.configuration;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
|
@ -11,7 +11,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan("org.baeldung.resttemplate.configuration")
|
||||
@ComponentScan("com.baeldung.resttemplate.configuration")
|
||||
public class SpringConfig {
|
||||
|
||||
@Bean
|
|
@ -1,9 +1,9 @@
|
|||
package org.baeldung.resttemplate.web.controller;
|
||||
package com.baeldung.resttemplate.web.controller;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.baeldung.resttemplate.web.dto.Person;
|
||||
import org.baeldung.resttemplate.web.service.PersonService;
|
||||
import com.baeldung.resttemplate.web.service.PersonService;
|
||||
import com.baeldung.resttemplate.web.dto.Person;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.web.dto;
|
||||
package com.baeldung.resttemplate.web.dto;
|
||||
|
||||
import com.thoughtworks.xstream.annotations.XStreamAlias;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.web.dto;
|
||||
package com.baeldung.resttemplate.web.dto;
|
||||
|
||||
public class Person {
|
||||
private Integer id;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.web.exception;
|
||||
package com.baeldung.resttemplate.web.exception;
|
||||
|
||||
public class NotFoundException extends RuntimeException {
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
package org.baeldung.resttemplate.web.handler;
|
||||
package com.baeldung.resttemplate.web.handler;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.baeldung.resttemplate.web.exception.NotFoundException;
|
||||
import com.baeldung.resttemplate.web.exception.NotFoundException;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.client.ClientHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate.web.model;
|
||||
package com.baeldung.resttemplate.web.model;
|
||||
|
||||
public class Bar {
|
||||
private String id;
|
|
@ -1,6 +1,5 @@
|
|||
package org.baeldung.resttemplate.web.model;
|
||||
package com.baeldung.resttemplate.web.model;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Objects;
|
||||
|
||||
public class Employee {
|
|
@ -1,7 +1,7 @@
|
|||
package org.baeldung.resttemplate.web.service;
|
||||
package com.baeldung.resttemplate.web.service;
|
||||
|
||||
import org.baeldung.resttemplate.web.handler.RestTemplateResponseErrorHandler;
|
||||
import org.baeldung.resttemplate.web.model.Bar;
|
||||
import com.baeldung.resttemplate.web.handler.RestTemplateResponseErrorHandler;
|
||||
import com.baeldung.resttemplate.web.model.Bar;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.web.client.RestTemplateBuilder;
|
||||
import org.springframework.stereotype.Service;
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.resttemplate.web.service;
|
||||
package com.baeldung.resttemplate.web.service;
|
||||
|
||||
import org.baeldung.resttemplate.web.model.Employee;
|
||||
import com.baeldung.resttemplate.web.model.Employee;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.resttemplate.web.service;
|
||||
package com.baeldung.resttemplate.web.service;
|
||||
|
||||
import org.baeldung.resttemplate.web.dto.Person;
|
||||
import com.baeldung.resttemplate.web.dto.Person;
|
||||
|
||||
public interface PersonService {
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package org.baeldung.resttemplate.web.service;
|
||||
package com.baeldung.resttemplate.web.service;
|
||||
|
||||
import org.baeldung.resttemplate.web.dto.Person;
|
||||
import com.baeldung.resttemplate.web.dto.Person;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung;
|
||||
package com.baeldung;
|
||||
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
@ -8,7 +8,7 @@ import org.springframework.web.client.RestTemplate;
|
|||
|
||||
@Configuration
|
||||
@EnableAutoConfiguration
|
||||
@ComponentScan("org.baeldung")
|
||||
@ComponentScan("com.baeldung")
|
||||
public class SpringTestConfig {
|
||||
|
||||
@Bean
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.client;
|
||||
package com.baeldung.client;
|
||||
|
||||
public interface Consts {
|
||||
int APPLICATION_PORT = 8082;
|
|
@ -1,10 +1,10 @@
|
|||
package org.baeldung.client;
|
||||
package com.baeldung.client;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.baeldung.resttemplate.web.dto.Foo;
|
||||
import com.baeldung.resttemplate.web.dto.Foo;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.resttemplate;
|
||||
package com.baeldung.resttemplate;
|
||||
|
||||
import org.assertj.core.api.Assertions;
|
||||
import org.junit.Assert;
|
|
@ -1,7 +1,7 @@
|
|||
package org.baeldung.resttemplate;
|
||||
package com.baeldung.resttemplate;
|
||||
|
||||
import static org.apache.commons.codec.binary.Base64.encodeBase64;
|
||||
import static org.baeldung.client.Consts.APPLICATION_PORT;
|
||||
import static com.baeldung.client.Consts.APPLICATION_PORT;
|
||||
import static org.hamcrest.CoreMatchers.equalTo;
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
import static org.hamcrest.CoreMatchers.notNullValue;
|
||||
|
@ -14,8 +14,8 @@ import java.net.URI;
|
|||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
|
||||
import org.baeldung.resttemplate.web.dto.Foo;
|
||||
import org.baeldung.resttemplate.web.handler.RestTemplateResponseErrorHandler;
|
||||
import com.baeldung.resttemplate.web.handler.RestTemplateResponseErrorHandler;
|
||||
import com.baeldung.resttemplate.web.dto.Foo;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.http.HttpEntity;
|
|
@ -1,12 +1,12 @@
|
|||
package org.baeldung.resttemplate.postjson;
|
||||
package com.baeldung.resttemplate.postjson;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
|
||||
import org.baeldung.resttemplate.RestTemplateConfigurationApplication;
|
||||
import org.baeldung.resttemplate.web.dto.Person;
|
||||
import com.baeldung.resttemplate.RestTemplateConfigurationApplication;
|
||||
import com.baeldung.resttemplate.web.dto.Person;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
import org.junit.BeforeClass;
|
|
@ -1,8 +1,8 @@
|
|||
package org.baeldung.web.handler;
|
||||
package com.baeldung.web.handler;
|
||||
|
||||
import org.baeldung.resttemplate.web.exception.NotFoundException;
|
||||
import org.baeldung.resttemplate.web.handler.RestTemplateResponseErrorHandler;
|
||||
import org.baeldung.resttemplate.web.model.Bar;
|
||||
import com.baeldung.resttemplate.web.exception.NotFoundException;
|
||||
import com.baeldung.resttemplate.web.handler.RestTemplateResponseErrorHandler;
|
||||
import com.baeldung.resttemplate.web.model.Bar;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
|
@ -1,4 +1,4 @@
|
|||
package org.baeldung.web.service;
|
||||
package com.baeldung.web.service;
|
||||
|
||||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.method;
|
||||
import static org.springframework.test.web.client.match.MockRestRequestMatchers.requestTo;
|
||||
|
@ -6,9 +6,9 @@ import static org.springframework.test.web.client.response.MockRestResponseCreat
|
|||
|
||||
import java.net.URI;
|
||||
|
||||
import org.baeldung.SpringTestConfig;
|
||||
import org.baeldung.resttemplate.web.model.Employee;
|
||||
import org.baeldung.resttemplate.web.service.EmployeeService;
|
||||
import com.baeldung.SpringTestConfig;
|
||||
import com.baeldung.resttemplate.web.model.Employee;
|
||||
import com.baeldung.resttemplate.web.service.EmployeeService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
|
@ -1,15 +1,13 @@
|
|||
package org.baeldung.web.service;
|
||||
package com.baeldung.web.service;
|
||||
|
||||
import org.baeldung.resttemplate.web.model.Employee;
|
||||
import org.baeldung.resttemplate.web.service.EmployeeService;
|
||||
import com.baeldung.resttemplate.web.model.Employee;
|
||||
import com.baeldung.resttemplate.web.service.EmployeeService;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.Mockito;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
|
@ -1,16 +0,0 @@
|
|||
package org.baeldung;
|
||||
|
||||
import org.baeldung.resttemplate.RestTemplateConfigurationApplication;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(classes = RestTemplateConfigurationApplication.class)
|
||||
public class SpringContextTest {
|
||||
|
||||
@Test
|
||||
public void whenSpringContextIsBootstrapped_thenNoExceptions() {
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue