[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
+8 -8
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,8 +46,7 @@ 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()
@@ -66,6 +67,5 @@ class Test {
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
@@ -43,8 +43,7 @@ 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()
@@ -64,9 +63,7 @@ class Test {
obj.getIsNonPrimitiveHuman() obj.getIsNonPrimitiveHuman()
obj.setIsNonPrimitiveHuman(false) obj.setIsNonPrimitiveHuman(false)
return "OK"
}
} }
//FILE: lombok.config //FILE: lombok.config
+2 -3
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"
} }
+2 -3
View File
@@ -79,8 +79,7 @@ class KotlinChildClass : ClashTest() {
} }
class Test { fun box(): String {
fun run() {
val obj = ClashTest() val obj = ClashTest()
obj.getAge() obj.getAge()
@@ -106,5 +105,5 @@ class Test {
childObj.setToOverride(34) childObj.setToOverride(34)
childObj.toOverride childObj.toOverride
childObj.toOverride = 412 childObj.toOverride = 412
} return "OK"
} }
+2 -3
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
+2 -3
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
+2 -3
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
+2 -3
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
+2 -3
View File
@@ -27,8 +27,7 @@ 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")
@@ -40,5 +39,5 @@ class Test {
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"
} }
+3 -3
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"
} }
+2 -3
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"
} }
+6 -6
View File
@@ -25,13 +25,12 @@ 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()
@@ -44,11 +43,12 @@ class Test {
// obj.getInvisible() // obj.getInvisible()
OverridenGetterTest().usage() OverridenGetterTest().usage()
} return "OK"
}
class OverridenGetterTest : GetterTest() { class OverridenGetterTest : GetterTest() {
fun usage() { fun usage() {
getName() getName()
} }
}
} }
+4 -5
View File
@@ -23,8 +23,7 @@ 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
@@ -38,11 +37,11 @@ class Test {
// obj.getName() // obj.getName()
OverridenGetterTest().usage() OverridenGetterTest().usage()
} return "OK"
}
class OverridenGetterTest : ClassLevelGetterTest() { class OverridenGetterTest : ClassLevelGetterTest() {
fun usage() { fun usage() {
getName() getName()
} }
}
} }
+4 -5
View File
@@ -27,8 +27,7 @@ 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)
@@ -40,11 +39,11 @@ class Test {
obj.getOverrideAnnotation() obj.getOverrideAnnotation()
OverridenGetterTest().usage() OverridenGetterTest().usage()
} return "OK"
}
class OverridenGetterTest : FluentTest() { class OverridenGetterTest : FluentTest() {
fun usage() { fun usage() {
name() name()
} }
}
} }
+3 -3
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"
} }
+3 -3
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"
} }
+2 -3
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"
} }
+2 -3
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"
} }
+3 -3
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"
} }
+4 -5
View File
@@ -20,8 +20,7 @@ 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
@@ -34,11 +33,11 @@ class Test {
// 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")
} }
}
} }
+3 -4
View File
@@ -23,8 +23,7 @@ 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)
@@ -33,8 +32,8 @@ class Test {
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"
} }
+2 -4
View File
@@ -25,8 +25,7 @@ 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)
@@ -34,6 +33,5 @@ class Test {
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"
} }
+2 -3
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"
} }
+2 -3
View File
@@ -28,8 +28,7 @@ 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")
@@ -40,5 +39,5 @@ class Test {
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"
} }
+2 -4
View File
@@ -18,11 +18,9 @@ public class WithExample {
//FILE: test.kt //FILE: test.kt
class Test { fun box(): String {
fun run() {
val obj: WithExample = WithExample().withAge(16).withName("fooo") val obj: WithExample = WithExample().withAge(16).withName("fooo")
assertEquals(obj.getName(), "fooo") assertEquals(obj.getName(), "fooo")
assertEquals(obj.age, 16) assertEquals(obj.age, 16)
} return "OK"
} }