Skip to content

Commit da60a60

Browse files
committed
Add API to get a specific class in the application.
Signed-off-by: Rahul Krishna <[email protected]>
1 parent 00ca701 commit da60a60

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"homepage": "https://github.com/codellm-devkit/typescript-sdk#readme",
1414
"scripts": {
1515
"build": "bun build ./src/index.ts --outdir ./dist",
16-
"test": "bun test --coverage --coverage-reporter=lcov --preload ./test/conftest.ts --timeout=600000 --verbose",
16+
"test": "bun test --verbose --coverage --coverage-reporter=lcov --preload ./test/conftest.ts --timeout=600000",
1717
"clean": "rm -rf dist coverage *.lock"
1818
},
1919
"files": [

test/unit/analysis/java/JavaAnalysis.test.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,24 @@ test("Must get Symbol Table", async () => {
1717
});
1818

1919
test("Must get all classes in a Java application", async () => {
20-
expect(await daytraderJavaAnalysis.getAllClasses()).toBeDefined();
20+
await expect(daytraderJavaAnalysis.getAllClasses()).toBeDefined();
2121
});
2222

2323
test("Must get a specific class the application", async () => {
2424
const tradeDirectObject = await daytraderJavaAnalysis.getClassByQualifiedName("com.ibm.websphere.samples.daytrader.impl.direct.TradeDirect");
25-
console.log(tradeDirectObject);
2625
expect(async () => JType.parse(tradeDirectObject)).not.toThrow();
2726
});
2827

28+
test("Must throw error when a requested class in the application does not exist", async () => {
29+
/**
30+
* Quick note to self: There is a subtle difference between await expect(...) and expect(await ...)
31+
* When there is an error, the reject happens even before the expect can be honored. So instead, we await the expect
32+
* by saying "Hey, I expect this promise to be rejected with this error ..."
33+
*/
34+
await expect(daytraderJavaAnalysis.getClassByQualifiedName("this.class.does.not.Exist")).rejects.toThrow(
35+
"Class this.class.does.not.Exist not found in the application.");
36+
});
37+
2938
test("Must get all methods in the application", () => {
3039
return daytraderJavaAnalysis.getAllMethods().then((methods) => {
3140
expect(methods).toBeDefined()

0 commit comments

Comments
 (0)