|
25 | 25 |
|
26 | 26 | import org.junit.jupiter.api.BeforeEach;
|
27 | 27 | import org.junit.jupiter.api.Test;
|
28 |
| - |
29 | 28 | import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
|
30 | 29 | import org.springframework.data.projection.ProjectionFactory;
|
31 | 30 | import org.springframework.data.relational.core.sql.LockMode;
|
@@ -123,28 +122,31 @@ public void returnsNullIfNoQueryIsFound() throws NoSuchMethodException {
|
123 | 122 | }
|
124 | 123 |
|
125 | 124 | @Test // GH-1041
|
126 |
| - void returnsQueryMethodWithLock() throws NoSuchMethodException { |
| 125 | + void returnsQueryMethodWithCorrectLockTypeWriteLock() throws NoSuchMethodException { |
127 | 126 |
|
128 | 127 | JdbcQueryMethod queryMethodWithWriteLock = createJdbcQueryMethod("queryMethodWithWriteLock");
|
129 |
| - JdbcQueryMethod queryMethodWithReadLock = createJdbcQueryMethod("queryMethodWithReadLock"); |
130 | 128 |
|
131 |
| - assertThat(queryMethodWithWriteLock.hasLockMode()).isTrue(); |
132 |
| - assertThat(queryMethodWithReadLock.hasLockMode()).isTrue(); |
| 129 | + assertThat(queryMethodWithWriteLock.lookupLockAnnotation()).isPresent(); |
| 130 | + assertThat(queryMethodWithWriteLock.lookupLockAnnotation().get().value()).isEqualTo(LockMode.PESSIMISTIC_WRITE); |
133 | 131 | }
|
134 | 132 |
|
135 | 133 | @Test // GH-1041
|
136 |
| - void returnsQueryMethodWithCorrectLockType() throws NoSuchMethodException { |
| 134 | + void returnsQueryMethodWithCorrectLockTypeReadLock() throws NoSuchMethodException { |
137 | 135 |
|
138 |
| - JdbcQueryMethod queryMethodWithWriteLock = createJdbcQueryMethod("queryMethodWithWriteLock"); |
139 | 136 | JdbcQueryMethod queryMethodWithReadLock = createJdbcQueryMethod("queryMethodWithReadLock");
|
140 | 137 |
|
141 |
| - assertThat(queryMethodWithWriteLock.lookupLockAnnotation()).isPresent(); |
142 | 138 | assertThat(queryMethodWithReadLock.lookupLockAnnotation()).isPresent();
|
143 |
| - |
144 |
| - assertThat(queryMethodWithWriteLock.lookupLockAnnotation().get().value()).isEqualTo(LockMode.PESSIMISTIC_WRITE); |
145 | 139 | assertThat(queryMethodWithReadLock.lookupLockAnnotation().get().value()).isEqualTo(LockMode.PESSIMISTIC_READ);
|
146 | 140 | }
|
147 | 141 |
|
| 142 | + @Test // GH-1041 |
| 143 | + void returnsQueryMethodWithCorrectLockTypeNoLock() throws NoSuchMethodException { |
| 144 | + |
| 145 | + JdbcQueryMethod queryMethodWithWriteLock = createJdbcQueryMethod("queryMethodName"); |
| 146 | + |
| 147 | + assertThat(queryMethodWithWriteLock.lookupLockAnnotation()).isEmpty(); |
| 148 | + } |
| 149 | + |
148 | 150 | @Lock(LockMode.PESSIMISTIC_WRITE)
|
149 | 151 | @Query
|
150 | 152 | private void queryMethodWithWriteLock() {}
|
|
0 commit comments