diff --git a/jackdaw-sample/src/main/java/com/github/vbauer/jackdaw/bean/IgnoredBeanModel.java b/jackdaw-sample/src/main/java/com/github/vbauer/jackdaw/bean/IgnoredBeanModel.java new file mode 100644 index 0000000..fb5457b --- /dev/null +++ b/jackdaw-sample/src/main/java/com/github/vbauer/jackdaw/bean/IgnoredBeanModel.java @@ -0,0 +1,30 @@ +package com.github.vbauer.jackdaw.bean; + +import com.github.vbauer.jackdaw.annotation.JAdapter; +import com.github.vbauer.jackdaw.annotation.JBean; +import com.github.vbauer.jackdaw.annotation.JBuilder; +import com.github.vbauer.jackdaw.annotation.JClassDescriptor; +import com.github.vbauer.jackdaw.annotation.JComparator; +import com.github.vbauer.jackdaw.annotation.JFactoryMethod; +import com.github.vbauer.jackdaw.annotation.JFunction; +import com.github.vbauer.jackdaw.annotation.JIgnore; +import com.github.vbauer.jackdaw.annotation.JPredicate; +import com.github.vbauer.jackdaw.annotation.JService; +import com.github.vbauer.jackdaw.annotation.JSupplier; + +/** + * @author Vladislav Bauer + */ +@JIgnore +@JAdapter +@JBean +@JBuilder +@JClassDescriptor +@JComparator +@JFactoryMethod +@JFunction +@JPredicate +@JService(Object.class) +@JSupplier +public abstract class IgnoredBeanModel { +} diff --git a/jackdaw-sample/src/test/kotlin/com/github/vbauer/jackdaw/JIgnoreTest.kt b/jackdaw-sample/src/test/kotlin/com/github/vbauer/jackdaw/JIgnoreTest.kt new file mode 100644 index 0000000..8126510 --- /dev/null +++ b/jackdaw-sample/src/test/kotlin/com/github/vbauer/jackdaw/JIgnoreTest.kt @@ -0,0 +1,57 @@ +package com.github.vbauer.jackdaw + +import com.github.vbauer.jackdaw.bean.IgnoredBeanModel +import org.hamcrest.BaseMatcher +import org.hamcrest.Description +import org.hamcrest.Matchers.emptyIterable +import org.hamcrest.Matchers.not +import org.junit.Assert.assertThat +import org.junit.Test +import java.util.* + +/** + * @author Vladislav Bauer + */ + +class JIgnoreTest { + + @Test + fun testIgnoredBean() { + assertThat(generatedClass("Adapter"), notExist()) + assertThat(beanClass(), notExist()) + assertThat(generatedClass("Builder"), notExist()) + assertThat(generatedClass("ClassDescriptor"), notExist()) + assertThat(generatedClass("Comparators"), notExist()) + assertThat(generatedClass("Factory"), notExist()) + assertThat(generatedClass("Functions"), notExist()) + assertThat(generatedClass("Predicates"), notExist()) + assertThat(generatedClass("Suppliers"), notExist()) + + val loader = ServiceLoader.load(IgnoredBeanModel::class.java) + assertThat(loader, emptyIterable()) + } + + + val pkg = "com.github.vbauer.jackdaw.bean" + + private fun notExist() = not(HasClassMatcher()) + private fun generatedClass(name: String) = pkg + ".IgnoredBeanModel" + name + private fun beanClass() = pkg + ".IgnoredBean" + + + class HasClassMatcher : BaseMatcher() { + override fun matches(item: Any?): Boolean { + try { + Class.forName(item.toString()) + return true + } catch (ex: Exception) { + return false + } + } + + override fun describeTo(description: Description) { + description.appendText("existed class") + } + } +} +