Skip to content

Commit

Permalink
Merge pull request #28 from HHS/dev
Browse files Browse the repository at this point in the history
Util 4.2.0
  • Loading branch information
bischoffz authored Jun 5, 2024
2 parents ce9eed6 + 987a5b5 commit 683a690
Show file tree
Hide file tree
Showing 8 changed files with 587 additions and 131 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/dev_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ name: Util Development Build
on:
push:
branches: [ "dev" ]
pull_request:
branches-ignore: ["main"]

jobs:
dev-build:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/dev_pr_build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: Util Development PR Build

on:
pull_request:
branches-ignore: ["main"]

jobs:
dev-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Util
uses: actions/checkout@v4

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build Util
run: mvn clean install --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
# - name: Update dependency graph
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
8 changes: 5 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- Artifact -->
<groupId>gov.hhs.aspr.ms</groupId>
<artifactId>util</artifactId>
<version>4.1.3</version>
<version>4.2.0</version>
<packaging>jar</packaging>

<name>Modeling Utils</name>
Expand Down Expand Up @@ -60,8 +60,8 @@
<flatten-maven-plugin.version>1.6.0</flatten-maven-plugin.version>
<maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.6.3</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.2.2</maven-gpg-plugin.version>
<maven-javadoc-plugin.version>3.7.0</maven-javadoc-plugin.version>
<maven-gpg-plugin.version>3.2.4</maven-gpg-plugin.version>
<central-publishing-maven-plugin.version>0.4.0</central-publishing-maven-plugin.version>

<!-- dependency versions-->
Expand Down Expand Up @@ -173,6 +173,8 @@
<publishingServerId>central</publishingServerId>
<tokenAuth>true</tokenAuth>
<deploymentName>ASPR MS Util</deploymentName>
<autoPublish>true</autoPublish>
<waitUntil>published</waitUntil>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,10 @@ private void probeTestClass(Class<?> c) {
final UnitTestForCoverage unitTestForCoverage = testMethod.getAnnotation(UnitTestForCoverage.class);

int caseIndex = 0;
if (test != null && unitTestForCoverage == null) {
if (test != null ) {
caseIndex += 16;
}
if (unitTestForCoverage == null) {
caseIndex += 8;
}
if (unitTestConstructor != null) {
Expand All @@ -242,8 +245,34 @@ private void probeTestClass(Class<?> c) {
}

switch (caseIndex) {
case 0:
// ignore the method
case 16:
warningContainerBuilder.addMethodWarning(
new MethodWarning(testMethod, WarningType.TEST_ANNOTATION_WITHOUT_UNIT_ANNOTATION));
break;
case 3://fall through
case 5://fall through
case 6://fall through
case 7://fall through
case 9://fall through
case 10://fall through
case 11://fall through
case 12://fall through
case 13://fall through
case 14://fall through
case 15://fall through
case 19://fall through
case 21://fall through
case 22://fall through
case 23://fall through
case 25://fall through
case 26://fall through
case 27://fall through
case 28://fall through
case 29://fall through
case 30://fall through
case 31:
warningContainerBuilder.addMethodWarning(
new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 1:
warningContainerBuilder.addMethodWarning(
Expand All @@ -253,55 +282,30 @@ private void probeTestClass(Class<?> c) {
warningContainerBuilder.addMethodWarning(
new MethodWarning(testMethod, WarningType.UNIT_METHOD_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;
case 3:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;

case 4:
warningContainerBuilder.addMethodWarning(
new MethodWarning(testMethod, WarningType.UNIT_CONSTRUCTOR_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;
case 5:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 6:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 7:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;

case 8:
warningContainerBuilder.addMethodWarning(
new MethodWarning(testMethod, WarningType.TEST_ANNOTATION_WITHOUT_UNIT_ANNOTATION));
new MethodWarning(testMethod, WarningType.UNIT_COVERAGE_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;

case 0://fall through
case 24:
//ignore
break;
case 9:
case 17:
probeFieldTest(testMethod, unitTestField);
break;
case 10:
case 18:
probeMethodTest(testMethod, unitTestMethod);
break;
case 11:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 12:
case 20:
probeConstructorTest(testMethod, unitTestConstructor);
break;
case 13:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 14:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 15:
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;

default:
throw new RuntimeException("unhandled case index " + caseIndex);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public enum WarningType {

SOURCE_CONSTRUCTOR_REQUIRES_TEST("Source constructor requires a test method but does not have one"),

UNIT_COVERAGE_ANNOTATION_WITHOUT_TEST_ANNOTATION(
"Test method is marked with @UnitTestForCoverage but does not have a corresponding @Test annotation"),


UNIT_CONSTRUCTOR_ANNOTATION_WITHOUT_TEST_ANNOTATION(
"Test method is marked with @UnitTestConstructor but does not have a corresponding @Test annotation"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import gov.hhs.aspr.ms.util.errors.ContractError;

public enum ResourceError implements ContractError {
UNKNOWN_FILE("Provided file does not exist");
UNKNOWN_FILE("Provided file does not exist"),
FILE_PATH_IS_DIRECTORY("The provided file path points to a directory and not a file"),
DIRECTORY_PATH_IS_FILE("The provided directory path points to a file and not a directory");

private final String description;

Expand Down
Loading

0 comments on commit 683a690

Please sign in to comment.