[Lombok] Adapt format of codegen tests to standard box() style

This commit is contained in:
Dmitriy Novozhilov
2022-05-24 10:41:44 +03:00
committed by teamcity
parent bc8051ce9b
commit dcd96932aa
30 changed files with 252 additions and 281 deletions
+19 -19
View File
@@ -3,8 +3,9 @@
import lombok.*; import lombok.*;
import lombok.experimental.*; import lombok.experimental.*;
@Getter @Setter @Getter
@Accessors(prefix = {"f", "field"}) @Setter
@Accessors(prefix = { "f", "field" })
public class AccessorsTest { public class AccessorsTest {
// @Accessors // @Accessors
private int age = 10; private int age = 10;
@@ -17,8 +18,9 @@ public class AccessorsTest {
@Accessors @Accessors
private Boolean isNonPrimitiveHuman; private Boolean isNonPrimitiveHuman;
static void test() { static void test()
val obj = new AccessorsTest(); {
val obj = new AccessorsTest ();
// obj.getAge(); // obj.getAge();
// obj.setAge(123); // obj.setAge(123);
@@ -44,28 +46,26 @@ public class AccessorsTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = AccessorsTest()
val obj = AccessorsTest()
// obj.getAge() // obj.getAge()
// obj.setAge(123) // obj.setAge(123)
obj.getTarget() obj.getTarget()
obj.setTarget(34) obj.setTarget(34)
obj.getValue() obj.getValue()
obj.setValue("sdf") obj.setValue("sdf")
obj.isHuman() obj.isHuman()
obj.setHuman(true) obj.setHuman(true)
obj.isPrefixedBoolean() obj.isPrefixedBoolean()
obj.setPrefixedBoolean(false) obj.setPrefixedBoolean(false)
obj.getIsNonPrimitiveHuman() obj.getIsNonPrimitiveHuman()
obj.setIsNonPrimitiveHuman(false) obj.setIsNonPrimitiveHuman(false)
}
return "OK"
} }
@@ -15,15 +15,13 @@ public class PrefixJava {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { //not generated because doesn't have prefix from class level @Accessors
//not generated because doesn't have prefix from class level @Accessors //assertEquals(PrefixJava().propA, "A")
//assertEquals(PrefixJava().propA, "A") //not generated because doesn't have prefix from config
//not generated because doesn't have prefix from config //assertEquals(PrefixJava().propC, "C")
//assertEquals(PrefixJava().propC, "C") assertEquals(PrefixJava().propD, "D")
assertEquals(PrefixJava().propD, "D") return "OK"
}
} }
//FILE: lombok.config //FILE: lombok.config
+15 -18
View File
@@ -43,30 +43,27 @@ public class AccessorsTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = AccessorsTest()
val obj = AccessorsTest()
// obj.getAge() // obj.getAge()
// obj.setAge(123) // obj.setAge(123)
obj.getTarget() obj.getTarget()
obj.setTarget(34) obj.setTarget(34)
obj.getValue() obj.getValue()
obj.setValue("sdf") obj.setValue("sdf")
obj.isHuman() obj.isHuman()
obj.setHuman(true) obj.setHuman(true)
obj.isPrefixedBoolean() obj.isPrefixedBoolean()
obj.setPrefixedBoolean(false) obj.setPrefixedBoolean(false)
obj.getIsNonPrimitiveHuman()
obj.setIsNonPrimitiveHuman(false)
}
obj.getIsNonPrimitiveHuman()
obj.setIsNonPrimitiveHuman(false)
return "OK"
} }
//FILE: lombok.config //FILE: lombok.config
+3 -4
View File
@@ -19,8 +19,7 @@ public class ConstructorExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val generated = ConstructorExample(12, "sdf", true)
val generated = ConstructorExample(12, "sdf", true) return "OK"
}
} }
@@ -24,9 +24,8 @@ public class ConstructorExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val existing: ConstructorExample = ConstructorExample("existing")
val existing: ConstructorExample = ConstructorExample("existing") val generated: ConstructorExample = ConstructorExample.of(45, "234", false)
val generated: ConstructorExample = ConstructorExample.of(45, "234", false) return "OK"
}
} }
+20 -21
View File
@@ -79,32 +79,31 @@ class KotlinChildClass : ClashTest() {
} }
class Test { fun box(): String {
fun run() { val obj = ClashTest()
val obj = ClashTest()
obj.getAge() obj.getAge()
//thats shouldn't work because lombok doesn't generate clashing method //thats shouldn't work because lombok doesn't generate clashing method
// obj.setAge(41) // obj.setAge(41)
// obj.age = 12 // obj.age = 12
val age = obj.age val age = obj.age
obj.getName() obj.getName()
obj.setName("Al") obj.setName("Al")
val name = obj.name val name = obj.name
obj.name = "sdf" obj.name = "sdf"
obj.isHuman() obj.isHuman()
obj.setHuman(true) obj.setHuman(true)
obj.isHuman("sdf") obj.isHuman("sdf")
val isHuman = obj.isHuman val isHuman = obj.isHuman
obj.isHuman = false obj.isHuman = false
val childObj = KotlinChildClass() val childObj = KotlinChildClass()
childObj.getToOverride() childObj.getToOverride()
childObj.setToOverride(34) childObj.setToOverride(34)
childObj.toOverride childObj.toOverride
childObj.toOverride = 412 childObj.toOverride = 412
} return "OK"
} }
+6 -7
View File
@@ -19,13 +19,12 @@ public class GetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GetterTest()
val obj = GetterTest() val ref: GetterTest = obj.name("some").age(34)
val ref: GetterTest = obj.name("some").age(34) obj.name()
obj.name() obj.age()
obj.age() return "OK"
}
} }
//FILE: lombok.config //FILE: lombok.config
+6 -7
View File
@@ -22,13 +22,12 @@ public class GetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GetterTest()
val obj = GetterTest() val ref: GetterTest = obj.fluent(true)
val ref: GetterTest = obj.fluent(true) obj.name()
obj.name() obj.age()
obj.age() return "OK"
}
} }
//FILE: lombok.config //FILE: lombok.config
+5 -6
View File
@@ -15,13 +15,12 @@ public class GetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GetterTest()
val obj = GetterTest()
obj.primitiveBoolean obj.primitiveBoolean
obj.getPrimitiveBoolean() obj.getPrimitiveBoolean()
} return "OK"
} }
//FILE: lombok.config //FILE: lombok.config
+5 -6
View File
@@ -15,13 +15,12 @@ public class GetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GetterTest()
val obj = GetterTest()
obj.primitiveBoolean obj.primitiveBoolean
obj.getPrimitiveBoolean() obj.getPrimitiveBoolean()
} return "OK"
} }
//FILE: lombok.config //FILE: lombok.config
+12 -13
View File
@@ -27,18 +27,17 @@ import lombok.*;
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = DataExample("name")
val obj = DataExample("name") obj.getName()
obj.getName() assertEquals(obj.name, "name")
assertEquals(obj.name, "name") obj.getTags()
obj.getTags() val tags = obj.tags
val tags = obj.tags obj.setScore(1.5)
obj.setScore(1.5) assertEquals(obj.score, 1.5)
assertEquals(obj.score, 1.5) obj.score = 2.5
obj.score = 2.5 assertEquals(obj.score, 2.5)
assertEquals(obj.score, 2.5)
val ex: DataExample.Exercise<Int> = DataExample.Exercise.of("name", 12) val ex: DataExample.Exercise<Int> = DataExample.Exercise.of("name", 12)
} return "OK"
} }
+9 -9
View File
@@ -26,13 +26,13 @@ public class GenericsTest<A, B> {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GenericsTest<String, Boolean>()
val obj = GenericsTest<String, Boolean>() val age: Int = obj.getAge();
val age: Int = obj.getAge(); obj.setFieldA("fooo");
obj.setFieldA("fooo"); val a: String = obj.getFieldA();
val a: String = obj.getFieldA(); val b: Boolean? = obj.getFieldB();
val b: Boolean? = obj.getFieldB(); obj.setFieldC(java.util.HashMap<String, Boolean>());
obj.setFieldC(java.util.HashMap<String, Boolean>()); return "OK"
}
} }
+4 -5
View File
@@ -21,9 +21,8 @@ public class ConstructorExample<A, B> {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val generated = ConstructorExample<Long, Boolean>(12, 42L, true)
val generated = ConstructorExample<Long, Boolean>(12, 42L, true) val generatedReq = ConstructorExample<String, Boolean>("234");
val generatedReq = ConstructorExample<String, Boolean>("234"); return "OK"
}
} }
@@ -21,11 +21,10 @@ public class ConstructorExample<A, B> {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val generated: ConstructorExample<Long, Boolean> = ConstructorExample.of(12, 42L, true)
val generated: ConstructorExample<Long, Boolean> = ConstructorExample.of(12, 42L, true) assertEquals(generated.name, 42L)
assertEquals(generated.name, 42L) val generatedReq: ConstructorExample<String, Boolean> = ConstructorExample.of("234")
val generatedReq: ConstructorExample<String, Boolean> = ConstructorExample.of("234") assertEquals(generatedReq.name, "234")
assertEquals(generatedReq.name, "234") return "OK"
}
} }
+19 -19
View File
@@ -25,30 +25,30 @@ public class GetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GetterTest()
val obj = GetterTest() val getter = obj.getAge()
val getter = obj.getAge() val property = obj.age
val property = obj.age
//todo kotlin doesn't see isBoolean methods as property //todo kotlin doesn't seee isBoolean methods as property
// obj.primitiveBoolean // obj.primitiveBoolean
obj.isPrimitiveBoolean() obj.isPrimitiveBoolean()
obj.boxedBoolean obj.boxedBoolean
obj.getBoxedBoolean() obj.getBoxedBoolean()
//shouldn't be accesible from here //shouldn't be accesible from here
// obj.getName() // obj.getName()
// obj.getInvisible() // obj.getInvisible()
OverridenGetterTest().usage() OverridenGetterTest().usage()
} return "OK"
}
class OverridenGetterTest : GetterTest() { class OverridenGetterTest : GetterTest() {
fun usage() { fun usage() {
getName() getName()
}
} }
} }
+14 -15
View File
@@ -23,26 +23,25 @@ public class ClassLevelGetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = ClassLevelGetterTest()
val obj = ClassLevelGetterTest() val getter = obj.getAge()
val getter = obj.getAge() val property = obj.age
val property = obj.age
obj.isPrimitiveBoolean() obj.isPrimitiveBoolean()
obj.boxedBoolean obj.boxedBoolean
obj.getBoxedBoolean() obj.getBoxedBoolean()
//shouldn't be accesible from here //shouldn't be accesible from here
// obj.getName() // obj.getName()
OverridenGetterTest().usage() OverridenGetterTest().usage()
} return "OK"
}
class OverridenGetterTest : ClassLevelGetterTest() { class OverridenGetterTest : ClassLevelGetterTest() {
fun usage() { fun usage() {
getName() getName()
}
} }
} }
+13 -14
View File
@@ -27,24 +27,23 @@ public class FluentTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = FluentTest()
val obj = FluentTest() assertEquals(obj.age(), 10)
assertEquals(obj.age(), 10)
obj.primitiveBoolean() obj.primitiveBoolean()
obj.boxedBoolean() obj.boxedBoolean()
obj.overrideAnnotation obj.overrideAnnotation
obj.getOverrideAnnotation() obj.getOverrideAnnotation()
OverridenGetterTest().usage() OverridenGetterTest().usage()
} return "OK"
}
class OverridenGetterTest : FluentTest() { class OverridenGetterTest : FluentTest() {
fun usage() { fun usage() {
name() name()
}
} }
} }
+5 -5
View File
@@ -22,9 +22,9 @@ public class ConstructorExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val existing = ConstructorExample("existing")
val existing = ConstructorExample("existing") val generated = ConstructorExample()
val generated = ConstructorExample() return "OK"
}
} }
+5 -5
View File
@@ -22,9 +22,9 @@ public class ConstructorExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val existing: ConstructorExample = ConstructorExample("existing")
val existing: ConstructorExample = ConstructorExample("existing") val generated: ConstructorExample = ConstructorExample.make()
val generated: ConstructorExample = ConstructorExample.make() return "OK"
}
} }
+5 -6
View File
@@ -14,10 +14,9 @@ public class GetterSetterExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GetterSetterExample()
val obj = GetterSetterExample() val age: Int = obj.getAge()
val age: Int = obj.getAge() val name: String? = obj.getName()
val name: String? = obj.getName() return "OK"
}
} }
@@ -23,8 +23,7 @@ public class Foo {
//FILE: test.kt //FILE: test.kt
@Anno @Anno
class Test { fun box(): String {
fun run() { val obj = Foo()
val obj = Foo() return "OK"
}
} }
+4 -5
View File
@@ -13,8 +13,7 @@ public class ChildClass extends ParentClass {}
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { ChildClass::class
ChildClass::class return "OK"
} }
}
+5 -5
View File
@@ -33,9 +33,9 @@ public class ConstructorExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val generated = ConstructorExample("foo", true)
val generated = ConstructorExample("foo", true) assertEquals(generated.foo, "foo")
assertEquals(generated.foo, "foo") return "OK"
}
} }
@@ -35,9 +35,8 @@ public class ConstructorExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val generated = ConstructorExample.build("foo", true, 12)
val generated = ConstructorExample.build("foo", true, 12) assertEquals(generated.foo, "foo")
assertEquals(generated.foo, "foo") return "OK"
}
} }
+13 -14
View File
@@ -20,25 +20,24 @@ public class SetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = SetterTest()
val obj = SetterTest() obj.setAge(42)
obj.setAge(42) obj.age = 42
obj.age = 42
//synthetic property generated only when there is a getter //synthetic property generated only when there is a getter
// obj.primitiveBoolean = false // obj.primitiveBoolean = false
obj.setPrimitiveBoolean(true) obj.setPrimitiveBoolean(true)
//shouldn't be accesible from here //shouldn't be accesible from here
// obj.setName("abc") // obj.setName("abc")
OverridenGetterTest().usage() OverridenGetterTest().usage()
} return "OK"
}
class OverridenGetterTest : SetterTest() { class OverridenGetterTest : SetterTest() {
fun usage() { fun usage() {
setName("abc") setName("abc")
}
} }
} }
+11 -12
View File
@@ -23,18 +23,17 @@ public class SetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = SetterTest()
val obj = SetterTest() obj.setAge(42)
obj.setAge(42) assertEquals(obj.age, 42)
assertEquals(obj.age, 42) obj.age = 43
obj.age = 43 assertEquals(obj.age, 43)
assertEquals(obj.age, 43)
obj.setPrimitiveBoolean(true) obj.setPrimitiveBoolean(true)
// no setters generated for final variable
// no setters generated for final variable // obj.setFinalName("error")
// obj.setFinalName("error") return "OK"
}
} }
+9 -11
View File
@@ -25,15 +25,13 @@ public class SetterTest {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = SetterTest()
val obj = SetterTest() obj.fluent(12)
obj.fluent(12) assertEquals(obj.fluent(), 12)
assertEquals(obj.fluent(), 12) obj.setChained("zz").getChained()
obj.setChained("zz").getChained() assertEquals(obj.getChained(), "zz")
assertEquals(obj.getChained(), "zz") obj.whyNotBoth("zzz").whyNotBoth()
obj.whyNotBoth("zzz").whyNotBoth() assertEquals(obj.whyNotBoth(), "zzz")
assertEquals(obj.whyNotBoth(), "zzz") return "OK"
}
} }
+5 -6
View File
@@ -13,10 +13,9 @@ public class GetterSetterExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = GetterSetterExample()
val obj = GetterSetterExample() val getter = obj.getAge()
val getter = obj.getAge() val property = obj.age
val property = obj.age return "OK"
}
} }
+11 -12
View File
@@ -28,17 +28,16 @@ import lombok.*;
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() { val obj = ValueExample("name", 12, 4.5)
val obj = ValueExample("name", 12, 4.5) assertEquals(obj.getName(), "name")
assertEquals(obj.getName(), "name") assertEquals(obj.name, "name")
assertEquals(obj.name, "name") assertEquals(obj.getAge(), 12)
assertEquals(obj.getAge(), 12) assertEquals(obj.age, 12)
assertEquals(obj.age, 12) assertEquals(obj.score, 4.5)
assertEquals(obj.score, 4.5)
val ex: ValueExample.Exercise<Int> = ValueExample.Exercise.of("nam1e", 42) val ex: ValueExample.Exercise<Int> = ValueExample.Exercise.of("nam1e", 42)
assertEquals(ex.name, "nam1e") assertEquals(ex.name, "nam1e")
assertEquals(ex.value, 42) assertEquals(ex.value, 42)
} return "OK"
} }
+5 -7
View File
@@ -18,11 +18,9 @@ public class WithExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
val obj: WithExample = WithExample().withAge(16).withName("fooo")
fun run() { assertEquals(obj.getName(), "fooo")
val obj: WithExample = WithExample().withAge(16).withName("fooo") assertEquals(obj.age, 16)
assertEquals(obj.getName(), "fooo") return "OK"
assertEquals(obj.age, 16)
}
} }