Skip to content

Commit c84fc75

Browse files
committed
Polishing.
Add unit tests. See #2234
1 parent d21f243 commit c84fc75

File tree

4 files changed

+91
-8
lines changed

4 files changed

+91
-8
lines changed

src/main/kotlin/org/springframework/data/redis/core/PartialUpdateExtensions.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@
1616
package org.springframework.data.redis.core
1717

1818
/**
19-
* Inline fun variant with reified generics for [PartialUpdate]
19+
* Inline fun variant with reified generics for [PartialUpdate].
2020
*
2121
* @author Mikhael Sokolov
22-
* @since 2.7
22+
* @since 2.6.1
2323
*/
2424
@Suppress("FunctionName")
2525
inline fun <reified T : Any> PartialUpdate(id: Any): PartialUpdate<T> =
26-
PartialUpdate.newPartialUpdate(id, T::class.java)
26+
PartialUpdate.newPartialUpdate(id, T::class.java)

src/main/kotlin/org/springframework/data/redis/core/script/RedisScriptExtensions.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,21 @@ import org.springframework.core.io.Resource
1919

2020

2121
/**
22-
* Inline fun variant with reified generics for [RedisScript]
22+
* Inline fun variant with reified generics for [RedisScript].
2323
*
2424
* @author Mikhael Sokolov
25-
* @since 2.7
25+
* @since 2.6.1
2626
*/
2727
@Suppress("FunctionName")
2828
inline fun <reified T : Any> RedisScript(script: String): RedisScript<T> =
2929
RedisScript.of(script, T::class.java)
3030

3131
/**
32-
* Inline fun variant with reified generics for [RedisScript]
32+
* Inline fun variant with reified generics for [RedisScript].
3333
*
3434
* @author Mikhael Sokolov
35-
* @since 2.7
35+
* @since 2.6.1
3636
*/
3737
@Suppress("FunctionName")
3838
inline fun <reified T : Any> RedisScript(script: Resource): RedisScript<T> =
39-
RedisScript.of(script, T::class.java)
39+
RedisScript.of(script, T::class.java)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.redis.core
17+
18+
import org.assertj.core.api.Assertions.assertThat
19+
import org.junit.jupiter.api.Test
20+
21+
/**
22+
* Unit tests for `PartialUpdateExtensions`.
23+
*
24+
* @author Mark Paluch
25+
*/
26+
class PartialUpdateExtensionsUnitTests {
27+
28+
@Test // GH-2234
29+
fun shouldCreatePartialUpdate() {
30+
31+
val update = PartialUpdate<String>("foo")
32+
33+
assertThat(update.target).isEqualTo(String::class.java)
34+
}
35+
36+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright 2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package org.springframework.data.redis.core.script
17+
18+
import org.assertj.core.api.Assertions.assertThat
19+
import org.junit.jupiter.api.Test
20+
import org.springframework.core.io.ByteArrayResource
21+
22+
/**
23+
* Unit tests for `PartialUpdateExtensions`.
24+
*
25+
* @author Mark Paluch
26+
*/
27+
class RedisScriptExtensionsUnitTests {
28+
29+
@Test // GH-2234
30+
fun shouldCreateRedisScriptFromString() {
31+
32+
val update = RedisScript<String>("foo")
33+
34+
assertThat(update.resultType).isEqualTo(String::class.java)
35+
assertThat(update.scriptAsString).isEqualTo("foo")
36+
}
37+
38+
@Test // GH-2234
39+
fun shouldCreateRedisScriptFromResource() {
40+
41+
val update = RedisScript<String>(ByteArrayResource("foo".toByteArray()))
42+
43+
assertThat(update.resultType).isEqualTo(String::class.java)
44+
assertThat(update.scriptAsString).isEqualTo("foo")
45+
}
46+
47+
}

0 commit comments

Comments
 (0)