Friday 13 September 2019

Rational Rhapsody Tip #65 - Linking to Jazz/qm test cases using Rhapsody Model Manager (6.0.6)

"Can I link to Jazz/qm test cases directly from Rhapsody?" came up recently in one of my training's.

Here's a short video that shows how...

The first thing to note is that the Rhapsody project needs to be stored in the Jazz/am application (aka Rhapsody Model Manager). This Jazz/am project area currently associated with requirements in Jazz/rm:

Note how external artifacts representing requirements can be placed on any diagram.

Here we can also see the OSLC links to other Jazz applications.

Jazz/am allows web browser access to the Rhapsody elements and diagrams.

To work with external test cases we need to first associate the Rhapsody Jazz/am project area with a Jazz/qm project area. I'll add an association to the Jazz/qm project area to consume Architecture Elements provided by Jazz/am.

When you close and re-open the Rhapsody project to get the Remote Artifacts Package to show the new association.

With OSLC linking, the requirements are not stored in Rhapsody, just the links. We can choose to login to access remote artifacts.

Let's add some relationships to tests in Jazz/qm. There's an Add New > OSLC Link on the diagrams right-click menu.

There's also an OSLC Links tab in the Features window.

For a Validated By link type, the picker allows me to select existing or create new test case.

The OSLC link is now shown in the OSLC Links tab.

The test case shows Validates Architecture Elements links to the Rhapsody elements.

You can use the Show in Rhapsody button to navigate to the Rhapsody client.

Jazz/qm test cases can be dragged on to diagrams similar to requirements.

... and Validated By OSLC links can be added by drawing a dependency.

Let's try again, this time with an activity diagram.

With the OSLC delegated user interface we can also create new test cases in Jazz/qm.

The rich hover in Jazz/qm allows the test engineer to view or jump to the Rhapsody element or diagram.

Sunday 1 September 2019

Rational Rhapsody Tip #64 - Customizing Rhapsody's C/C++ code generator using a simplifier plugin

I've been doing more training lately with the IBM Rational Rhapsody Developer Edition. This has promoted me to show a few videos on the fundamentals of C/C++ code generation. This video gives an "under the hood" look at the two stage process that underlies the built-in C/C++ code generation technology. Based on a modified version of the UsersSimplifiers.rpy project in the Rhapsody samples folder, it shows how we can use plugin customisation to make a single change to the generated code for many files.

Not many people realize that Rhapsody's own C and C++ code generator is based on a two stage process starting with a model-to-model transform. We can view this model-to-model transform by setting the CPP_CG::Configuration::ShowCgSimplifiedModelPackage property and regenerating the code.

The results of the "simplifier" step will then be shown in the Rhapsody browser. This "simplification" takes into account diagrams, properties and other settings in the model. The model is called 'simplified' because it is flattened out into just types, attributes, operations and relations, e.g., statecharts are converted into C/C++ operations that will implement them.

The user model has the diagrams and properties and other settings that determine what to generate. Whereas the simplified model has a simplified metamodel that has a direct correspondence with the code that will be written into the .h/.cpp/.c files

So, why make the simplified model available in the browser? Well, it's because it's possible to customize this simplification step.

This project is a modified version of the UserSimplifiers sample in the Rhapsody installation.

Let's look at an example of a call-back hook available during C/C++ code generation. This plugin and these hooks will be pulled into the Rhapsody process when the project is loaded. In this example, this post simplication call-back checks for a «SingletonPattern» stereotype on classes.

If present, the Java plugin adds additional elements to the simplified model prior to Rhapsody writing the .h/.cpp files.

Let's re-generate again to a different configuration's folder to view its effect. First we need to set the stereotype that the post simplification hook is looking for.

The simplified model now has additional elements added by the simplification plugin.

The active code view shows us the .h/.cpp files that were generated. It includes user-defined methods as well as operations/attributes automatically generated. We can view the differences using a textual diff tool

Let's look at another example, an onPostSimplication call-back for operations. This adds a call the Reporter singleton class to the body of operations.

To get the simplifier plugin change to be reloaded, we need to completely exit and re-launch Rhapsody. When we open the sample model the plugin will be loaded into the Rhapsody process (due to a profile that loads a .hep profile).

Like pretty much everything in Rhapsody, the simplifier is controlled through Rhapsody properties. Here we can see that the stereotype is setting CPP_CG::Operation::Simplify to ByUserPostDefault.

With the simplifier plugin now active for operations, let's re-generate the code. We can then view the results in the textual differencing tool. This code was added by the simplifier plugin.

Like adding a new gear to your process, using customisations like this we can make a single change to the generated code for many files.