All files / src/objects enhancement_spot.ts

96.22% Statements 51/53
87.5% Branches 14/16
100% Functions 5/5
96.22% Lines 51/53

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 541x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 37x 37x 1x 1x 1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 1x 1x 4x 4x 4x 4x 4x 1x 1x 1x 1x 4x 4x     4x 4x 4x 2x 2x 2x 2x 2x 4x 4x 4x 1x  
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 getAllowedNaming() {
    return {
      maxLength: 30,
      allowNamespace: true,
    };
  }
 
  public setDirty(): void {
    this.badis = undefined;
    super.setDirty();
  }
 
  public listBadiDefinitions(): IBadiDefinition[] {
    if (this.badis === undefined) {
      this.badis = this.parseXML();
    }
    return this.badis;
  }
 
/////////////////
 
  private parseXML(): IBadiDefinition[] {
    const parsed = super.parseRaw2();
    if (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;
  }
}