Task: Pass the suite tests.PointGroupLog
.
Write an aspect to log whenever a Point
is added to a Group
. Note that this requires a dynamic instanceof
test, because in principle any figure element can be added to a group. The log message should simply be:
adding Point
args
primitive pointcut. Besides exposing context objects, this
, target
and args
can also be used to include a dynamic type test in the pointcut.
With your aspect you should be able to pass the tests of suite tests.PointGroupLog
.
Task: Pass the suite tests.PointGroupInvariant
.
Add similar advice to ensure that a Point
is never added to more than one Group
. If this invariant is violated, the advice should throw an IllegalStateException
that uses the string representation of the first group as its message.
Take a look a the implementation of the test case to see what is precisely expected.
Group
with each Point
object. Check and set this field from the advice.
After you have completed the exercise, remove your aspect from the build path; then return to the Overview.