-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
132 additions
and
13 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
kmongo-core-tests/src/main/kotlin/org/litote/kmongo/issues/Issue314ValueClass.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
* Copyright (C) 2016/2021 Litote | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.litote.kmongo.issues | ||
|
||
import org.bson.codecs.pojo.annotations.BsonId | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
import org.litote.kmongo.AllCategoriesKMongoBaseTest | ||
import org.litote.kmongo.Id | ||
import org.litote.kmongo.eq | ||
import org.litote.kmongo.findOne | ||
import org.litote.kmongo.newId | ||
import kotlin.test.assertNotNull | ||
|
||
data class Account(@BsonId val id: Id<Account>, val email: EmailAddress) | ||
|
||
@JvmInline | ||
value class EmailAddress(val value: String) | ||
|
||
|
||
/** | ||
* | ||
*/ | ||
class Issue314ValueClass : AllCategoriesKMongoBaseTest<Account>() { | ||
|
||
@Test | ||
@Ignore | ||
fun `test insert and load`() { | ||
col.insertOne(Account(newId(), EmailAddress("a"))) | ||
val doc = col.findOne(Account::email eq EmailAddress("a")) | ||
assertNotNull(doc) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
kmongo/src/test/kotlin/org/litote/kmongo/issues/Issue316ReplaceNotNull.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright (C) 2016/2021 Litote | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.litote.kmongo.issues | ||
|
||
import org.junit.Test | ||
import org.litote.kmongo.and | ||
import org.litote.kmongo.combine | ||
import org.litote.kmongo.div | ||
import org.litote.kmongo.eq | ||
import org.litote.kmongo.exists | ||
import org.litote.kmongo.json | ||
import org.litote.kmongo.or | ||
import org.litote.kmongo.setValue | ||
import org.litote.kmongo.unset | ||
|
||
/** | ||
* | ||
*/ | ||
class Issue316ReplaceNotNull { | ||
|
||
class MyClass(val someId:String, val someOtherId: String, val nestedObject:NestedClass) | ||
class NestedClass(val yetAnotherId: String) | ||
|
||
@Test | ||
fun `test insert and load`() { | ||
val filter = and( | ||
or( | ||
MyClass::someId eq "someId", | ||
MyClass::someOtherId eq "someOtherId", | ||
MyClass::nestedObject / NestedClass::yetAnotherId eq "yetAnotherId" | ||
), | ||
MyClass::nestedObject exists true | ||
) | ||
println(filter.json) | ||
} | ||
|
||
class Data(val field1:Int, val field2:Int) | ||
|
||
@Test | ||
fun `test insert and load2`() { | ||
val filter = combine(unset( Data::field1,), setValue(Data::field2 , 2)) | ||
println(filter.json) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters