[BAEL-9710] - Standardized packages for spring-rest module

This commit is contained in:
amit2103 2018-12-08 18:37:08 +05:30
parent 5072291b32
commit 9eff0c662b
57 changed files with 112 additions and 94 deletions

View File

@ -1,4 +1,4 @@
package org.baeldung.resttemplate.lists;
package com.baeldung.resttemplate.lists;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -1,11 +1,12 @@
package org.baeldung.resttemplate.lists.client;
package com.baeldung.resttemplate.lists.client;
import org.baeldung.resttemplate.lists.dto.Employee;
import org.baeldung.resttemplate.lists.dto.EmployeeList;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.http.*;
import org.springframework.web.client.RestTemplate;
import com.baeldung.resttemplate.lists.dto.Employee;
import com.baeldung.resttemplate.lists.dto.EmployeeList;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,14 +1,15 @@
package org.baeldung.resttemplate.lists.controller;
package com.baeldung.resttemplate.lists.controller;
import org.baeldung.resttemplate.lists.dto.Employee;
import org.baeldung.resttemplate.lists.dto.EmployeeList;
import org.baeldung.resttemplate.lists.service.EmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.resttemplate.lists.dto.Employee;
import com.baeldung.resttemplate.lists.dto.EmployeeList;
import com.baeldung.resttemplate.lists.service.EmployeeService;
import java.util.List;
@RestController

View File

@ -1,4 +1,4 @@
package org.baeldung.resttemplate.lists.dto;
package com.baeldung.resttemplate.lists.dto;
public class Employee {

View File

@ -1,4 +1,4 @@
package org.baeldung.resttemplate.lists.dto;
package com.baeldung.resttemplate.lists.dto;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,8 +1,9 @@
package org.baeldung.resttemplate.lists.service;
package com.baeldung.resttemplate.lists.service;
import org.baeldung.resttemplate.lists.dto.Employee;
import org.springframework.stereotype.Service;
import com.baeldung.resttemplate.lists.dto.Employee;
import java.util.ArrayList;
import java.util.List;

View File

@ -1,4 +1,4 @@
package org.baeldung.config;
package com.baeldung.sampleapp.config;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
@ -6,7 +6,7 @@ import org.springframework.context.annotation.ComponentScan;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@EnableAutoConfiguration
@ComponentScan("org.baeldung")
@ComponentScan("com.baeldung.sampleapp")
public class MainApplication implements WebMvcConfigurer {
public static void main(final String[] args) {

View File

@ -1,15 +1,16 @@
package org.baeldung.config;
package com.baeldung.sampleapp.config;
import java.util.ArrayList;
import java.util.List;
import org.baeldung.interceptors.RestTemplateHeaderModifierInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.client.ClientHttpRequestInterceptor;
import org.springframework.util.CollectionUtils;
import org.springframework.web.client.RestTemplate;
import com.baeldung.sampleapp.interceptors.RestTemplateHeaderModifierInterceptor;
@Configuration
public class RestClientConfig {

View File

@ -1,4 +1,4 @@
package org.baeldung.config;
package com.baeldung.sampleapp.config;
import java.text.SimpleDateFormat;
import java.util.List;
@ -18,7 +18,7 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
*/
@Configuration
@EnableWebMvc
@ComponentScan({ "org.baeldung.web" })
@ComponentScan({ "com.baeldung.sampleapp.web" })
public class WebConfig implements WebMvcConfigurer {
public WebConfig() {

View File

@ -1,4 +1,4 @@
package org.baeldung.interceptors;
package com.baeldung.sampleapp.interceptors;
import java.io.IOException;

View File

@ -1,10 +1,10 @@
package org.baeldung.repository;
import org.baeldung.web.dto.HeavyResource;
import org.baeldung.web.dto.HeavyResourceAddressOnly;
package com.baeldung.sampleapp.repository;
import java.util.Map;
import com.baeldung.sampleapp.web.dto.HeavyResource;
import com.baeldung.sampleapp.web.dto.HeavyResourceAddressOnly;
public class HeavyResourceRepository {
public void save(HeavyResource heavyResource) {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;

View File

@ -1,10 +1,11 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import org.baeldung.web.dto.Company;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.sampleapp.web.dto.Company;
@RestController
public class CompanyController {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import java.util.concurrent.CompletableFuture;
import java.util.function.Consumer;

View File

@ -1,11 +1,8 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import java.util.Map;
import org.baeldung.repository.HeavyResourceRepository;
import org.baeldung.web.dto.HeavyResource;
import org.baeldung.web.dto.HeavyResourceAddressOnly;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
@ -14,6 +11,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.sampleapp.repository.HeavyResourceRepository;
import com.baeldung.sampleapp.web.dto.HeavyResource;
import com.baeldung.sampleapp.web.dto.HeavyResourceAddressOnly;
@RestController
public class HeavyResourceController {

View File

@ -1,14 +1,14 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import java.util.Date;
import org.baeldung.web.dto.Item;
import org.baeldung.web.dto.ItemManager;
import org.baeldung.web.dto.Views;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.sampleapp.web.dto.Item;
import com.baeldung.sampleapp.web.dto.ItemManager;
import com.baeldung.sampleapp.web.dto.Views;
import com.fasterxml.jackson.annotation.JsonView;
@RestController

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import java.util.Collection;
import java.util.HashMap;
@ -6,8 +6,6 @@ import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.baeldung.web.dto.Foo;
import org.baeldung.web.exception.ResourceNotFoundException;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
@ -18,6 +16,9 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.servlet.support.ServletUriComponentsBuilder;
import com.baeldung.sampleapp.web.dto.Foo;
import com.baeldung.sampleapp.web.exception.ResourceNotFoundException;
@Controller
@RequestMapping(value = "/foos")
public class MyFooController {

View File

@ -1,9 +1,8 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import java.util.ArrayList;
import java.util.List;
import org.baeldung.web.dto.PactDto;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
@ -12,6 +11,8 @@ import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.sampleapp.web.dto.PactDto;
@RestController
public class PactController {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller;
package com.baeldung.sampleapp.web.controller;
import java.io.BufferedOutputStream;
import java.io.File;
@ -7,7 +7,6 @@ import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.baeldung.web.dto.Foo;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -15,6 +14,8 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import com.baeldung.sampleapp.web.dto.Foo;
// used to test HttpClientPostingTest
@RestController
public class SimplePostController {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller.advice;
package com.baeldung.sampleapp.web.controller.advice;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.AbstractJsonpResponseBodyAdvice;

View File

@ -1,13 +1,14 @@
package org.baeldung.web.controller.mediatypes;
package com.baeldung.sampleapp.web.controller.mediatypes;
import org.baeldung.web.dto.BaeldungItem;
import org.baeldung.web.dto.BaeldungItemV2;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.baeldung.sampleapp.web.dto.BaeldungItem;
import com.baeldung.sampleapp.web.dto.BaeldungItemV2;
@RestController
@RequestMapping(value = "/", produces = "application/vnd.baeldung.api.v1+json")
public class CustomMediaTypeController {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller.redirect;
package com.baeldung.sampleapp.web.controller.redirect;
import javax.servlet.http.HttpServletRequest;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class BaeldungItem {
private final String itemId;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class BaeldungItemV2 {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class Company {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
import com.thoughtworks.xstream.annotations.XStreamAlias;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class HeavyResource {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class HeavyResourceAddressOnly {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class HeavyResourceAddressPartialUpdate {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
import com.fasterxml.jackson.annotation.JsonView;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class ItemManager {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class PactDto {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.dto;
package com.baeldung.sampleapp.web.dto;
public class Views {
public static class Public {

View File

@ -1,4 +1,4 @@
package org.baeldung.web.exception;
package com.baeldung.sampleapp.web.exception;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;

View File

@ -1,6 +1,5 @@
package org.baeldung;
package com.baeldung;
import org.baeldung.config.MainApplication;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
@ -10,6 +9,7 @@ import com.baeldung.custom.CustomApplication;
import com.baeldung.produceimage.ImageApplication;
import com.baeldung.propertyeditor.PropertyEditorApplication;
import com.baeldung.responseheaders.ResponseHeadersApplication;
import com.baeldung.sampleapp.config.MainApplication;
import com.baeldung.web.log.app.Application;
@RunWith(SpringRunner.class)

View File

@ -1,4 +1,4 @@
package org.baeldung.client;
package com.baeldung.client;
public interface Consts {
int APPLICATION_PORT = 8082;

View File

@ -1,5 +1,6 @@
package com.baeldung.controllers;
import com.baeldung.sampleapp.config.MainApplication;
import com.baeldung.services.ExampleService;
import com.baeldung.transfer.LoginForm;
import org.junit.Before;
@ -12,7 +13,6 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.baeldung.config.MainApplication;
import static org.mockito.Mockito.when;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post;

View File

@ -1,5 +1,6 @@
package com.baeldung.controllers;
import com.baeldung.sampleapp.config.MainApplication;
import com.baeldung.services.ExampleService;
import com.baeldung.transfer.LoginForm;
import org.junit.Before;
@ -19,7 +20,6 @@ import static org.springframework.test.web.servlet.request.MockMvcRequestBuilder
import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
import org.baeldung.config.MainApplication;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = MainApplication.class)

View File

@ -1,4 +1,4 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
import java.io.IOException;

View File

@ -1,6 +1,6 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
import static org.baeldung.client.Consts.APPLICATION_PORT;
import static com.baeldung.client.Consts.APPLICATION_PORT;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;

View File

@ -1,6 +1,6 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
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.junit.Assert.assertThat;
import static org.junit.Assert.fail;

View File

@ -1,4 +1,4 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
import java.io.IOException;

View File

@ -1,6 +1,6 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
import static org.baeldung.client.Consts.APPLICATION_PORT;
import static com.baeldung.client.Consts.APPLICATION_PORT;
import java.io.File;
import java.io.IOException;

View File

@ -1,6 +1,6 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
import static org.baeldung.client.Consts.APPLICATION_PORT;
import static com.baeldung.client.Consts.APPLICATION_PORT;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

View File

@ -1,4 +1,4 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
import static org.hamcrest.Matchers.equalTo;
import static org.junit.Assert.assertThat;

View File

@ -1,4 +1,4 @@
package org.baeldung.okhttp;
package com.baeldung.okhttp;
import okhttp3.RequestBody;
import okhttp3.MediaType;

View File

@ -1,11 +1,12 @@
package org.baeldung.pact;
package com.baeldung.pact;
import org.baeldung.config.MainApplication;
import org.junit.BeforeClass;
import org.junit.runner.RunWith;
import org.springframework.boot.SpringApplication;
import org.springframework.web.context.ConfigurableWebApplicationContext;
import com.baeldung.sampleapp.config.MainApplication;
import au.com.dius.pact.provider.junit.PactRunner;
import au.com.dius.pact.provider.junit.Provider;
import au.com.dius.pact.provider.junit.State;

View File

@ -1,10 +1,9 @@
package org.baeldung.resttemplate;
package com.baeldung.resttemplate;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import org.baeldung.config.RestClientConfig;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
@ -17,6 +16,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.web.client.RestTemplate;
import com.baeldung.sampleapp.config.RestClientConfig;
import com.baeldung.transfer.LoginForm;
@RunWith(SpringJUnit4ClassRunner.class)

View File

@ -1,4 +1,4 @@
package org.baeldung.uribuilder;
package com.baeldung.uribuilder;
import static org.junit.Assert.assertEquals;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller;
package com.baeldung.web.controller;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.put;
@ -6,9 +6,6 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
import java.util.HashMap;
import org.baeldung.config.WebConfig;
import org.baeldung.web.dto.HeavyResource;
import org.baeldung.web.dto.HeavyResourceAddressOnly;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -21,6 +18,9 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.sampleapp.config.WebConfig;
import com.baeldung.sampleapp.web.dto.HeavyResource;
import com.baeldung.sampleapp.web.dto.HeavyResourceAddressOnly;
import com.fasterxml.jackson.databind.ObjectMapper;

View File

@ -1,6 +1,5 @@
package org.baeldung.web.controller.mediatypes;
package com.baeldung.web.controller.mediatypes;
import org.baeldung.config.WebConfig;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -12,6 +11,8 @@ import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;
import com.baeldung.sampleapp.config.WebConfig;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller.mediatypes;
package com.baeldung.web.controller.mediatypes;
import io.restassured.http.ContentType;
import org.junit.Test;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller.mediatypes;
package com.baeldung.web.controller.mediatypes;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

View File

@ -1,4 +1,4 @@
package org.baeldung.web.controller.redirect;
package com.baeldung.web.controller.redirect;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

View File

@ -8,7 +8,7 @@ Content-Length: 1759
Connection: keep-alive
Accept-Ranges: bytes
Server: nginx/1.10.0 (Ubuntu)
Date: Sat, 28 Apr 2018 20:53:35 GMT
Date: Sat, 08 Dec 2018 13:02:07 GMT
Last-Modified: Tue, 27 May 2014 02:35:47 GMT
ETag: "5383fa03-6df"
OkHttp-Sent-Millis: 1489054646765

View File

@ -4,10 +4,10 @@ GET
HTTP/1.1 301 Moved Permanently
8
Server: nginx/1.10.0 (Ubuntu)
Date: Sat, 28 Apr 2018 20:53:33 GMT
Date: Sat, 08 Dec 2018 13:02:04 GMT
Content-Type: text/html
Content-Length: 194
Connection: keep-alive
Location: https://publicobject.com/helloworld.txt
OkHttp-Sent-Millis: 1524948815122
OkHttp-Received-Millis: 1524948815342
OkHttp-Sent-Millis: 1544274128028
OkHttp-Received-Millis: 1544274128386

View File

@ -67,3 +67,9 @@ CLEAN 4b217e04ba52215f3a6b64d28f6729c6 333 194
READ 2d9345a30d2cc31bb3091d70a8ef6c18
DIRTY 2d9345a30d2cc31bb3091d70a8ef6c18
CLEAN 2d9345a30d2cc31bb3091d70a8ef6c18 7618 1759
READ 4b217e04ba52215f3a6b64d28f6729c6
DIRTY 4b217e04ba52215f3a6b64d28f6729c6
CLEAN 4b217e04ba52215f3a6b64d28f6729c6 333 194
READ 2d9345a30d2cc31bb3091d70a8ef6c18
DIRTY 2d9345a30d2cc31bb3091d70a8ef6c18
CLEAN 2d9345a30d2cc31bb3091d70a8ef6c18 7618 1759