• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

future-architect / uroborosql / #743

28 Jun 2024 04:17PM UTC coverage: 90.988% (+0.5%) from 90.484%
#743

push

web-flow
add paramIfNotEmpty method (#318)

* v0.x to master merge

* fix nanoseconds diff (java8 to java11)

* eclipse cleanup and  optimize import

* eclipse format

* optimize Imports

* remove unused annotation

* library version up

* migrate v0.x to master
- update java version 8 to 11
- update junit4 to junit5
- library version update

* fix test failed

* remove unused annotation

* fixed bug

* use var

* fix java8 coding style

* Refactoring TransactionContextManager

* Refactoring SqlAgent

* 途中コミット

* fix testcase

* fix review

* fix javadoc comments

* merge v0.x PR

* cleanup code

* cleanup test code

* change build status badge

* - agent.query, update, proc, batch にそれぞれSupplierを引数にとるメソッドを追加
- SqlQuery.paramとSqlEntityUpdate.setにFunctionを受け取るメソッドを追加

* testcaseの整形

* - SqlFluent と ExtractionCondition の分離
- Arrays.asList -> List.of への変更
- テストの整形

* - v0.x系の不具合対応の追いつき
- ログ出力の整理

* - SqlKindの整理(ENTITY_XXXの追加)
- REPL_LOGの追加
- Deprecatedメソッドの削除(SqlAgent)
- SqlAgent, ExecutionContextでsetterをfluent APIに変更

* DB接続URLの修正

* add and fix testcases.

* add event testcases.

* fix typo

* add paramIfNotEmpty method and StringUtils rename ObjectUtils

* fix review comments.

* remove unused import

1695 of 1958 new or added lines in 97 files covered. (86.57%)

26 existing lines in 10 files now uncovered.

8249 of 9066 relevant lines covered (90.99%)

0.91 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

82.76
/src/main/java/jp/co/future/uroborosql/event/subscriber/DebugEventSubscriber.java
1
/**
2
 * Copyright (c) 2017-present, Future Corporation
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
package jp.co.future.uroborosql.event.subscriber;
8

9
import java.sql.SQLException;
10

11
import org.slf4j.Logger;
12
import org.slf4j.LoggerFactory;
13

14
import jp.co.future.uroborosql.event.AfterBeginTransactionEvent;
15
import jp.co.future.uroborosql.event.AfterGetOutParameterEvent;
16
import jp.co.future.uroborosql.event.BeforeEndTransactionEvent;
17
import jp.co.future.uroborosql.event.BeforeSetParameterEvent;
18
import jp.co.future.uroborosql.event.SqlBatchEvent;
19
import jp.co.future.uroborosql.event.SqlQueryEvent;
20
import jp.co.future.uroborosql.event.SqlUpdateEvent;
21

22
/**
23
 * デバッグログを出力するEventSubscriber
24
 *
25
 * @author H.Sugimoto
26
 * @since v1.0.0
27
 */
28
public class DebugEventSubscriber extends EventSubscriber {
1✔
29
        /** ロガー */
30
        private static final Logger EVENT_LOG = LoggerFactory.getLogger("jp.co.future.uroborosql.event");
1✔
31

32
        @Override
33
        public void initialize() {
34
                afterBeginTransactionListener(this::afterBeginTransaction);
1✔
35
                beforeEndTransactionListener(this::beforeEndTransaction);
1✔
36
                beforeSetParameterListener(this::beforeSetParameter);
1✔
37
                afterGetOutParameterListener(this::afterGetOutParameter);
1✔
38
                sqlQueryListener(this::sqlQuery);
1✔
39
                sqlUpdateListener(this::sqlUpdate);
1✔
40
                sqlBatchListener(this::sqlBatch);
1✔
41
        }
1✔
42

43
        void afterBeginTransaction(final AfterBeginTransactionEvent evt) {
44
                if (EVENT_LOG.isDebugEnabled()) {
1✔
45
                        try {
46
                                EVENT_LOG.debug("Begin Transaction - connection:{}, requiredNew:{}, transactionLevel:{}, occurredOn:{}",
1✔
47
                                                evt.getTransactionContext().getConnection(),
1✔
48
                                                evt.isRequiredNew(),
1✔
49
                                                evt.getTransactionLevel(),
1✔
50
                                                evt.occurredOn());
1✔
NEW
51
                        } catch (SQLException ex) {
×
NEW
52
                                EVENT_LOG.error(ex.getMessage(), ex);
×
53
                        }
1✔
54
                }
55
        }
1✔
56

57
        void beforeEndTransaction(final BeforeEndTransactionEvent evt) {
58
                if (EVENT_LOG.isDebugEnabled()) {
1✔
59
                        try {
60
                                EVENT_LOG.debug(
1✔
61
                                                "End Transaction - connection:{}, requiredNew:{}, transactionLevel:{}, result:{}, occurredOn:{}",
62
                                                evt.getTransactionContext().getConnection(),
1✔
63
                                                evt.isRequiredNew(),
1✔
64
                                                evt.getTransactionLevel(),
1✔
65
                                                evt.getResult(),
1✔
66
                                                evt.occurredOn());
1✔
NEW
67
                        } catch (SQLException ex) {
×
NEW
68
                                EVENT_LOG.error(ex.getMessage(), ex);
×
69
                        }
1✔
70
                }
71
        }
1✔
72

73
        void beforeSetParameter(final BeforeSetParameterEvent evt) {
74
                if (EVENT_LOG.isDebugEnabled()) {
1✔
75
                        EVENT_LOG.debug("Before Set Parameter - Parameter:{}", evt.getParameter());
1✔
76
                }
77
        }
1✔
78

79
        void afterGetOutParameter(final AfterGetOutParameterEvent evt) {
NEW
80
                if (EVENT_LOG.isDebugEnabled()) {
×
NEW
81
                        EVENT_LOG.debug("After Get OutParameter - key:{}, value:{}. parameterIndex:{}",
×
NEW
82
                                        evt.getKey(), evt.getValue(), evt.getParameterIndex());
×
83
                }
NEW
84
        }
×
85

86
        void sqlQuery(final SqlQueryEvent evt) {
87
                if (EVENT_LOG.isDebugEnabled()) {
1✔
88
                        EVENT_LOG.debug("Execute Query - sqlName:{} executed.", evt.getExecutionContext().getSqlName());
1✔
89
                        EVENT_LOG.trace("Execute Query sql:{}", evt.getPreparedStatement());
1✔
90
                }
91
        }
1✔
92

93
        void sqlUpdate(final SqlUpdateEvent evt) {
94
                if (EVENT_LOG.isDebugEnabled()) {
1✔
95
                        EVENT_LOG.debug("Execute Update - sqlName:{} executed. Count:{} items.",
1✔
96
                                        evt.getExecutionContext().getSqlName(), evt.getCount());
1✔
97
                }
98
        }
1✔
99

100
        void sqlBatch(final SqlBatchEvent evt) {
101
                if (EVENT_LOG.isDebugEnabled()) {
1✔
102
                        var counts = evt.getCounts();
1✔
103
                        try {
104
                                counts = new int[] { evt.getPreparedStatement().getUpdateCount() };
1✔
NEW
105
                        } catch (SQLException ex) {
×
NEW
106
                                EVENT_LOG.error(ex.getMessage(), ex);
×
107
                        }
1✔
108

109
                        var builder = new StringBuilder();
1✔
110
                        for (int val : counts) {
1✔
111
                                builder.append(val).append(", ");
1✔
112
                        }
113
                        EVENT_LOG.debug("Execute Update - sqlName:{} executed. Results:{}",
1✔
114
                                        evt.getExecutionContext().getSqlName(), counts);
1✔
115
                }
116
        }
1✔
117
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc