All files / src/objects icf_service.ts

95.65% Statements 66/69
84.61% Branches 11/13
85.71% Functions 6/7
95.65% Lines 66/69

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 59 60 61 62 63 64 65 66 67 68 691x 1x 1x 1x 1x 1x 1x 1x 1x 1x 16x 16x 1x 1x 1x 1x 1x 1x 1x 1x 1x 5x 5x 5x 1x 1x       1x 1x 1x 1x 1x 1x 1x 4x 4x 4x 1x 1x 8x 3x 3x 5x 5x 5x 5x 5x 5x 8x 2x 2x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 3x 1x 1x
import {AbstractObject} from "./_abstract_object";
import {xmlToArray} from "../xml_utils";
 
export class ICFService extends AbstractObject {
  private parsedXML: {
    url?: string,
    handlers?: string[] | undefined,
  } | undefined;
 
  public getType(): string {
    return "SICF";
  }
 
  public getAllowedNaming() {
    return { // todo, verify
      maxLength: 100,
      allowNamespace: true,
    };
  }
 
  public setDirty(): void {
    this.parsedXML = undefined;
    super.setDirty();
  }
 
  public getDescription(): string | undefined {
    // todo
    return undefined;
  }
 
  public getURL(): string | undefined {
    this.parse();
    return this.parsedXML?.url;
  }
 
  public getHandlerList(): string[] | undefined {
    this.parse();
    return this.parsedXML?.handlers;
  }
 
  public parse() {
    if (this.parsedXML) {
      return {updated: false, runtime: 0};
    }
 
    const start = Date.now();
    this.parsedXML = {};
    const parsed = super.parseRaw2();
    if (parsed === undefined
        || parsed.abapGit === undefined
        || parsed.abapGit["asx:abap"]["asx:values"] === undefined) {
      return {updated: false, runtime: 0};
    }
 
    const table = parsed.abapGit["asx:abap"]["asx:values"].ICFHANDLER_TABLE;
    this.parsedXML.handlers = [];
    for (const h of xmlToArray(table)) {
      if (h.ICFHANDLER !== undefined) {
        this.parsedXML.handlers.push(h.ICFHANDLER.ICFHANDLER);
      }
    }
 
    this.parsedXML.url = parsed.abapGit["asx:abap"]["asx:values"].URL;
 
    const end = Date.now();
    return {updated: true, runtime: end - start};
  }
 
}