diff --git a/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/Employee.groovy b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/Employee.groovy index d0af18fe3d..f49d0f906b 100644 --- a/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/Employee.groovy +++ b/core-groovy-2/src/main/groovy/com/baeldung/metaprogramming/Employee.groovy @@ -37,5 +37,9 @@ class Employee { log.info "$methodName is not defined" "method '$methodName' is not defined" } + + def logEmp() { + log.info "Employee: $lastName, $firstName is of $age years age" + } } \ No newline at end of file diff --git a/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy b/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy index bafd1f8a63..8066b10f9b 100644 --- a/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy +++ b/core-groovy-2/src/test/groovy/com/baeldung/metaprogramming/MetaprogrammingUnitTest.groovy @@ -97,7 +97,7 @@ class MetaprogrammingUnitTest extends GroovyTestCase { void testEqualsAndHashCodeAnnotation() { Employee norman = new Employee(1, "norman", "lewis", 28) Employee normanCopy = new Employee(1, "norman", "lewis", 28) - assert norman == normanCopy + assert norman.equals(normanCopy) assert norman.hashCode() == normanCopy.hashCode() } @@ -109,7 +109,10 @@ class MetaprogrammingUnitTest extends GroovyTestCase { } catch(CloneNotSupportedException e) { e.printStackTrace() } - } + void testLoggingAnnotation() { + Employee employee = new Employee(1, "Norman", "Lewis", 28) + employee.logEmp() + } } \ No newline at end of file