Extending Imports from DOORS #8608328/HEAD / v10 |
Tags:
not added yet
Extending Imports from DOORScodeBeamer 10.0 and newer provides an extension mechanism for imports from IBM® Rational® DOORS® via the Codebeamer DOORS Bridge, that allows you to write and deploy own Java code, that plugs into the import process, to perform special data transformations, not supported by default.
DoorsImportExtension frameworkIf you want to extend the DOORS Import, you need to implement and deploy
We recommend, that the package of your custom DoorsImportExtensionFactory should be a sub-package of com.intland.codebeamer, e.g. com.intland.codebeamer.controller.doors.<mycompany> You can use any package name, but when using a sub-package of com.intland.codebeamer, your extensions can be automatically detected and deployed by the Component scan during CodeBeamer startup: package com.intland.codebeamer.controller.doors; import org.springframework.stereotype.Component; @Component("exampleTestCaseExtensionFactory") public class ExampleDoorsTestCaseExtensionFactory extends DoorsTestCaseExtensionFactory { ... } Whenever an import from IBM® Rational® DOORS® via the Codebeamer DOORS Bridge starts, the method createDoorsImportExtension(ImportContext doorsImport, JsonNode content)of all registered DoorsImportExtensionFactory implementations is called, to check, if this extension needs to instrument the specific import or not. To make this decision, the following information is provided:
import org.springframework.stereotype.Component; import org.springframework.beans.factory.annotation.Autowired; import com.intland.codebeamer.manager.TrackerItemManager; @Component("exampleTestCaseExtensionFactory") public class ExampleDoorsTestCaseExtensionFactory extends DoorsTestCaseExtensionFactory { @Autowired private TrackerItemManager trackerItemManager; ... } If applicable, the DoorsImportExtensionFactory must return an appropriate DoorsImportExtension for this import, otherwise null. A DoorsImportExtension, associated with a DOORS import, is called
Please note: DoorsImportExtension implementations must not be annotated and must not contain @Autowired variables. Java IDEDeveloping a own/custom DoorsImportExtension in Java requires a Java 8 or newer Standard Edition (SE) Java Development Kit (JDK) plus the following frameworks/libraries:
DeploymentTo deploy your custom extensions, the Java code must be compiled and the resulting *.class files must be uploaded to the appropriate sub-directory under ~/CB-.../tomcat/webapps/cb/WEB-INF/classes/... on your codeBeamer server, where the sub-directory is the equivalent of the extension's package name. ~/CB-../tomcat/webapps/cb/WEB-INF/classes/my-ApplicationContext.xml Finally you have to restart CodeBeamer, for your newly deployed extensions to get loaded. DoorsTestCaseExtensionCB-10.0 and newer, provides a basic DoorsImportExtension implementation for importing DOORS Test Specifications into codeBeamer Test Case trackers.
Optionally the following codeBeamer Test Case attributes can also be represented by (special) child objects
There is no required order for child objects representing the Test Case description, pre-/post-actions, test parameters or test steps. By default, the DoorsTestCaseExtension determines the Type of a DOORS object via a special/custom object enumeration attribute (discriminator), that must be mapped to either
The names of the discriminator field values are not relevant, but you must map them in the DOORS import configuration to target codeBeamer choice field options with the following predefined names:
Objects, whose discriminator value is none of the above, are either Folders or Information, depending on their DOORS object type. The Expected Result of a
DeploymentThere is no DoorsTestCaseExtension deployed by default, because there is no standard schema for Test Specifications in IBM® Rational® DOORS®.
In both examples, the name of the DOORS discriminator attribute is objectType and the name of the DOORS Test Step Result attribute is resultValue. Please note, that DoorsTestCaseExtensionFactory will only apply a DoorsTestCaseExtension, if
See except from DoorsTestCaseExtensionFactory.java: /** * Create a new {@link DoorsTestCaseExtension} instance, if the specified DOORS import is into a Test Case tracker * @param doorsImport is the DOORS import/context * @param content is the DOORS content (module plus attributes plus objects) to import * @return a new {@link DoorsTestCaseExtension} instance, or null, if no extension is needed */ @Override public DoorsTestCaseExtension createDoorsImportExtension(ImportContext doorsImport, JsonNode content) { if (doorsImport.getTracker().isTestCase()) { TrackerLayoutLabelDto discriminatorField = doorsImport.getConfig().getMappedField(discriminatorAttribute); TrackerLayoutLabelDto testStepResultField = doorsImport.getConfig().getMappedField(testStepResultAttribute); if (isApplicable(doorsImport, content, discriminatorField, testStepResultField)) { return createDoorsImportExtension(doorsImport, content, discriminatorField, testStepResultField, additionalTestCaseFields); } } return null; } /** * Check if we should provide a {@link DoorsTestCaseExtension} for the specified DOORS Test Cases/Specifications import/context * @param doorsImport is the DOORS Test Cases/Specifications import/context * @param content is the DOORS content (module plus attributes plus objects) to import * @param discriminatorField is the target tracker field, that defines whether an imported {@link TrackerItemDto} <ul> * <li>is a Test Case</li> * <li>is the Description (Purpose) of the parent object (= Test Case)</li> * <li>is a Pre-Action (Prerequisite) of the parent object (= Test Case)</li> * <li>is a Post-Action of the parent object (= Test Case)</li> * <li>is a Test Parameter of the parent object (= Test Case)</li> * <li>is a Test Step of the parent object (= Test Case)</li></ul>, * or null, to use {@link TrackerItemDto#getCategories()} as the discriminator * @param testStepResultField is the target tracker field of imported test step items, where the test step result is stored * @return whether to provide a {@link DoorsTestCaseExtension} instance, or not */ protected boolean isApplicable(ImportContext doorsImport, JsonNode content, TrackerLayoutLabelDto discriminatorField, TrackerLayoutLabelDto testStepResultField) { return (discriminatorField == null || discriminatorField.isChoiceField()) && testStepResultField != null && testStepResultField.isTextField(); } Besides the Test Steps, also the following additional Test Case fields can be mapped from child objects:
Even if your DOORS Test Specifications module to import does not have a discriminator attribute, you can still use DoorsTestCaseExtension, as long as you are able to determine the type of objects to import via other means. You only need to override the appropriate DoorsTestCaseExtension type detector method, e.g.
package com.intland.codebeamer.controller.doors; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import com.fasterxml.jackson.databind.JsonNode; import com.intland.codebeamer.controller.doors.DoorsImportController.ImportContext; import com.intland.codebeamer.persistence.dto.TrackerItemDto; import com.intland.codebeamer.persistence.dto.TrackerLayoutLabelDto; import static com.intland.codebeamer.controller.doors.DoorsTestCaseExtension.*; import static com.intland.codebeamer.persistence.dto.TrackerLayoutLabelDto.DESCRIPTION_LABEL_ID; @Component("myPrefixBasedDoorsTestCaseExtensionFactory") public class MyPrefixBasedDoorsTestCaseExtensionFactory extends DoorsTestCaseExtensionFactory { public static final String TEST_CASE_PREFIX = "Test Case: "; public static final String TEST_STEP_PREFIX = "Test Step: "; public MyPrefixBasedDoorsTestCaseExtensionFactory() { super(null, "resultValue", DESCRIPTION_LABEL_ID, PRE_ACTION_FIELD_ID); } @Override protected DoorsTestCaseExtension createDoorsImportExtension(ImportContext doorsImport, JsonNode content, TrackerLayoutLabelDto discriminatorField, TrackerLayoutLabelDto testStepResultField, int... additionalFields) { return new DoorsTestCaseExtension(doorsImport, discriminatorField, testStepResultField, additionalFields) { @Override protected boolean isTestCase(JsonNode object, TrackerItemDto item) { return StringUtils.startsWith(item.getName(), TEST_CASE_PREFIX); } @Override protected boolean isDescription(JsonNode object, TrackerItemDto item) { return StringUtils.startsWith(item.getDescription(), "Purpose: "); } @Override protected boolean isPreAction(JsonNode object, TrackerItemDto item) { return StringUtils.startsWith(item.getDescription(), "Prerequisites: "); } @Override protected boolean isTestStep(JsonNode object, TrackerItemDto item) { return StringUtils.startsWith(item.getDescription(), TEST_STEP_PREFIX); } /** * Remove the Purpose, Prerequisites and Test Step type prefix from the item description * @param item is an imported item representing a Purpose, Prerequisites or Test Step * @return the item description without the type prefix */ @Override protected String getDescription(TrackerItemDto item) { return StringUtils.substringAfter(item.getDescription(), ": "); } /** * Remove the Test Case type prefix from the name of the specified testCase * @param testCase is an imported Test Case item * @param hierarchy is the Test Case child hierarchy */ // @Override // protected void prepareTestCase(TrackerItemDto testCase, TrackerItemDto hierarchy) { // super.prepareTestCase(testCase, hierarchy); // // if (StringUtils.startsWith(testCase.getName(), TEST_CASE_PREFIX)) { // testCase.setName(StringUtils.substringAfter(testCase.getName(), TEST_CASE_PREFIX)); // } // } }; } } Please note, that in the example above we also override getDescription(TrackerItemDto item), to remove the discriminator prefixes from the Test Case description and the Pre-Action and Test Step names. Optionally, you could also override prepareTestCase(TrackerItemDto testCase, TrackerItemDto hierarchy), to also remove the prefix from the Test Case name. |
Fast Links
codebeamer Overview codebeamer Knowledge Base Services by Intland Software |
This website stores cookies on your computer. These cookies are used to improve your browsing experience, constantly optimize the functionality and content of our website, furthermore helps us to understand your interests and provide more personalized services to you, both on this website and through other media. With your permission we and our partners may use precise geolocation data and identification through device scanning. You may click accept to consent to our and our partners’ processing as described above. Please be aware that some processing of your personal data may not require your consent, but you have a right to object to such processing. By using our website, you acknowledge this notice of our cookie practices. By accepting and continuing to browse this site, you agree to this use. For more information about the cookies we use, please visit our Privacy Policy.Your preferences will apply to this website only.