Skip to content

Commit

Permalink
tweaky tweaky tweaky
Browse files Browse the repository at this point in the history
  • Loading branch information
evanchooly committed Sep 1, 2024
1 parent 1d07659 commit 15248af
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,8 @@ class EntityModelGenerator(source: KSClassDeclaration, val config: MorphiaConfig
}

private fun annotations(ctor: Builder) {
println("**************** annotations()")
source.allAnnotations().forEach { annotation ->
println("**************** annotation = ${annotation}")
val codeGen = annotation.entityCodeGen()
try {
ctor.addCode("\nannotation($codeGen);")
} finally {
println("**************** codeGen = ${codeGen}")
}
ctor.addCode("\nannotation(${annotation.entityCodeGen()});")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,16 @@ import dev.morphia.critter.sources.Example
import dev.morphia.mapping.codec.pojo.PropertyModel
import dev.morphia.mapping.codec.pojo.TypeData
import io.quarkus.gizmo.ClassCreator
import io.quarkus.gizmo.ClassOutput
import io.quarkus.gizmo.MethodDescriptor
import java.lang.reflect.Modifier
import kotlin.reflect.KClass
import org.objectweb.asm.Type
import org.testng.Assert.assertEquals
import org.testng.Assert.assertNotNull
import org.testng.Assert.fail
import org.testng.annotations.Test

class TestGizmoGeneration {
private val map: Map<String, Example>? = null
private val list: List<Map<String, Example>>? = null

private val classOutput = ClassOutput { name, data ->
critterClassLoader.register(name.replace('/', '.'), data)
}

@Test
fun testMapStringExample() {
var descString = "Ljava/util/Map<Ljava/lang/String;Ldev/morphia/critter/sources/Example;>;"
Expand All @@ -38,7 +31,7 @@ class TestGizmoGeneration {
var typeData = typeData(descString)[0]
assertEquals(
typeData,
Map::class.java.typeData(String::class.java.typeData(), Example::class.java.typeData())
Map::class.typeData(String::class.typeData(), Example::class.typeData())
)
}

Expand All @@ -60,13 +53,9 @@ class TestGizmoGeneration {
val typeData = typeData(descString)[0]
assertEquals(
typeData,
List::class
.java
.typeData(
Map::class
.java
.typeData(String::class.java.typeData(), Example::class.java.typeData())
)
List::class.typeData(
Map::class.typeData(String::class.typeData(), Example::class.typeData())
)
)
}

Expand All @@ -81,17 +70,13 @@ class TestGizmoGeneration {
descriptor(List::class.java, descriptor(Example::class.java))
)
assertEquals(descriptor, descString)
println("**************** descString = ${descriptor}")
val typeData = typeData(descriptor)[0]
println("**************** descString = $typeData")
assertEquals(
typeData,
Map::class
.java
.typeData(
String::class.java.typeData(),
List::class.java.typeData(Example::class.java.typeData())
)
Map::class.typeData(
String::class.typeData(),
List::class.typeData(Example::class.typeData())
)
)
}

Expand All @@ -107,10 +92,11 @@ class TestGizmoGeneration {
return desc
}

private fun Class<*>.typeData(vararg typeParameters: TypeData<*>) =
TypeData(this, listOf(*typeParameters))
private fun KClass<*>.typeData(vararg typeParameters: TypeData<*>): TypeData<*> {
return TypeData(this.java, listOf(*typeParameters))
}

@Test
// @Test
fun testGizmo() {
val generator = CritterGizmoGenerator(critterClassLoader, GeneratorTest.mapper)
generator.generate(Example::class.java)
Expand Down Expand Up @@ -192,7 +178,6 @@ class TestGizmoGeneration {
.getConstructor(String::class.java)
.newInstance("here i am")

println("**************** newInstance = ${newInstance}")
val creator =
ClassCreator.builder()
.classOutput { name, data ->
Expand Down

0 comments on commit 15248af

Please sign in to comment.