Skip to content

Commit

Permalink
Polishing.
Browse files Browse the repository at this point in the history
Add since tags to extension methods and issue references to tests.
Update antora playbook to consider maintenance branches.

Original Pull Request: #4753
  • Loading branch information
christophstrobl committed Sep 12, 2024
1 parent df08576 commit 78fbea4
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2024 the original author or authors.
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,6 +23,7 @@ import kotlin.reflect.KProperty
* Static factory method to create an Update using the provided key
*
* @author Pawel Matysek
* @since 4.4
* @see Update.update
*/
fun <T> update(key: KProperty<T>, value: T?) =
Expand All @@ -32,6 +33,7 @@ fun <T> update(key: KProperty<T>, value: T?) =
* Update using the {@literal $set} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.set
*/
fun <T> Update.set(key: KProperty<T>, value: T?) =
Expand All @@ -41,6 +43,7 @@ fun <T> Update.set(key: KProperty<T>, value: T?) =
* Update using the {@literal $setOnInsert} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.setOnInsert
*/
fun <T> Update.setOnInsert(key: KProperty<T>, value: T?) =
Expand All @@ -50,6 +53,7 @@ fun <T> Update.setOnInsert(key: KProperty<T>, value: T?) =
* Update using the {@literal $unset} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.unset
*/
fun <T> Update.unset(key: KProperty<T>) =
Expand All @@ -59,6 +63,7 @@ fun <T> Update.unset(key: KProperty<T>) =
* Update using the {@literal $inc} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.inc
*/
fun <T> Update.inc(key: KProperty<T>, inc: Number) =
Expand All @@ -71,6 +76,7 @@ fun <T> Update.inc(key: KProperty<T>) =
* Update using the {@literal $push} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.push
*/
fun <T> Update.push(key: KProperty<Collection<T>>, value: T?) =
Expand All @@ -79,9 +85,10 @@ fun <T> Update.push(key: KProperty<Collection<T>>, value: T?) =
/**
* Update using {@code $push} modifier. <br/>
* Allows creation of {@code $push} command for single or multiple (using {@code $each}) values as well as using
*
* {@code $position}.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.push
*/
fun <T> Update.push(key: KProperty<T>) =
Expand All @@ -92,6 +99,7 @@ fun <T> Update.push(key: KProperty<T>) =
* Allows creation of {@code $push} command for single or multiple (using {@code $each}) values * {@code $position}.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.addToSet
*/
fun <T> Update.addToSet(key: KProperty<T>) =
Expand All @@ -101,6 +109,7 @@ fun <T> Update.addToSet(key: KProperty<T>) =
* Update using the {@literal $addToSet} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.addToSet
*/
fun <T> Update.addToSet(key: KProperty<Collection<T>>, value: T?) =
Expand All @@ -110,6 +119,7 @@ fun <T> Update.addToSet(key: KProperty<Collection<T>>, value: T?) =
* Update using the {@literal $pop} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.pop
*/
fun <T> Update.pop(key: KProperty<T>, pos: Position) =
Expand All @@ -119,6 +129,7 @@ fun <T> Update.pop(key: KProperty<T>, pos: Position) =
* Update using the {@literal $pull} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.pull
*/
fun <T> Update.pull(key: KProperty<T>, value: Any) =
Expand All @@ -128,6 +139,7 @@ fun <T> Update.pull(key: KProperty<T>, value: Any) =
* Update using the {@literal $pullAll} update modifier
*
* @author Pawel Matysek
* @since 4.4
* @see Update.pullAll
*/
fun <T> Update.pullAll(key: KProperty<Collection<T>>, values: Array<T>) =
Expand All @@ -137,6 +149,7 @@ fun <T> Update.pullAll(key: KProperty<Collection<T>>, values: Array<T>) =
* Update given key to current date using {@literal $currentDate} modifier.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.currentDate
*/
fun <T> Update.currentDate(key: KProperty<T>) =
Expand All @@ -146,6 +159,7 @@ fun <T> Update.currentDate(key: KProperty<T>) =
* Update given key to current date using {@literal $currentDate : &#123; $type : "timestamp" &#125;} modifier.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.currentTimestamp
*/
fun <T> Update.currentTimestamp(key: KProperty<T>) =
Expand All @@ -155,6 +169,7 @@ fun <T> Update.currentTimestamp(key: KProperty<T>) =
* Multiply the value of given key by the given number.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.multiply
*/
fun <T> Update.multiply(key: KProperty<T>, multiplier: Number) =
Expand All @@ -164,6 +179,7 @@ fun <T> Update.multiply(key: KProperty<T>, multiplier: Number) =
* Update given key to the {@code value} if the {@code value} is greater than the current value of the field.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.max
*/
fun <T : Any> Update.max(key: KProperty<T>, value: T) =
Expand All @@ -173,6 +189,7 @@ fun <T : Any> Update.max(key: KProperty<T>, value: T) =
* Update given key to the {@code value} if the {@code value} is less than the current value of the field.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.min
*/
fun <T : Any> Update.min(key: KProperty<T>, value: T) =
Expand All @@ -182,6 +199,7 @@ fun <T : Any> Update.min(key: KProperty<T>, value: T) =
* The operator supports bitwise {@code and}, bitwise {@code or}, and bitwise {@code xor} operations.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.bitwise
*/
fun <T> Update.bitwise(key: KProperty<T>) =
Expand All @@ -192,6 +210,7 @@ fun <T> Update.bitwise(key: KProperty<T>) =
* driver without further type or field mapping.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.filterArray
*/
fun <T> Update.filterArray(identifier: KProperty<T>, expression: Any) =
Expand All @@ -201,6 +220,7 @@ fun <T> Update.filterArray(identifier: KProperty<T>, expression: Any) =
* Determine if a given {@code key} will be touched on execution.
*
* @author Pawel Matysek
* @since 4.4
* @see Update.modifies
*/
fun <T> Update.modifies(key: KProperty<T>) =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2018-2024 the original author or authors.
* Copyright 2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,7 +27,7 @@ import java.time.Instant
*/
class TypedUpdateExtensionsTests {

@Test
@Test // GH-3028
fun `update() should equal expected Update`() {

val typed = update(Book::title, "Moby-Dick")
Expand All @@ -36,7 +36,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `set() should equal expected Update`() {

val typed = Update().set(Book::title, "Moby-Dick")
Expand All @@ -45,7 +45,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `setOnInsert() should equal expected Update`() {

val typed = Update().setOnInsert(Book::title, "Moby-Dick")
Expand All @@ -54,7 +54,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `unset() should equal expected Update`() {

val typed = Update().unset(Book::title)
Expand All @@ -63,7 +63,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `inc(key, inc) should equal expected Update`() {

val typed = Update().inc(Book::price, 5)
Expand All @@ -72,7 +72,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `inc(key) should equal expected Update`() {

val typed = Update().inc(Book::price)
Expand All @@ -81,7 +81,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `push(key, value) should equal expected Update`() {

val typed = Update().push(Book::categories, "someCategory")
Expand All @@ -90,7 +90,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `push(key) should equal expected Update`() {

val typed = Update().push(Book::categories)
Expand All @@ -99,7 +99,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `addToSet(key) should equal expected Update`() {

val typed = Update().addToSet(Book::categories).each("category", "category2")
Expand All @@ -108,7 +108,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `addToSet(key, value) should equal expected Update`() {

val typed = Update().addToSet(Book::categories, "someCategory")
Expand All @@ -117,7 +117,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `pop() should equal expected Update`() {

val typed = Update().pop(Book::categories, Update.Position.FIRST)
Expand All @@ -126,7 +126,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `pull() should equal expected Update`() {

val typed = Update().pull(Book::categories, "someCategory")
Expand All @@ -135,7 +135,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `pullAll() should equal expected Update`() {

val typed = Update().pullAll(Book::categories, arrayOf("someCategory", "someCategory2"))
Expand All @@ -144,7 +144,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `currentDate() should equal expected Update`() {

val typed = Update().currentDate(Book::releaseDate)
Expand All @@ -153,7 +153,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `currentTimestamp() should equal expected Update`() {

val typed = Update().currentTimestamp(Book::releaseDate)
Expand All @@ -162,7 +162,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `multiply() should equal expected Update`() {

val typed = Update().multiply(Book::price, 2)
Expand All @@ -171,7 +171,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `max() should equal expected Update`() {

val typed = Update().max(Book::price, 200)
Expand All @@ -180,7 +180,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `min() should equal expected Update`() {

val typed = Update().min(Book::price, 100)
Expand All @@ -189,7 +189,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `bitwise() should equal expected Update`() {

val typed = Update().bitwise(Book::price).and(2)
Expand All @@ -198,7 +198,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `filterArray() should equal expected Update`() {

val typed = Update().filterArray(Book::categories, "someCategory")
Expand All @@ -207,7 +207,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `typed modifies() should equal expected modifies()`() {

val typed = update(Book::title, "Moby-Dick")
Expand All @@ -216,7 +216,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed.modifies(Book::price)).isEqualTo(typed.modifies("price"))
}

@Test
@Test // GH-3028
fun `One level nested should equal expected Update`() {

val typed = update(Book::author / Author::name, "Herman Melville")
Expand All @@ -225,7 +225,7 @@ class TypedUpdateExtensionsTests {
assertThat(typed).isEqualTo(expected)
}

@Test
@Test // GH-3028
fun `Two levels nested should equal expected Update`() {

data class Entity(val book: Book)
Expand Down
2 changes: 1 addition & 1 deletion src/main/antora/antora-playbook.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ content:
- url: https://github.com/spring-projects/spring-data-commons
# Refname matching:
# https://docs.antora.org/antora/latest/playbook/content-refname-matching/
branches: [ main, 3.2.x ]
branches: [ main, 3.3.x, 3.2.x]
start_path: src/main/antora
asciidoc:
attributes:
Expand Down
Loading

0 comments on commit 78fbea4

Please sign in to comment.