These scenarios can be used as exercises to get familiar with Moose.
Ideally, a scenario:
- describes in a short paragraph the goal to achieve
- gives indication on how to get a result
- provides a model exemple (or explains how to get one)
- gives the expected result (if an exemple model is provided)
- Goal
Find whether a given method seems (static analysis) to be tested - Indications
- Choose a method (not a test) in the model,
- Follow incoming invocations and try to find a test method
- Example model
One can build a pharo model with a package (e.g.Collections-Atomic) and a test package (e.g.Collections-Atomic-Tests) - Expected result
Very simple exercise with methodnextOrNilthat is directly invoked by test methods. There are two implementations ofnextOrNil, classesLIFOQueueandWaitfreeQueue. They are invoked in 15 tests. Because they are direct invocations, one can use a "Navigation query" or a visualization (e.g. "Navigation tree")
- Goal
Find all methods of some given package(s) that have a given pragma/annotation - Indication
- Find all
AnnotationTypein the model (for exampleFamixStAnnotationTypefor a model of Pharo code - Restrict further to get one
AnnotationType(for example on the name "example") - Get all
AnnotationInstances - get the
annotatedEntity-ies of the instances
- Find all
- Example model
One can build a pharo model with a package (e.g.Rubric) and a pragma (e.g.example) - Expected result At the time of this writing, there are 3 methods with the
examplepragma:RubFloatingEditorBuilder>>exampleCommandLauncher;RubFloatingEditorBuilder>>exampleEditableStringMorph;RubTextAreaExamples>>nicolaiAttributeFix
- Goal
Find all instantiations of a class and its subclasses. - Indication
- Select a class
- Select its subclasses
- Collect their methods
- Select the constructor ones (i.e. new MyClass() in Java)
- Follow constructors incoming invocation
- Example model
You can easily get a Java model using VerveineJ. - Concrete application
Try to determine all the widgets creation of a GUI
- Goal
Retrieve the rest services of a Java Spring application with the possible methods and parameters. - Indication
- Look for the annotation
@Pathin a Java Project - Retrieve the classes annotated with the path annotation and the parameter of the path.
- Collect the methods of the classes
- Select the methods with a REST annotation (e.g.:
@GET,@POST) - Determine the path for those methods using again the
@Pathannotation (but on methods this time)
- Look for the annotation
- Example model
You can easily get a Java model using VerveineJ