Skip to content
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

feat: send graphql request to update report with coverage data #176

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

AkashKumar7902
Copy link

Related Issue

  • Info about Issue or bug

Closes: keploy/keploy#1735

Describe the changes you've made

A clear and concise description of what you have done to successfully close your assigned issue. Any new files? or anything you feel to let us know!

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Code style update (formatting, local variables)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How did you test your code changes?

Please describe the tests(if any). Provide instructions how its affecting the coverage.

Describe if there is any unusual behaviour of your code(Write NA if there isn't)

A clear and concise description of it.

Checklist:

  • My code follows the style guidelines of this project.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas and used java doc.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have added tests that prove my fix is effective or that my feature works.
  • New and existing unit tests pass locally with my changes.

Screenshots (if any)

Original Updated
original screenshot updated screenshot

@@ -552,6 +551,11 @@ public static void runTests(String jarPath, RunOptions runOptions) {
if (appErr != null) {
throw new AssertionError("error stopping user application: " + appErr);
}

Boolean updateReportResult = udpateReportWithCoverage(testRunId, testSet);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 90).


Boolean updateReportResult = udpateReportWithCoverage(testRunId, testSet);
if (!updateReportResult) {
throw new AssertionError("error updating report with coverage data");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 89).

@@ -805,6 +809,48 @@ public static RunTestSetResult runTestSet(String testRunId, String testSetId, St
}
}

public static Boolean udpateReportWithCoverage(String testRunId, String testSetId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 88).

@@ -805,6 +809,48 @@ public static RunTestSetResult runTestSet(String testRunId, String testSetId, St
}
}

public static Boolean udpateReportWithCoverage(String testRunId, String testSetId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.javadoc.MissingJavadocMethodCheck> reported by reviewdog 🐶
Missing a Javadoc comment.

@@ -805,6 +809,48 @@ public static RunTestSetResult runTestSet(String testRunId, String testSetId, St
}
}

public static Boolean udpateReportWithCoverage(String testRunId, String testSetId) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.FinalParametersCheck> reported by reviewdog 🐶
Parameter testRunId should be final.

int responseCode = conn.getResponseCode();
logger.debug("Status code received: " + responseCode);

if (responseCode >= 200 && responseCode < 300) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck> reported by reviewdog 🐶
'200' is a magic number.

int responseCode = conn.getResponseCode();
logger.debug("Status code received: " + responseCode);

if (responseCode >= 200 && responseCode < 300) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.coding.MagicNumberCheck> reported by reviewdog 🐶
'300' is a magic number.


// Parse the response body using Gson
Gson gson = new Gson();
GraphQLResponse response = gson.fromJson(resBody, GraphQLResponse.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 89).


return true;
} else {
logger.error("Failed to update report with coverage data. Status code: " + responseCode);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 105).

return false;
}
} catch (Exception e) {
logger.error("Error updating report with coverage data: " + e.getMessage(), e);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 91).

Signed-off-by: Akash Kumar <[email protected]>
}

String payload = String.format(
"{\"query\": \"mutation updateReportWithCov{ updateReportWithCov(testRunId: \\\"%s\\\", testSetId: \\\"%s\\\", language: \\\"java\\\") }\"}",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚫 [checkstyle] <com.puppycrawl.tools.checkstyle.checks.sizes.LineLengthCheck> reported by reviewdog 🐶
Line is longer than 80 characters (found 157).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature]: Add code coverage data to keploy test report
1 participant