File tree 3 files changed +16
-6
lines changed
main/java/ru/mystamps/web
test/java/ru/mystamps/web/feature/category
3 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 20
20
21
21
import org .springframework .context .annotation .Configuration ;
22
22
import org .springframework .context .annotation .Import ;
23
+ import ru .mystamps .web .feature .category .CategoryConfig ;
23
24
import ru .mystamps .web .feature .country .CountryConfig ;
24
25
25
26
@ Configuration
26
27
@ Import ({
28
+ CategoryConfig .Daos .class ,
27
29
CountryConfig .Daos .class
28
30
})
29
31
public class DaoConfig {
Original file line number Diff line number Diff line change 26
26
/**
27
27
* Spring configuration that is required for using categories in an application.
28
28
*
29
- * The beans are grouped into two classes to make possible to register a controller
30
- * and the services in the separated application contexts.
29
+ * The beans are grouped into different classes to make possible to register a controller
30
+ * and the services in the separate application contexts. DAOs have been extracted to use
31
+ * them independently from services in the tests.
31
32
*/
32
33
@ Configuration
33
34
public class CategoryConfig {
@@ -52,16 +53,23 @@ public SuggestionController suggestionCategoryController() {
52
53
@ RequiredArgsConstructor
53
54
public static class Services {
54
55
55
- private final NamedParameterJdbcTemplate jdbcTemplate ;
56
+ private final CategoryDao categoryDao ;
56
57
57
58
@ Bean
58
- public CategoryService categoryService (CategoryDao categoryDao ) {
59
+ public CategoryService categoryService () {
59
60
return new CategoryServiceImpl (
60
61
LoggerFactory .getLogger (CategoryServiceImpl .class ),
61
62
categoryDao
62
63
);
63
64
}
64
65
66
+ }
67
+
68
+ @ RequiredArgsConstructor
69
+ public static class Daos {
70
+
71
+ private final NamedParameterJdbcTemplate jdbcTemplate ;
72
+
65
73
@ Bean
66
74
public CategoryDao categoryDao () {
67
75
return new JdbcCategoryDao (jdbcTemplate );
Original file line number Diff line number Diff line change 27
27
import org .springframework .test .context .TestPropertySource ;
28
28
import org .springframework .test .context .jdbc .Sql ;
29
29
import org .springframework .test .context .junit4 .SpringRunner ;
30
+ import ru .mystamps .web .config .DaoConfig ;
30
31
import ru .mystamps .web .tests .Random ;
31
32
32
33
import java .util .Map ;
33
34
34
35
@ JdbcTest
35
- // @todo #1143 Introduce a dedicated config for DAO classes
36
- @ ContextConfiguration (classes = CategoryConfig .Services .class )
36
+ @ ContextConfiguration (classes = DaoConfig .class )
37
37
@ TestPropertySource (
38
38
properties = {
39
39
// don't load test data, start with an empty database
You can’t perform that action at this time.
0 commit comments