-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Transformer: ignore fields of type List with @convert annotation.
- objectbox/objectbox-java#481 - Extract and add transformer converter tests.
- Loading branch information
1 parent
6e448d1
commit 5dcda93
Showing
8 changed files
with
198 additions
and
102 deletions.
There are no files selected for viewing
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
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
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
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
52 changes: 52 additions & 0 deletions
52
...dle-plugin/src/test/kotlin/io/objectbox/gradle/transform/ClassTransformerConverterTest.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,52 @@ | ||
package io.objectbox.gradle.transform | ||
|
||
import org.junit.Assert | ||
import org.junit.Test | ||
|
||
|
||
class ClassTransformerConverterTest : AbstractTransformTest() { | ||
|
||
@Test | ||
fun testTransformEntity_converter_shouldNotTransform() { | ||
val classes = listOf(EntityConverterList::class, | ||
EntityEmpty::class, EntityEmptyConverter::class) | ||
val (stats) = testTransformOrCopy(classes, 0, 3) | ||
Assert.assertEquals(0, stats.boxStoreFieldsAdded) | ||
Assert.assertEquals(0, stats.toOnesFound) | ||
Assert.assertEquals(0, stats.toManyFound) | ||
Assert.assertEquals(0, stats.toManyInitializerAdded) | ||
} | ||
|
||
@Test | ||
fun testTransformEntity_converterAndList_shouldTransformOnlyList() { | ||
val classes = listOf(EntityConverterListAndList::class, EntityConverterListAndList_::class, | ||
EntityEmpty::class, EntityEmptyConverter::class) | ||
val (stats) = testTransformOrCopy(classes, 1, 3) | ||
Assert.assertEquals(1, stats.boxStoreFieldsAdded) | ||
Assert.assertEquals(0, stats.toOnesFound) | ||
Assert.assertEquals(1, stats.toManyFound) | ||
Assert.assertEquals(1, stats.toManyInitializerAdded) | ||
} | ||
|
||
@Test | ||
fun testTransformEntity_converterAndToMany_shouldTransformOnlyToMany() { | ||
val classes = listOf(EntityConverterAndToMany::class, EntityConverterAndToMany_::class) | ||
val (stats) = testTransformOrCopy(classes, 1, 1) | ||
Assert.assertEquals(1, stats.boxStoreFieldsAdded) | ||
Assert.assertEquals(0, stats.toOnesFound) | ||
Assert.assertEquals(1, stats.toManyFound) | ||
Assert.assertEquals(1, stats.toManyInitializerAdded) | ||
} | ||
|
||
@Test | ||
fun testTransformEntity_converterAndToOne_shouldTransformOnlyToOne() { | ||
val classes = listOf(EntityConverterAndToOne::class, EntityConverterAndToOne_::class) | ||
val (stats) = testTransformOrCopy(classes, 1, 1) | ||
Assert.assertEquals(1, stats.boxStoreFieldsAdded) | ||
Assert.assertEquals(1, stats.toOnesFound) | ||
Assert.assertEquals(0, stats.toManyFound) | ||
Assert.assertTrue(stats.constructorsCheckedForTransform >= 1) | ||
Assert.assertEquals(stats.constructorsCheckedForTransform, stats.toOnesInitializerAdded) | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.