Skip to content

Commit

Permalink
Merge pull request #31 from HHS/bugfix/metainfo-report-generator
Browse files Browse the repository at this point in the history
Bugfix/metainfo report generator
  • Loading branch information
shawnhatch authored Jun 19, 2024
2 parents 7a9b7e1 + 549243d commit 674cc54
Show file tree
Hide file tree
Showing 4 changed files with 563 additions and 31 deletions.
2 changes: 1 addition & 1 deletion 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.2.0</version>
<version>4.2.1</version>
<packaging>jar</packaging>

<name>Modeling Utils</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,17 +221,18 @@ private void probeTestClass(Class<?> c) {

final Method[] methods = c.getMethods();
for (final Method testMethod : methods) {

final Test test = testMethod.getAnnotation(Test.class);
final UnitTestMethod unitTestMethod = testMethod.getAnnotation(UnitTestMethod.class);
final UnitTestConstructor unitTestConstructor = testMethod.getAnnotation(UnitTestConstructor.class);
final UnitTestField unitTestField = testMethod.getAnnotation(UnitTestField.class);
final UnitTestForCoverage unitTestForCoverage = testMethod.getAnnotation(UnitTestForCoverage.class);

int caseIndex = 0;
if (test != null ) {
if (test != null) {
caseIndex += 16;
}
if (unitTestForCoverage == null) {
if (unitTestForCoverage != null) {
caseIndex += 8;
}
if (unitTestConstructor != null) {
Expand All @@ -249,30 +250,30 @@ private void probeTestClass(Class<?> c) {
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 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));
warningContainerBuilder
.addMethodWarning(new MethodWarning(testMethod, WarningType.MULTIPLE_UNIT_ANNOTATIONS_PRESENT));
break;
case 1:
warningContainerBuilder.addMethodWarning(
Expand All @@ -282,20 +283,20 @@ private void probeTestClass(Class<?> c) {
warningContainerBuilder.addMethodWarning(
new MethodWarning(testMethod, WarningType.UNIT_METHOD_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;

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

case 8:
warningContainerBuilder.addMethodWarning(
new MethodWarning(testMethod, WarningType.UNIT_COVERAGE_ANNOTATION_WITHOUT_TEST_ANNOTATION));
break;
case 0://fall through

case 0:// fall through
case 24:
//ignore
// ignore
break;
case 17:
probeFieldTest(testMethod, unitTestField);
Expand Down
265 changes: 265 additions & 0 deletions src/main/java/gov/hhs/aspr/ms/util/misc/ColorConsole.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,265 @@
package gov.hhs.aspr.ms.util.misc;

public class ColorConsole {

private static enum TextCase{
NONE,UPPER,LOWER;
}

private String resetToken = "\u001B[0m";
private String boldToken = "\u001B[1m";
private String underlineToken = "\u001B[4m";

private String textColorToken;
private String backgroundColorToken;
private boolean useBold;
private TextCase textCase = TextCase.NONE;
private boolean useUnderline;

public ColorConsole black() {
textColorToken = "\u001B[30m";
return this;
}

public ColorConsole black_B() {
backgroundColorToken = "\u001B[40m";
return this;
}

public ColorConsole red() {
textColorToken = "\u001B[31m";
return this;
}

public ColorConsole red_B() {
backgroundColorToken = "\u001B[41m";
return this;
}

public ColorConsole green() {
textColorToken = "\u001B[32m";
return this;
}

public ColorConsole green_B() {
backgroundColorToken = "\u001B[42m";
return this;
}

public ColorConsole yellow() {
textColorToken = "\u001B[33m";
return this;
}

public ColorConsole yellow_B() {
backgroundColorToken = "\u001B[43m";
return this;
}

public ColorConsole blue() {
textColorToken = "\u001B[34m";
return this;
}

public ColorConsole blue_B() {
backgroundColorToken = "\u001B[44m";
return this;
}

public ColorConsole magenta() {
textColorToken = "\u001B[35m";
return this;
}

public ColorConsole magenta_B() {
backgroundColorToken = "\u001B[45m";
return this;
}

public ColorConsole cyan() {
textColorToken = "\u001B[36m";
return this;
}

public ColorConsole cyan_B() {
backgroundColorToken = "\u001B[46m";
return this;
}

public ColorConsole lightGray() {
textColorToken = "\u001B[37m";
return this;
}

public ColorConsole lightGray_B() {
backgroundColorToken = "\u001B[47m";
return this;
}

public ColorConsole darkGray() {
textColorToken = "\u001B[90m";
return this;
}

public ColorConsole darkGray_B() {
backgroundColorToken = "\u001B[100m";
return this;
}

public ColorConsole lightRed() {
textColorToken = "\u001B[91m";
return this;
}

public ColorConsole lightRed_B() {
backgroundColorToken = "\u001B[101m";
return this;
}

public ColorConsole lightGreen() {
textColorToken = "\u001B[92m";
return this;
}

public ColorConsole lightGreen_B() {
backgroundColorToken = "\u001B[102m";
return this;
}

public ColorConsole lightYellow() {
textColorToken = "\u001B[93m";
return this;
}

public ColorConsole lightYellow_B() {
backgroundColorToken = "\u001B[103m";
return this;
}

public ColorConsole lightBlue() {
textColorToken = "\u001B[94m";
return this;
}

public ColorConsole lightBlue_B() {
backgroundColorToken = "\u001B[104m";
return this;
}

public ColorConsole lightMagenta() {
textColorToken = "\u001B[95m";
return this;
}

public ColorConsole lightMagenta_B() {
backgroundColorToken = "\u001B[105m";
return this;
}

public ColorConsole lightCyan() {
textColorToken = "\u001B[96m";
return this;
}

public ColorConsole lightCyan_B() {
backgroundColorToken = "\u001B[106m";
return this;
}

public ColorConsole white() {
textColorToken = "\u001B[97m";
return this;
}

public ColorConsole white_B() {
backgroundColorToken = "\u001B[107m";
return this;
}

public ColorConsole upperCase() {
this.textCase = TextCase.UPPER;
return this;
}

public ColorConsole lowerCase() {
this.textCase = TextCase.LOWER;
return this;
}

public ColorConsole noCase() {
this.textCase = TextCase.NONE;
return this;
}

public ColorConsole bold() {
this.useBold = true;
return this;
}

public ColorConsole regular() {
this.useBold = false;
return this;
}

public ColorConsole underline() {
this.useUnderline = true;
return this;
}

public ColorConsole clearline() {
this.useUnderline = true;
return this;
}


private String constructDecoratedString(String message) {
StringBuilder sb = new StringBuilder();
if (useBold) {
sb.append(boldToken);
}
if (useUnderline) {
sb.append(underlineToken);
}
if (textColorToken != null) {
sb.append(textColorToken);
}
if (backgroundColorToken != null) {
sb.append(backgroundColorToken);
}
switch(textCase) {
case LOWER:
sb.append(message.toLowerCase());
break;
case UPPER:
sb.append(message.toUpperCase());
break;
default:
sb.append(message);
break;

}

sb.append(resetToken);
return sb.toString();
}

public ColorConsole print(String message) {
System.out.print(constructDecoratedString(message));
return this;
}

public ColorConsole println(String message) {
System.out.println(constructDecoratedString(message));
return this;
}

public ColorConsole reset() {
backgroundColorToken = null;
textColorToken = null;
useBold = false;
useUnderline = false;
textCase = TextCase.NONE;
return this;
}

}
Loading

0 comments on commit 674cc54

Please sign in to comment.