-
Notifications
You must be signed in to change notification settings - Fork 1k
/
GroovyEnumElementSpec.groovy
52 lines (43 loc) · 1.14 KB
/
GroovyEnumElementSpec.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package io.micronaut.ast.groovy.visitor
import io.micronaut.ast.transform.test.AbstractBeanDefinitionSpec
import io.micronaut.inject.ast.ClassElement
import io.micronaut.inject.ast.ElementQuery
class GroovyEnumElementSpec extends AbstractBeanDefinitionSpec {
void "test is enum"() {
given:
def element = buildClassElement("""
package test
enum MyEnum {
A, B
}
""")
expect:
element.isEnum()
element.getPrimaryConstructor().get().getDeclaringType().isEnum()
}
void "test inner enum is enum"() {
given:
def element = buildClassElement("test.Foo","""
package test
class Foo {
enum MyEnum {
A, B
}
}
""")
expect:
element.getEnclosedElement(ElementQuery.of(ClassElement.class)).get().getPrimaryConstructor().get().getDeclaringType().isEnum()
}
void "exclude Groovy autogenerated MAX_VALUE and MIN_VALUE"() {
given:
def element = (GroovyEnumElement) buildClassElement("""
package test
enum MyEnum {
A, B
}
""")
expect:
!element.values().contains('MAX_VALUE')
!element.values().contains('MIN_VALUE')
}
}