minor cleanup

This commit is contained in:
eugenp 2017-05-18 10:22:09 +03:00
parent 6d4682fa36
commit 54d136518e
5 changed files with 62 additions and 76 deletions

View File

@ -1,64 +1,61 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion>
<modelVersion>4.0.0</modelVersion> <groupId>spring-boot-app</groupId>
<groupId>spring-boot-app</groupId> <artifactId>spring-boot-app</artifactId>
<artifactId>spring-boot-app</artifactId> <version>0.0.1-SNAPSHOT</version>
<version>0.0.1-SNAPSHOT</version> <packaging>war</packaging>
<packaging>war</packaging>
<parent> <parent>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId> <artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version> <version>1.5.3.RELEASE</version>
<relativePath /> </parent>
</parent>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId> <artifactId>spring-boot-starter-web</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId> <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.h2database</groupId> <groupId>com.h2database</groupId>
<artifactId>h2</artifactId> <artifactId>h2</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId> <artifactId>spring-boot-starter-actuator</artifactId>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
<sourceDirectory>src</sourceDirectory> <plugins>
<plugins> <plugin>
<plugin> <artifactId>maven-compiler-plugin</artifactId>
<artifactId>maven-compiler-plugin</artifactId> <version>3.6.1</version>
<version>3.5.1</version> <configuration>
<configuration> <source>1.8</source>
<source>1.8</source> <target>1.8</target>
<target>1.8</target> </configuration>
</configuration> </plugin>
</plugin> <plugin>
<plugin> <artifactId>maven-war-plugin</artifactId>
<artifactId>maven-war-plugin</artifactId> <version>3.1.0</version>
<version>3.0.0</version> <configuration>
<configuration> <warSourceDirectory>WebContent</warSourceDirectory>
<warSourceDirectory>WebContent</warSourceDirectory> </configuration>
</configuration> </plugin>
</plugin> </plugins>
</plugins> </build>
</build>
<properties> <properties>
<tomcat.version>8.0.43</tomcat.version> <tomcat.version>8.0.43</tomcat.version>
</properties> </properties>
</project> </project>

View File

@ -5,7 +5,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication @SpringBootApplication
public class Application { public class Application {
public static void main(String[] args){ public static void main(String[] args) {
SpringApplication.run(Application.class, args); SpringApplication.run(Application.class, args);
} }
} }

View File

@ -14,10 +14,7 @@ public class PersistenceConfig {
@Bean @Bean
public DataSource dataSource() { public DataSource dataSource() {
EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder(); EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();
EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2) EmbeddedDatabase db = builder.setType(EmbeddedDatabaseType.H2).addScript("mySchema.sql").addScript("myData.sql").build();
.addScript("mySchema.sql")
.addScript("myData.sql")
.build();
return db; return db;
} }

View File

@ -16,8 +16,8 @@ import com.stackify.repository.EmployeeRepository;
public class EmployeeController { public class EmployeeController {
private EmployeeRepository employeeRepository; private EmployeeRepository employeeRepository;
public EmployeeController(EmployeeRepository employeeRepository){ public EmployeeController(EmployeeRepository employeeRepository) {
this.employeeRepository = employeeRepository; this.employeeRepository = employeeRepository;
} }

View File

@ -32,23 +32,15 @@ public class EmployeeControllerTest {
@Before @Before
public void setup() throws Exception { public void setup() throws Exception {
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext) this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext).build();
.build();
} }
@Test @Test
public void whenCreateGetEmployee_thenOk() throws Exception { public void whenCreateGetEmployee_thenOk() throws Exception {
String employeeJson = "{\"name\":\"john\"}"; String employeeJson = "{\"name\":\"john\"}";
this.mockMvc.perform(post("/employees").contentType(CONTENT_TYPE) this.mockMvc.perform(post("/employees").contentType(CONTENT_TYPE).content(employeeJson)).andExpect(status().isCreated());
.content(employeeJson))
.andExpect(status().isCreated());
this.mockMvc.perform(get("/employees")) this.mockMvc.perform(get("/employees")).andExpect(status().isOk()).andExpect(content().contentType(CONTENT_TYPE)).andExpect(jsonPath("$", hasSize(2))).andExpect(jsonPath("$[0].name", is("ana"))).andExpect(jsonPath("$[1].name", is("john")));
.andExpect(status().isOk())
.andExpect(content().contentType(CONTENT_TYPE))
.andExpect(jsonPath("$", hasSize(2)))
.andExpect(jsonPath("$[0].name", is("ana")))
.andExpect(jsonPath("$[1].name", is("john")));
} }
} }