Skip to content
This repository was archived by the owner on Oct 21, 2024. It is now read-only.

Commit 02ffdf6

Browse files
committed
hibernate: copied template
1 parent f1f2964 commit 02ffdf6

File tree

4 files changed

+281
-0
lines changed

4 files changed

+281
-0
lines changed

hibernate/app/pom.xml

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>es.msanchez.frameworks.java.hibernate</groupId>
4+
<artifactId>java-frameworks-hibernate</artifactId>
5+
<version>0.0.1-SNAPSHOT</version>
6+
7+
<properties>
8+
<!-- General -->
9+
<java.compiler.version>1.8</java.compiler.version>
10+
11+
<!-- maven plugins -->
12+
<maven.compiler.plugin.version>3.8.0</maven.compiler.plugin.version>
13+
<maven.shade.version>3.2.1</maven.shade.version>
14+
15+
<!-- Normal Dependency Versions -->
16+
<spring.version>5.1.6.RELEASE</spring.version>
17+
<spring-boot.version>2.0.0.RELEASE</spring-boot.version>
18+
19+
<lombok.version>1.18.6</lombok.version>
20+
<slf4j.version>1.7.25</slf4j.version>
21+
<logback.version>1.2.3</logback.version>
22+
<google.guava.version>27.1-jre</google.guava.version>
23+
<apache.commons.collections.version>4.3</apache.commons.collections.version>
24+
25+
<!-- Test Dependency Versions -->
26+
<junit.version>4.12</junit.version>
27+
<testng.version>6.14.3</testng.version>
28+
<mockito.version>2.26.0</mockito.version>
29+
<assertj.version>3.12.2</assertj.version>
30+
<codearte.catchexception.version>1.4.6</codearte.catchexception.version>
31+
32+
</properties>
33+
34+
<dependencies>
35+
36+
<!-- Spring Boot -->
37+
<dependency>
38+
<groupId>org.springframework.boot</groupId>
39+
<artifactId>spring-boot-starter</artifactId>
40+
<version>${spring-boot.version}</version>
41+
</dependency>
42+
43+
<dependency>
44+
<groupId>org.springframework.boot</groupId>
45+
<artifactId>spring-boot-starter-web</artifactId>
46+
<version>${spring-boot.version}</version>
47+
</dependency>
48+
49+
<!-- Spring -->
50+
<dependency>
51+
<groupId>org.springframework</groupId>
52+
<artifactId>spring-context</artifactId>
53+
<version>${spring.version}</version>
54+
</dependency>
55+
56+
<dependency>
57+
<groupId>org.springframework</groupId>
58+
<artifactId>spring-core</artifactId>
59+
<version>${spring.version}</version>
60+
</dependency>
61+
62+
<!-- Logging -->
63+
<dependency>
64+
<groupId>org.slf4j</groupId>
65+
<artifactId>slf4j-api</artifactId>
66+
<version>${slf4j.version}</version>
67+
</dependency>
68+
69+
<dependency>
70+
<groupId>ch.qos.logback</groupId>
71+
<artifactId>logback-classic</artifactId>
72+
<version>${logback.version}</version>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>ch.qos.logback</groupId>
77+
<artifactId>logback-core</artifactId>
78+
<version>${logback.version}</version>
79+
</dependency>
80+
81+
<!-- Other dependencies -->
82+
<dependency>
83+
<groupId>org.projectlombok</groupId>
84+
<artifactId>lombok</artifactId>
85+
<version>${lombok.version}</version>
86+
<scope>provided</scope>
87+
</dependency>
88+
89+
<dependency>
90+
<groupId>com.google.guava</groupId>
91+
<artifactId>guava</artifactId>
92+
<version>${google.guava.version}</version>
93+
</dependency>
94+
95+
<dependency>
96+
<groupId>org.apache.commons</groupId>
97+
<artifactId>commons-collections4</artifactId>
98+
<version>${apache.commons.collections.version}</version>
99+
</dependency>
100+
101+
<!-- Test Dependencies -->
102+
<dependency>
103+
<groupId>junit</groupId>
104+
<artifactId>junit</artifactId>
105+
<version>${junit.version}</version>
106+
<scope>test</scope>
107+
</dependency>
108+
109+
<dependency>
110+
<groupId>org.testng</groupId>
111+
<artifactId>testng</artifactId>
112+
<version>${testng.version}</version>
113+
<scope>test</scope>
114+
</dependency>
115+
116+
<dependency>
117+
<groupId>org.mockito</groupId>
118+
<artifactId>mockito-core</artifactId>
119+
<version>${mockito.version}</version>
120+
<scope>test</scope>
121+
</dependency>
122+
123+
<dependency>
124+
<groupId>org.assertj</groupId>
125+
<artifactId>assertj-core</artifactId>
126+
<version>${assertj.version}</version>
127+
<scope>test</scope>
128+
</dependency>
129+
130+
<dependency>
131+
<groupId>eu.codearte.catch-exception</groupId>
132+
<artifactId>catch-exception</artifactId>
133+
<version>${codearte.catchexception.version}</version>
134+
<scope>test</scope>
135+
</dependency>
136+
137+
<!-- Spring test -->
138+
<dependency>
139+
<groupId>org.springframework</groupId>
140+
<artifactId>spring-test</artifactId>
141+
<version>${spring.version}</version>
142+
<scope>test</scope>
143+
</dependency>
144+
145+
<dependency>
146+
<groupId>org.springframework.boot</groupId>
147+
<artifactId>spring-boot-starter-test</artifactId>
148+
<version>${spring-boot.version}</version>
149+
<scope>test</scope>
150+
</dependency>
151+
152+
</dependencies>
153+
154+
<build>
155+
<plugins>
156+
<!-- Solves Manifest not found trouble -->
157+
<plugin>
158+
<groupId>org.springframework.boot</groupId>
159+
<artifactId>spring-boot-maven-plugin</artifactId>
160+
<version>${spring-boot.version}</version>
161+
<executions>
162+
<execution>
163+
<goals>
164+
<goal>repackage</goal>
165+
</goals>
166+
</execution>
167+
</executions>
168+
</plugin>
169+
170+
<!-- Sets the compiler version -->
171+
<plugin>
172+
<groupId>org.apache.maven.plugins</groupId>
173+
<artifactId>maven-compiler-plugin</artifactId>
174+
<version>${maven.compiler.plugin.version}</version>
175+
<configuration>
176+
<source>${java.compiler.version}</source>
177+
<target>${java.compiler.version}</target>
178+
</configuration>
179+
</plugin>
180+
</plugins>
181+
</build>
182+
</project>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package es.msanchez.frameworks.java.spring.boot;
2+
3+
import java.util.Arrays;
4+
import java.util.List;
5+
6+
import org.springframework.boot.CommandLineRunner;
7+
import org.springframework.boot.SpringApplication;
8+
import org.springframework.boot.autoconfigure.SpringBootApplication;
9+
import org.springframework.context.ApplicationContext;
10+
import org.springframework.context.annotation.Bean;
11+
12+
import lombok.extern.slf4j.Slf4j;
13+
14+
@Slf4j
15+
@SpringBootApplication
16+
public class Application {
17+
18+
public static void main(final String[] args) {
19+
SpringApplication.run(Application.class, args);
20+
}
21+
22+
@Bean
23+
public CommandLineRunner commandLineRunner(final ApplicationContext context) {
24+
return args -> {
25+
log.info("Beans provided by Spring Boot:");
26+
final List<String> beanNames = Arrays.asList(context.getBeanDefinitionNames());
27+
beanNames.forEach(bean -> log.debug("Bean name '{}'", bean));
28+
};
29+
30+
}
31+
32+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package es.msanchez.frameworks.java.spring.boot.controller;
2+
3+
import org.springframework.web.bind.annotation.RequestMapping;
4+
import org.springframework.web.bind.annotation.RestController;
5+
6+
@RestController
7+
public class HelloController {
8+
9+
@RequestMapping("/")
10+
public String index() {
11+
return "Greetings from Spring Boot!";
12+
}
13+
14+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package es.msanchez.frameworks.java.spring.boot.controller;
2+
3+
import static org.assertj.core.api.Assertions.assertThat;
4+
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
import org.mockito.InjectMocks;
9+
import org.mockito.junit.MockitoJUnitRunner;
10+
import org.springframework.http.HttpStatus;
11+
import org.springframework.mock.web.MockHttpServletResponse;
12+
import org.springframework.test.web.servlet.MockMvc;
13+
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders;
14+
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
15+
16+
@RunWith(MockitoJUnitRunner.class)
17+
public class HelloControllerTest {
18+
19+
private MockMvc mvcMock;
20+
21+
@InjectMocks
22+
private HelloController controller;
23+
24+
@Before
25+
public void setUp() {
26+
this.mvcMock = MockMvcBuilders.standaloneSetup(this.controller).build();
27+
}
28+
29+
@Test
30+
public void givenMockMvcWhenGetThenHttpStatusOk() throws Exception {
31+
// Given
32+
33+
// When
34+
final MockHttpServletResponse response = this.mvcMock.perform(
35+
MockMvcRequestBuilders.get("/")).andReturn().getResponse();
36+
37+
// Then
38+
assertThat(response.getStatus()).isEqualTo(HttpStatus.OK.value());
39+
}
40+
41+
@Test
42+
public void givenMockMvcWhenGetThenExpectedStringResponse() throws Exception {
43+
// Given
44+
45+
// When
46+
final MockHttpServletResponse response = this.mvcMock.perform(
47+
MockMvcRequestBuilders.get("/")).andReturn().getResponse();
48+
49+
// Then
50+
assertThat(response.getContentAsString()).isEqualTo("Greetings from Spring Boot!");
51+
}
52+
53+
}

0 commit comments

Comments
 (0)