All files / src/objects enhancement_spot.ts

88.89% Statements 16/18
66.67% Branches 8/12
83.33% Functions 5/6
88.89% Lines 16/18

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 591x 1x             1x       15x                 1x             2x 2x       2x 2x   2x           2x 2x       2x 2x 2x           2x      
import {AbstractObject} from "./_abstract_object";
import {xmlToArray} from "../xml_utils";
 
export interface IBadiDefinition {
  name: string,
  interface: string,
}
 
export class EnhancementSpot extends AbstractObject {
  private badis: IBadiDefinition[] | undefined;
 
  public getType(): string {
    return "ENHS";
  }
 
  public getDescription(): string | undefined {
    // todo
    return undefined;
  }
 
  public getAllowedNaming() {
    return {
      maxLength: 30,
      allowNamespace: true,
    };
  }
 
  public setDirty(): void {
    this.badis = undefined;
    super.setDirty();
  }
 
  public listBadiDefinitions(): IBadiDefinition[] {
    Eif (this.badis === undefined) {
      this.badis = this.parseXML();
    }
    return this.badis;
  }
 
/////////////////
 
  private parseXML(): IBadiDefinition[] {
    const parsed = super.parseRaw2();
    Iif (parsed === undefined) {
      return [];
    }
 
    const ret: IBadiDefinition[] = [];
    for (const b of xmlToArray(parsed.abapGit["asx:abap"]["asx:values"]?.BADI_DATA?.ENH_BADI_DATA)) {
      ret.push({
        name: b.BADI_NAME,
        interface: b.INTERFACE_NAME,
      });
    }
 
    return ret;
  }
}