-
Notifications
You must be signed in to change notification settings - Fork 10
Issue 100 capture database entries #110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
… test and/or resources folder only within project directory. Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
…avaEE and Jakarta Persistence API. Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
… the crud operations that occur in it as an array list. Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
… the crud operations and queries that occur in it as an array list. Also updated the test case to capture this. Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
… the crud operations and queries that occur in it as an array list. Also updated the test case to capture this. Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
I have also made it so that we can get the crud operations easily directly form package com.ibm.cldk;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Assertions;
import org.testcontainers.containers.BindMode;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.MountableFile;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.file.Paths;
import java.util.Properties;
@Testcontainers
@SuppressWarnings("resource")
public class CodeAnalyzerIntegrationTest {
// ...
@Test
void shouldBeAbleToDetectCRUDOperationsAndQueriesForPlantByWebsphere() throws Exception {
var runCodeAnalyzerOnPlantsByWebsphere = container.execInContainer(
"java",
"-jar",
String.format("/opt/jars/codeanalyzer-%s.jar", codeanalyzerVersion),
"--input=/test-applications/plantsbywebsphere",
"--analysis-level=1", "--verbose"
);
Assertions.assertTrue(runCodeAnalyzerOnPlantsByWebsphere.getStdout().contains("\"query_type\": \"NAMED\""), "No entry point classes found");
Assertions.assertTrue(runCodeAnalyzerOnPlantsByWebsphere.getStdout().contains("\"operation_type\": \"READ\""), "No entry point methods found");
Assertions.assertTrue(runCodeAnalyzerOnPlantsByWebsphere.getStdout().contains("\"operation_type\": \"UPDATE\""), "No entry point methods found");
Assertions.assertTrue(runCodeAnalyzerOnPlantsByWebsphere.getStdout().contains("\"operation_type\": \"CREATE\""), "No entry point methods found");
// Convert the expected JSON structure into a string
String expectedCrudOperation =
"\"crud_operations\": [" +
"{" +
"\"line_number\": 115," +
"\"operation_type\": \"READ\"," +
"\"target_table\": null," +
"\"involved_fields\": null," +
"\"condition\": null," +
"\"joined_tables\": null," +
"\"technology\": null," +
"\"is_batch_operation\": false" +
"}]";
// Expected JSON for CRUD Queries
String expectedCrudQuery =
"\"crud_queries\": [" +
"{" +
"\"line_number\": 141,";
// Normalize the output and expected strings to ignore formatting differences
String normalizedOutput = output.replaceAll("\\s+", "");
String normalizedExpectedCrudOperation = expectedCrudOperation.replaceAll("\\s+", "");
String normalizedExpectedCrudQuery = expectedCrudQuery.replaceAll("\\s+", "");
// Assertions for both CRUD operations and queries
Assertions.assertTrue(normalizedOutput.contains(normalizedExpectedCrudOperation), "Expected CRUD operation JSON structure not found");
Assertions.assertTrue(normalizedOutput.contains(normalizedExpectedCrudQuery), "Expected CRUD query JSON structure not found");
}
} |
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
sinha108
approved these changes
Feb 11, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation and Context
We now support the following frameworks
How Has This Been Tested?
We have added a new test case to our integration testing suite and we have verified that it runs on plantsbywebsphere
Breaking Changes
Yes.
analysis.json
has new fields, so cldk'spython-sdk
will break if this new version of codeanalyzer-2.2.0-dev is used.Types of changes
Checklist
Additional context
A number of new interfaces and enums were added, some of them will be backported to refactor the entrypoint detection offered in v2.1.0 of codeanalyzer.