Skip to content

Commit

Permalink
Add test for Kotlin Collections
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Dec 14, 2022
1 parent 0c348b9 commit 21a7649
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package io.smallrye.config.test.collections

import org.eclipse.microprofile.config.inject.ConfigProperty
import javax.enterprise.context.Dependent
import javax.inject.Inject

@Dependent
class KotlinCollectionsBean {
@Inject
@ConfigProperty(name = "property.list")
lateinit var typeList: List<MyType>

@Inject
@ConfigProperty(name = "property.single")
lateinit var singleType: MyType
}

class MyType(val value: String) {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.smallrye.config.test.collections;

import static org.testng.Assert.assertEquals;

import javax.inject.Inject;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.testng.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.testng.annotations.Test;

public class KotlinCollectionsBeanTest extends Arquillian {
@Deployment
public static WebArchive deploy() {
return ShrinkWrap
.create(WebArchive.class)
.addClasses(CollectionBean.class)
.addClasses(KotlinCollectionsBean.class, KotlinCollectionsBeanTest.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml")
.addAsResource(new StringAsset("property.list=1,2,3\n" +
"property.single=1234\n"),
"META-INF/microprofile-config.properties");
}

@Inject
KotlinCollectionsBean kotlinCollectionsBean;

@Test
public void kotlinCollections() {
assertEquals(kotlinCollectionsBean.typeList.get(0).getValue(), "1");
assertEquals(kotlinCollectionsBean.typeList.get(1).getValue(), "2");
assertEquals(kotlinCollectionsBean.typeList.get(2).getValue(), "3");
assertEquals(kotlinCollectionsBean.singleType.getValue(), "1234");
}
}

0 comments on commit 21a7649

Please sign in to comment.