Specification for V3BiStakeholderBase
Attributes
| Attribute | Type | Description |
|---|---|---|
reference | string | Unique identifier for the stakeholder |
description | V3BiTranslationBase[] | Array of translations describing the stakeholder in different languages |
influencedBy | V3BiInfluenceBase[] | Array of influences that affect the stakeholder, optional, defaults to an empty array |
Methods
| Method | Description |
|---|---|
constructor | Initializes a new instance of V3BiStakeholderBase with the provided reference, description, and optionally influencedBy array. Defaults influencedBy to an empty array if not provided. |
getStakeholder | Returns the stakeholder description in the specified language, or ‘unknown stakeholder description’ if the translation is not found. |
Constructor
Signature:
constructor(reference: string, description: V3BiTranslationBase[], influencedBy?: V3BiInfluenceBase[])
Parameters:
reference(string): Unique identifier for the stakeholder.description(V3BiTranslationBase[]): Array of translations describing the stakeholder.influencedBy(V3BiInfluenceBase[], optional): Array of influences that affect the stakeholder.
Description:
The constructor initializes the V3BiStakeholderBase instance with the provided reference, description, and optionally influencedBy. If influencedBy is not provided, it defaults to an empty array.
Method: getStakeholder
Signature:
getStakeholder(language: string): string
Parameters:
language(string): The language code for which the stakeholder description is requested.
Description:
Returns the stakeholder description in the specified language, or ‘unknown stakeholder description’ if the translation is not found.
Example Usage
const translations = [
new V3BiTranslationBase('en', 'Stakeholder description in English'),
new V3BiTranslationBase('es', 'Descripción del stakeholder en español')
];
const influences = [
new V3BiInfluenceBase('influence1'),
new V3BiInfluenceBase('influence2')
];
const stakeholder = new V3BiStakeholderBase('stakeholder1', translations, influences);
console.log(stakeholder.getStakeholder('en')); // Output: Stakeholder description in English
console.log(stakeholder.getStakeholder('fr')); // Output: unknown stakeholder description
Scenario Table
| Scenario | Given | When | Then |
|---|---|---|---|
| Create an instance with all attributes | The reference is 'stakeholder1', description is a valid array, and influencedBy is a valid array | I create a new V3BiStakeholderBase with reference, description, and influencedBy | The instance should be created with the specified attributes |
Create an instance with an empty influencedBy array | The reference is 'stakeholder2' and description is a valid array | I create a new V3BiStakeholderBase with reference and description | The instance should be created with influencedBy as an empty array |
| Return the correct stakeholder description for a language | The reference is 'stakeholder3' and description is a valid array | I call getStakeholder with a valid language code | The correct stakeholder description for the given language should be returned |
| Return “unknown stakeholder description” if the language does not exist | The reference is 'stakeholder4' and description is a valid array | I call getStakeholder with an invalid language code | The message ‘unknown stakeholder description’ should be returned |
Handle empty influencedBy array | The reference is 'stakeholder5', description is a valid array, and influencedBy is an empty array | I create a new V3BiStakeholderBase with reference, description, and an empty influencedBy | The instance should be created with influencedBy as an empty array and the description and reference should be as provided |