From 71a7a0a202dd189bfc3760643b83422c3965adb3 Mon Sep 17 00:00:00 2001 From: Facundo Rossi Date: Wed, 31 Jan 2018 20:22:29 -0300 Subject: [PATCH 1/2] Postgres Integration Ready, CRUD Customer Ready --- template/pom.xml | 36 +++++++- .../techgroups/template/Application.java | 13 +++ .../template/business/CustomerService.java | 21 +++++ .../business/CustomerServiceImpl.java | 45 ++++++++++ .../template/configuration/ServiceConfig.java | 22 +++++ .../techgroups/template/model/Customer.java | 68 +++++++++++++++ .../repository/CustomerRepository.java | 10 +++ .../template/services/Application.java | 31 ------- .../template/services/CustomerController.java | 84 +++++++++++++++++++ .../src/main/resources/application.properties | 5 ++ 10 files changed, 300 insertions(+), 35 deletions(-) create mode 100644 template/src/main/java/com/simtlix/techgroups/template/Application.java create mode 100644 template/src/main/java/com/simtlix/techgroups/template/business/CustomerService.java create mode 100644 template/src/main/java/com/simtlix/techgroups/template/business/CustomerServiceImpl.java create mode 100644 template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java create mode 100644 template/src/main/java/com/simtlix/techgroups/template/model/Customer.java create mode 100644 template/src/main/java/com/simtlix/techgroups/template/repository/CustomerRepository.java delete mode 100644 template/src/main/java/com/simtlix/techgroups/template/services/Application.java create mode 100644 template/src/main/java/com/simtlix/techgroups/template/services/CustomerController.java create mode 100644 template/src/main/resources/application.properties diff --git a/template/pom.xml b/template/pom.xml index 89df074..3a58a66 100644 --- a/template/pom.xml +++ b/template/pom.xml @@ -1,6 +1,6 @@ + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework @@ -13,6 +13,12 @@ 1.5.9.RELEASE + + 1.9 + 5.2.11.Final + 5.8.1.Final + + org.springframework.boot @@ -31,11 +37,33 @@ test + + org.postgresql + postgresql + 9.4-1206-jdbc42 + + + org.springframework.boot + spring-boot-starter-data-jpa + + + javax.xml.bind + jaxb-api + 2.3.0 + + + + + + + + + + + - - 1.9 - + diff --git a/template/src/main/java/com/simtlix/techgroups/template/Application.java b/template/src/main/java/com/simtlix/techgroups/template/Application.java new file mode 100644 index 0000000..9ff9999 --- /dev/null +++ b/template/src/main/java/com/simtlix/techgroups/template/Application.java @@ -0,0 +1,13 @@ +package com.simtlix.techgroups.template; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class Application { + + public static void main(String[] args) { + SpringApplication.run(Application.class, args); + } + +} diff --git a/template/src/main/java/com/simtlix/techgroups/template/business/CustomerService.java b/template/src/main/java/com/simtlix/techgroups/template/business/CustomerService.java new file mode 100644 index 0000000..b4dc909 --- /dev/null +++ b/template/src/main/java/com/simtlix/techgroups/template/business/CustomerService.java @@ -0,0 +1,21 @@ +package com.simtlix.techgroups.template.business; + +import com.simtlix.techgroups.template.model.Customer; + +import java.util.List; + +/** + * Created by Facundo on 1/29/2018. + */ +public interface CustomerService { + + Customer addCustomer(Customer customer); + + List getCustomers(); + + Customer getCustomer(Long id); + + Customer updateCustomer(Customer customer); + + void deleteCustomer(Long id); +} diff --git a/template/src/main/java/com/simtlix/techgroups/template/business/CustomerServiceImpl.java b/template/src/main/java/com/simtlix/techgroups/template/business/CustomerServiceImpl.java new file mode 100644 index 0000000..1dcbe9c --- /dev/null +++ b/template/src/main/java/com/simtlix/techgroups/template/business/CustomerServiceImpl.java @@ -0,0 +1,45 @@ +package com.simtlix.techgroups.template.business; + +import com.simtlix.techgroups.template.model.Customer; +import com.simtlix.techgroups.template.repository.CustomerRepository; +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Facundo on 1/29/2018. + */ +public class CustomerServiceImpl implements CustomerService { + + private final CustomerRepository customerRepository; + + public CustomerServiceImpl(CustomerRepository customerRepository) { + this.customerRepository = customerRepository; + } + + @Override + public List getCustomers() { + List customers = new ArrayList<>(); + customerRepository.findAll().forEach(customers::add); + return customers; + } + + @Override + public Customer getCustomer(Long id) { + return customerRepository.findOne(id); + } + + @Override + public Customer addCustomer(Customer customer) { + return customerRepository.save(customer); + } + + @Override + public Customer updateCustomer(Customer customer) { + return customerRepository.save(customer); + } + + @Override + public void deleteCustomer(Long id) { + customerRepository.delete(id); + } +} diff --git a/template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java b/template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java new file mode 100644 index 0000000..cdc6877 --- /dev/null +++ b/template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java @@ -0,0 +1,22 @@ +package com.simtlix.techgroups.template.configuration; + +import com.simtlix.techgroups.template.business.CustomerService; +import com.simtlix.techgroups.template.business.CustomerServiceImpl; +import com.simtlix.techgroups.template.repository.CustomerRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * Created by Facundo on 1/29/2018. + */ +@Configuration +public class ServiceConfig { + + @Autowired + private CustomerRepository customerRepository; + + @Bean + public CustomerService customerService(){return new CustomerServiceImpl(customerRepository);} + +} diff --git a/template/src/main/java/com/simtlix/techgroups/template/model/Customer.java b/template/src/main/java/com/simtlix/techgroups/template/model/Customer.java new file mode 100644 index 0000000..590cc76 --- /dev/null +++ b/template/src/main/java/com/simtlix/techgroups/template/model/Customer.java @@ -0,0 +1,68 @@ +package com.simtlix.techgroups.template.model; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * Created by Facundo on 1/29/2018. + */ +@Entity +@Table(name = "customer") +public class Customer implements Serializable { + + + @GeneratedValue(strategy = GenerationType.AUTO) + @Column(name = "id", nullable = false) + @Id + private Long id; + + @Column(name = "name") + private String name; + + @Column(name = "last_name") + private String lastName; + + @Column(name = "email", unique = true, nullable = false) + private String email; + + public Customer() { + } + + public Customer(String name, String lastName, String email) { + this.name = name; + this.lastName = lastName; + this.email = email; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getLastName() { + return lastName; + } + + public void setLastName(String lastName) { + this.lastName = lastName; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/template/src/main/java/com/simtlix/techgroups/template/repository/CustomerRepository.java b/template/src/main/java/com/simtlix/techgroups/template/repository/CustomerRepository.java new file mode 100644 index 0000000..2affcdc --- /dev/null +++ b/template/src/main/java/com/simtlix/techgroups/template/repository/CustomerRepository.java @@ -0,0 +1,10 @@ +package com.simtlix.techgroups.template.repository; + +import com.simtlix.techgroups.template.model.Customer; +import org.springframework.data.repository.CrudRepository; +/** + * Created by Facundo on 1/29/2018. + */ + +public interface CustomerRepository extends CrudRepository { +} diff --git a/template/src/main/java/com/simtlix/techgroups/template/services/Application.java b/template/src/main/java/com/simtlix/techgroups/template/services/Application.java deleted file mode 100644 index 8e07e82..0000000 --- a/template/src/main/java/com/simtlix/techgroups/template/services/Application.java +++ /dev/null @@ -1,31 +0,0 @@ -package com.simtlix.techgroups.template.services; - -import java.util.Arrays; - -import org.springframework.boot.CommandLineRunner; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.ApplicationContext; -import org.springframework.context.annotation.Bean; - -@SpringBootApplication -public class Application { - - public static void main(String[] args) { - SpringApplication.run(Application.class, args); - } - - /*@Bean - public CommandLineRunner commandLineRunner(ApplicationContext ctx) { - return args -> { - - String[] beanNames = ctx.getBeanDefinitionNames(); - Arrays.sort(beanNames); - for (String beanName : beanNames) { - System.out.println(beanName); - } - - }; - }*/ - -} diff --git a/template/src/main/java/com/simtlix/techgroups/template/services/CustomerController.java b/template/src/main/java/com/simtlix/techgroups/template/services/CustomerController.java new file mode 100644 index 0000000..cf1a457 --- /dev/null +++ b/template/src/main/java/com/simtlix/techgroups/template/services/CustomerController.java @@ -0,0 +1,84 @@ +package com.simtlix.techgroups.template.services; + +import com.simtlix.techgroups.template.business.CustomerService; +import com.simtlix.techgroups.template.model.Customer; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.*; +import java.util.List; + +/** + * Created by Facundo on 1/29/2018. + */ +@RestController +@RequestMapping("/customers") +public class CustomerController { + + private CustomerService customerService; + + @Autowired + public CustomerController(CustomerService customerService){ + this.customerService = customerService; + } + + @RequestMapping(method = RequestMethod.GET, produces = "application/JSON") + public ResponseEntity> getCustomers() { + ResponseEntity> responseEntity; + List customers = customerService.getCustomers(); + if (customers == null || customers.isEmpty()) { + responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); + } else{ + responseEntity = new ResponseEntity<>(customers,HttpStatus.OK); + } + return responseEntity; + } + + @RequestMapping(method = RequestMethod.GET, path = "{id}", produces = "application/JSON") + public ResponseEntity getCustomerById(@PathVariable Long id) { + ResponseEntity responseEntity; + Customer customer = customerService.getCustomer(id); + if (customer == null) { + responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); + } else{ + responseEntity = new ResponseEntity<>(customer,HttpStatus.OK); + } + return responseEntity; + } + + @RequestMapping(method = RequestMethod.POST,produces = "application/JSON") + public ResponseEntity addCustomer(@RequestBody Customer customer) { + ResponseEntity responseEntity; + Customer customerStored = customerService.addCustomer(customer); + if (customerStored == null) { + responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); + } else{ + responseEntity = new ResponseEntity<>(customerStored,HttpStatus.CREATED); + } + return responseEntity; + } + + @RequestMapping(method = RequestMethod.PUT,produces = "application/JSON") + public ResponseEntity updateCustomer(@RequestBody Customer customer) { + ResponseEntity responseEntity; + Customer customerStored = customerService.updateCustomer(customer); + if (customerStored == null) { + responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); + } else{ + responseEntity = new ResponseEntity<>(customerStored,HttpStatus.OK); + } + return responseEntity; + } + + @RequestMapping(method = RequestMethod.DELETE, path = "{id}") + public ResponseEntity deleteCustomer(@PathVariable Long id) { + customerService.deleteCustomer(id); + return new ResponseEntity(HttpStatus.OK); + } + + + + + + +} diff --git a/template/src/main/resources/application.properties b/template/src/main/resources/application.properties new file mode 100644 index 0000000..1c9aad6 --- /dev/null +++ b/template/src/main/resources/application.properties @@ -0,0 +1,5 @@ +spring.datasource.url=jdbc:postgresql://localhost:5432/template +spring.datasource.driver-class-name=org.postgresql.Driver +spring.datasource.username=postgres +spring.datasource.password=Simtlix01 +spring.jpa.hibernate.ddl-auto=update From 66db2dc172d4ebe58f25515b194cbba9e18c4b5c Mon Sep 17 00:00:00 2001 From: Facundo Rossi Date: Tue, 20 Feb 2018 20:36:11 -0300 Subject: [PATCH 2/2] fix review issues --- .../template/configuration/ServiceConfig.java | 22 ------ .../controllers/CustomerController.java | 53 ++++++-------- .../repositories/CustomerRepository.java | 5 +- .../services/CustomerServiceImpl.java | 4 ++ .../src/main/resources/application.properties | 2 +- .../controllers/CostumerControllerTest.java | 70 +++++++++++++++++++ .../controllers/UserControllerTest.java | 6 +- 7 files changed, 102 insertions(+), 60 deletions(-) delete mode 100644 template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java create mode 100644 template/src/test/java/com/simtlix/techgroups/template/controllers/CostumerControllerTest.java diff --git a/template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java b/template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java deleted file mode 100644 index 3483319..0000000 --- a/template/src/main/java/com/simtlix/techgroups/template/configuration/ServiceConfig.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.simtlix.techgroups.template.configuration; - -import com.simtlix.techgroups.template.services.CustomerService; -import com.simtlix.techgroups.template.services.CustomerServiceImpl; -import com.simtlix.techgroups.template.repositories.CustomerRepository; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -/** - * Created by Facundo on 1/29/2018. - */ -@Configuration -public class ServiceConfig { - - @Autowired - private CustomerRepository customerRepository; - - @Bean - public CustomerService customerService(){return new CustomerServiceImpl(customerRepository);} - -} diff --git a/template/src/main/java/com/simtlix/techgroups/template/controllers/CustomerController.java b/template/src/main/java/com/simtlix/techgroups/template/controllers/CustomerController.java index 17da8b7..fd089b2 100644 --- a/template/src/main/java/com/simtlix/techgroups/template/controllers/CustomerController.java +++ b/template/src/main/java/com/simtlix/techgroups/template/controllers/CustomerController.java @@ -4,15 +4,20 @@ import com.simtlix.techgroups.template.services.CustomerService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; import java.util.List; /** * Created by Facundo on 1/29/2018. */ @RestController -@RequestMapping("/customers") +@RequestMapping("/api/customers") public class CustomerController { private CustomerService customerService; @@ -22,63 +27,49 @@ public CustomerController(CustomerService customerService){ this.customerService = customerService; } - @RequestMapping(method = RequestMethod.GET, produces = "application/JSON") + @RequestMapping(method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity> getCustomers() { - ResponseEntity> responseEntity; List customers = customerService.getCustomers(); - if (customers == null || customers.isEmpty()) { - responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); - } else{ - responseEntity = new ResponseEntity<>(customers,HttpStatus.OK); - } - return responseEntity; + return new ResponseEntity<>(customers,HttpStatus.OK); } - @RequestMapping(method = RequestMethod.GET, path = "{id}", produces = "application/JSON") + @RequestMapping(method = RequestMethod.GET, path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity getCustomerById(@PathVariable Long id) { ResponseEntity responseEntity; Customer customer = customerService.getCustomer(id); if (customer == null) { - responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); + responseEntity = new ResponseEntity<>(HttpStatus.NO_CONTENT); } else{ responseEntity = new ResponseEntity<>(customer,HttpStatus.OK); } return responseEntity; } - @RequestMapping(method = RequestMethod.POST,produces = "application/JSON") + @RequestMapping(method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity addCustomer(@RequestBody Customer customer) { - ResponseEntity responseEntity; - Customer customerStored = customerService.addCustomer(customer); - if (customerStored == null) { - responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); - } else{ - responseEntity = new ResponseEntity<>(customerStored,HttpStatus.CREATED); - } - return responseEntity; + Customer customerSaved = customerService.addCustomer(customer); + return new ResponseEntity<>(customerSaved,HttpStatus.CREATED); } - @RequestMapping(method = RequestMethod.PUT,produces = "application/JSON") - public ResponseEntity updateCustomer(@RequestBody Customer customer) { + @RequestMapping(method = RequestMethod.PUT, path = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, + consumes = MediaType.APPLICATION_JSON_VALUE) + public ResponseEntity updateCustomer(@RequestBody Customer customer,@PathVariable Long id) { ResponseEntity responseEntity; - Customer customerStored = customerService.updateCustomer(customer); + Customer customerStored = customerService.getCustomer(id); if (customerStored == null) { responseEntity = new ResponseEntity<>(HttpStatus.NOT_FOUND); } else{ - responseEntity = new ResponseEntity<>(customerStored,HttpStatus.OK); + customer.setId(id); + responseEntity = new ResponseEntity<>(customerService.updateCustomer(customer),HttpStatus.OK); } return responseEntity; } - @RequestMapping(method = RequestMethod.DELETE, path = "{id}") + @RequestMapping(method = RequestMethod.DELETE, path = "/{id}") public ResponseEntity deleteCustomer(@PathVariable Long id) { customerService.deleteCustomer(id); return new ResponseEntity(HttpStatus.OK); } - - - - - } diff --git a/template/src/main/java/com/simtlix/techgroups/template/repositories/CustomerRepository.java b/template/src/main/java/com/simtlix/techgroups/template/repositories/CustomerRepository.java index 49fac47..905e842 100644 --- a/template/src/main/java/com/simtlix/techgroups/template/repositories/CustomerRepository.java +++ b/template/src/main/java/com/simtlix/techgroups/template/repositories/CustomerRepository.java @@ -1,10 +1,11 @@ package com.simtlix.techgroups.template.repositories; import com.simtlix.techgroups.template.model.Customer; -import org.springframework.data.repository.CrudRepository; +import org.springframework.data.repository.PagingAndSortingRepository; + /** * Created by Facundo on 1/29/2018. */ -public interface CustomerRepository extends CrudRepository { +public interface CustomerRepository extends PagingAndSortingRepository { } diff --git a/template/src/main/java/com/simtlix/techgroups/template/services/CustomerServiceImpl.java b/template/src/main/java/com/simtlix/techgroups/template/services/CustomerServiceImpl.java index 220e9cb..a59cffe 100644 --- a/template/src/main/java/com/simtlix/techgroups/template/services/CustomerServiceImpl.java +++ b/template/src/main/java/com/simtlix/techgroups/template/services/CustomerServiceImpl.java @@ -2,6 +2,8 @@ import com.simtlix.techgroups.template.model.Customer; import com.simtlix.techgroups.template.repositories.CustomerRepository; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; @@ -9,10 +11,12 @@ /** * Created by Facundo on 1/29/2018. */ +@Service public class CustomerServiceImpl implements CustomerService { private final CustomerRepository customerRepository; + @Autowired public CustomerServiceImpl(CustomerRepository customerRepository) { this.customerRepository = customerRepository; } diff --git a/template/src/main/resources/application.properties b/template/src/main/resources/application.properties index bc79609..578c6a5 100644 --- a/template/src/main/resources/application.properties +++ b/template/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.datasource.url=jdbc:postgresql://localhost:5432/template +spring.datasource.url=jdbc:postgresql://db:5432/template spring.datasource.driver-class-name=org.postgresql.Driver spring.datasource.username=postgres spring.datasource.password=Simtlix01 diff --git a/template/src/test/java/com/simtlix/techgroups/template/controllers/CostumerControllerTest.java b/template/src/test/java/com/simtlix/techgroups/template/controllers/CostumerControllerTest.java new file mode 100644 index 0000000..6cc4db1 --- /dev/null +++ b/template/src/test/java/com/simtlix/techgroups/template/controllers/CostumerControllerTest.java @@ -0,0 +1,70 @@ +package com.simtlix.techgroups.template.controllers; + +import com.simtlix.techgroups.template.model.Customer; +import com.simtlix.techgroups.template.repositories.CustomerRepository; +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.embedded.LocalServerPort; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.web.client.TestRestTemplate; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.test.context.junit4.SpringRunner; + +import java.net.URL; + +import static org.junit.Assert.assertEquals; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.when; + +/** + * Created by Facundo on 2/20/2018. + */ +@RunWith(SpringRunner.class) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +public class CostumerControllerTest { + + @LocalServerPort + private int port; + + private URL base; + + @Autowired + private TestRestTemplate restTemplate; + + @MockBean + private CustomerRepository customerRepository; + + + @Before + public void setUp() throws Exception { + this.base = new URL("http://localhost:" + port + "/"); + Customer customer = new Customer(); + customer.setId(1l); + customer.setEmail("test"); + customer.setName("test"); + customer.setLastName("test"); + + when(customerRepository.save(any(Customer.class))).thenReturn(customer); + when(customerRepository.findOne(any())).thenReturn(customer); + + } + + @Test + public void testSaveOk() { + Customer customer = new Customer(); + customer.setEmail("test"); + customer.setName("test"); + customer.setLastName("test"); + ResponseEntity response = restTemplate.postForEntity(base.toString() + "api/customers", customer, Customer.class); + assertEquals(response.getStatusCode(), HttpStatus.OK); + } + @Test + public void testFindCustomer() { + ResponseEntity response = restTemplate.getForEntity(base.toString() + "api/customers/123123", Customer.class); + assertEquals(123L, response.getBody().getId().longValue()); + } +} diff --git a/template/src/test/java/com/simtlix/techgroups/template/controllers/UserControllerTest.java b/template/src/test/java/com/simtlix/techgroups/template/controllers/UserControllerTest.java index 1b7be36..89eba5a 100644 --- a/template/src/test/java/com/simtlix/techgroups/template/controllers/UserControllerTest.java +++ b/template/src/test/java/com/simtlix/techgroups/template/controllers/UserControllerTest.java @@ -7,18 +7,16 @@ import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.context.embedded.LocalServerPort; -import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; + import java.net.URL; -import java.util.List; -import static org.hamcrest.Matchers.equalTo; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; import static org.mockito.Matchers.any; import static org.mockito.Mockito.when;