|
1 | 1 | import { |
2 | 2 | createDataExtensionYaml, |
3 | | - createDataExtensionYamlsPerLibrary, |
| 3 | + createDataExtensionYamlsForApplicationMode, |
| 4 | + createDataExtensionYamlsForFrameworkMode, |
4 | 5 | createFilenameForLibrary, |
5 | 6 | loadDataExtensionYaml, |
6 | 7 | } from "../../../src/data-extensions-editor/yaml"; |
@@ -134,9 +135,9 @@ describe("createDataExtensionYaml", () => { |
134 | 135 | }); |
135 | 136 | }); |
136 | 137 |
|
137 | | -describe("createDataExtensionYamlsPerLibrary", () => { |
| 138 | +describe("createDataExtensionYamlsForApplicationMode", () => { |
138 | 139 | it("creates the correct YAML files", () => { |
139 | | - const yaml = createDataExtensionYamlsPerLibrary( |
| 140 | + const yaml = createDataExtensionYamlsForApplicationMode( |
140 | 141 | "java", |
141 | 142 | [ |
142 | 143 | { |
@@ -341,6 +342,142 @@ describe("createDataExtensionYamlsPerLibrary", () => { |
341 | 342 | }); |
342 | 343 | }); |
343 | 344 |
|
| 345 | +describe("createDataExtensionYamlsForFrameworkMode", () => { |
| 346 | + it("creates the correct YAML files", () => { |
| 347 | + const yaml = createDataExtensionYamlsForFrameworkMode( |
| 348 | + "github/sql2o", |
| 349 | + "java", |
| 350 | + [ |
| 351 | + { |
| 352 | + library: "sql2o", |
| 353 | + signature: "org.sql2o.Connection#createQuery(String)", |
| 354 | + packageName: "org.sql2o", |
| 355 | + typeName: "Connection", |
| 356 | + methodName: "createQuery", |
| 357 | + methodParameters: "(String)", |
| 358 | + supported: true, |
| 359 | + usages: [ |
| 360 | + { |
| 361 | + label: "createQuery(...)", |
| 362 | + url: { |
| 363 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 364 | + startLine: 15, |
| 365 | + startColumn: 13, |
| 366 | + endLine: 15, |
| 367 | + endColumn: 56, |
| 368 | + }, |
| 369 | + }, |
| 370 | + { |
| 371 | + label: "createQuery(...)", |
| 372 | + url: { |
| 373 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 374 | + startLine: 26, |
| 375 | + startColumn: 13, |
| 376 | + endLine: 26, |
| 377 | + endColumn: 39, |
| 378 | + }, |
| 379 | + }, |
| 380 | + ], |
| 381 | + }, |
| 382 | + { |
| 383 | + library: "sql2o", |
| 384 | + signature: "org.sql2o.Query#executeScalar(Class)", |
| 385 | + packageName: "org.sql2o", |
| 386 | + typeName: "Query", |
| 387 | + methodName: "executeScalar", |
| 388 | + methodParameters: "(Class)", |
| 389 | + supported: true, |
| 390 | + usages: [ |
| 391 | + { |
| 392 | + label: "executeScalar(...)", |
| 393 | + url: { |
| 394 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 395 | + startLine: 15, |
| 396 | + startColumn: 13, |
| 397 | + endLine: 15, |
| 398 | + endColumn: 85, |
| 399 | + }, |
| 400 | + }, |
| 401 | + { |
| 402 | + label: "executeScalar(...)", |
| 403 | + url: { |
| 404 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 405 | + startLine: 26, |
| 406 | + startColumn: 13, |
| 407 | + endLine: 26, |
| 408 | + endColumn: 68, |
| 409 | + }, |
| 410 | + }, |
| 411 | + ], |
| 412 | + }, |
| 413 | + { |
| 414 | + library: "sql2o", |
| 415 | + signature: "org.sql2o.Sql2o#Sql2o(String,String,String)", |
| 416 | + packageName: "org.sql2o", |
| 417 | + typeName: "Sql2o", |
| 418 | + methodName: "Sql2o", |
| 419 | + methodParameters: "(String,String,String)", |
| 420 | + supported: false, |
| 421 | + usages: [ |
| 422 | + { |
| 423 | + label: "new Sql2o(...)", |
| 424 | + url: { |
| 425 | + uri: "file:/home/runner/work/sql2o-example/sql2o-example/src/main/java/org/example/HelloController.java", |
| 426 | + startLine: 10, |
| 427 | + startColumn: 33, |
| 428 | + endLine: 10, |
| 429 | + endColumn: 88, |
| 430 | + }, |
| 431 | + }, |
| 432 | + ], |
| 433 | + }, |
| 434 | + ], |
| 435 | + { |
| 436 | + "org.sql2o.Connection#createQuery(String)": { |
| 437 | + type: "sink", |
| 438 | + input: "Argument[0]", |
| 439 | + output: "", |
| 440 | + kind: "sql", |
| 441 | + provenance: "df-generated", |
| 442 | + }, |
| 443 | + "org.sql2o.Sql2o#Sql2o(String,String,String)": { |
| 444 | + type: "sink", |
| 445 | + input: "Argument[0]", |
| 446 | + output: "", |
| 447 | + kind: "jndi", |
| 448 | + provenance: "manual", |
| 449 | + }, |
| 450 | + }, |
| 451 | + ); |
| 452 | + |
| 453 | + expect(yaml).toEqual({ |
| 454 | + "models/sql2o.model.yml": `extensions: |
| 455 | + - addsTo: |
| 456 | + pack: codeql/java-all |
| 457 | + extensible: sourceModel |
| 458 | + data: [] |
| 459 | +
|
| 460 | + - addsTo: |
| 461 | + pack: codeql/java-all |
| 462 | + extensible: sinkModel |
| 463 | + data: |
| 464 | + - ["org.sql2o","Connection",true,"createQuery","(String)","","Argument[0]","sql","df-generated"] |
| 465 | + - ["org.sql2o","Sql2o",true,"Sql2o","(String,String,String)","","Argument[0]","jndi","manual"] |
| 466 | +
|
| 467 | + - addsTo: |
| 468 | + pack: codeql/java-all |
| 469 | + extensible: summaryModel |
| 470 | + data: [] |
| 471 | +
|
| 472 | + - addsTo: |
| 473 | + pack: codeql/java-all |
| 474 | + extensible: neutralModel |
| 475 | + data: [] |
| 476 | +`, |
| 477 | + }); |
| 478 | + }); |
| 479 | +}); |
| 480 | + |
344 | 481 | describe("loadDataExtensionYaml", () => { |
345 | 482 | it("loads the YAML file", () => { |
346 | 483 | const data = loadDataExtensionYaml({ |
|
0 commit comments