Skip to content

Commit d1a794e

Browse files
committed
Updated readme
1 parent 03126b7 commit d1a794e

File tree

2 files changed

+78
-27
lines changed

2 files changed

+78
-27
lines changed

README.md

Lines changed: 69 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,55 @@ watching for any changes on our frontend files.
5050
This way we can be really productive since we don't have to worry about recompiling and deploying
5151
our server or client side code every time we make changes.
5252

53-
### Other ways of running the app
53+
54+
### Profiles
55+
56+
The project comes prepared for being used in three different environments plus
57+
another one for testing. We use Spring Profiles in combination with Boot feature for
58+
loading properties files by naming convention (application-*\<profile name\>*.properties).
59+
60+
You can find the profile constants in
61+
[StarterProfiles](src/main/java/com/dlizarra/starter/StarterProfiles.java)
62+
and the properties files in `src/main/resources`.
63+
64+
### Database
65+
The database connections are configured in
66+
[DatabaseConfig](src/main/java/com/dlizarra/starter/DatabaseConfig.java)
67+
where we can find a working H2 embedded database connection for the default profile and the staging and production configurations examples for working with an external database.
68+
69+
### Security
70+
All the boilerplate for the initial Spring Security configuration is already created. These are they key classes:
71+
72+
- [User](src/main/java/com/dlizarra/starter/user/User.java), [Role](src/main/java/com/dlizarra/starter/role/Role.java) and [RoleName](src/main/java/com/dlizarra/starter/role/RoleName.java) which are populated by [data.sql](src/main/resources/data.sql) file for the default profile only.
73+
- [CustomUserDetails](src/main/java/com/dlizarra/starter/support/security/CustomUserDetails.java)
74+
- [CustomUserDetailsService](src/main/java/com/dlizarra/starter/support/security/CustomUserDetailsService.java)
75+
- [SecurityConfig](src/main/java/com/dlizarra/starter/SecurityConfig.java) with just very basic security rules.
76+
77+
### DTO-Entity mapping
78+
The project includes Orika and it already has a class, [OrikaBeanMapper](src/main/java/com/dlizarra/starter/support/orika/OrikaBeanMapper.java), ready to be injected anywhere and be used to do any mapping. It will also scan the project on startup searching for custom mappers and components.
79+
80+
You can see how to use it in [UserServiceImpl](src/main/java/com/dlizarra/starter/user/UserServiceImpl.java) or in this sample [project](https://github.com/dlizarra/orika-spring-integration).
81+
82+
This, along with Lombok annotations for auto-generating getters, setters, toString methods and such, allows us to have much cleaner Entities and DTOs classes.
83+
84+
### Unit and integration testing
85+
For **unit testing** we included Spring Test, JUnit, Mockito and AssertJ as well as an [AbstractUnitTest](src/test/java/com/dlizarra/starter/support/AbstractUnitTest.java) class that we can extend to include the boilerplate annotations and configuration for every test. [UserServiceTest](src/test/java/com/dlizarra/starter/user/UserServiceTest.java) can serve as an example.
86+
87+
To create integration tests we can extend [AbstractIntegrationTest](src/test/java/com/dlizarra/starter/support/AbstractIntegrationTest.java) and make use of Spring `@sql` annotation to run a databse script before every test, just like it's done in [UserRepositoryTest](src/test/java/com/dlizarra/starter/user/UserRepositoryTest.java).
88+
89+
### Code coverage
90+
The project is also ready to use Cobertura as a code coverage utility and Coveralls to show a nice graphical representation of the results, get a badge with the results, etc.
91+
92+
The only thing you need to do is to create an account in [Coveralls.io](http://coveralls.io) and add your repo token key [here](pom.xml#L134) in the pom.xml.
93+
94+
And if you want to use different tools you just need to remove the plugins from the pom.
95+
96+
### Continuous integration and deployment
97+
A [travis.yml](.travis.yml) file is included with a minimal configuration just to use jdk 8, trigger the code analysis tool and deploy the app to Heroku using the `api_key` in the file.
98+
99+
We also included a Heroku [Procfile](Procfile) which declares the `web` process type and the java command to run our app and specifies which Spring Profile we want to use.
100+
101+
### Other ways to run the app
54102
#### Run everything from Maven
55103

56104
mvn generate-resources spring-boot:run
@@ -68,25 +116,27 @@ In a second terminal:
68116
cd src/main/frontend
69117
webpack
70118

71-
### Profiles
72-
73-
The project comes prepared for being used in three different environments plus
74-
another one for testing. We use Spring Profiles in combination with Boot feature for
75-
loading properties files by naming convention (application-*\<profile name\>*.properties).
76-
77-
You can find the profile constants in
78-
[StarterProfiles](spring-boot-react-webpack-starter/src/main/java/com/dlizarra/starter/StarterProfiles.java)
79-
and the properties files in `src/main/resources`.
80-
81-
### Database
82-
The database connections are configured in
83-
[DatabaseConfig](src/main/java/com/dlizarra/starter/DatabaseConfig.jav)
84-
where we can find a working H2 embedded database
85-
86119
## Tech stack and libraries
87120
### Backend
88-
- Spring
89-
90-
121+
- [Spring Boot](http://projects.spring.io/spring-boot/)
122+
- [Spring MVC](http://docs.spring.io/autorepo/docs/spring/3.2.x/spring-framework-reference/html/mvc.html)
123+
- [Spring Data](http://projects.spring.io/spring-data/)
124+
- [Spring Security](http://projects.spring.io/spring-security/)
125+
- [Spring Test](http://docs.spring.io/autorepo/docs/spring-framework/3.2.x/spring-framework-reference/html/testing.html)
126+
- [JUnit](http://junit.org/)
127+
- [Mockito](http://mockito.org/)
128+
- [AssertJ](http://joel-costigliola.github.io/assertj/)
129+
- [Lombok](https://projectlombok.org/)
130+
- [Orika](http://orika-mapper.github.io/orika-docs/)
131+
- [Maven](https://maven.apache.org/)
132+
133+
### Frontend
134+
- [Node](https://nodejs.org/en/)
135+
- [React](https://facebook.github.io/react/)
136+
- [Redux](https://reduxframework.com/)
137+
- [Webpack](https://webpack.github.io/)
138+
- [Axios](https://github.com/mzabriskie/axios)
139+
- [Babel](https://babeljs.io/)
140+
- [ES6](http://www.ecma-international.org/ecma-262/6.0/)
91141

92142
---

src/main/java/com/dlizarra/starter/user/UserServiceImpl.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import org.springframework.transaction.annotation.Transactional;
1111

1212
import com.dlizarra.starter.role.RoleName;
13+
import com.dlizarra.starter.role.Role;
1314
import com.dlizarra.starter.support.orika.OrikaBeanMapper;
1415

1516
@Service
@@ -24,14 +25,14 @@ public class UserServiceImpl implements UserService {
2425
@Transactional
2526
@Override
2627
public void createUser(final UserDto userDto, final RoleName roleName) {
27-
// final User user = mapper.map(userDto, User.class);
28-
// final Role role = new Role();
29-
// role.setRolename(roleName);
30-
// role.setUser(user);
31-
// user.getRoles().add(role);
32-
// user.setEnabled(true);
33-
//
34-
// userRepository.save(user);
28+
final User user = mapper.map(userDto, User.class);
29+
final Role role = new Role();
30+
role.setRolename(roleName);
31+
role.setUser(user);
32+
user.getRoles().add(role);
33+
user.setEnabled(true);
34+
35+
userRepository.save(user);
3536
}
3637

3738
@Transactional(readOnly = true)

0 commit comments

Comments
 (0)