diff --git a/pom.xml b/pom.xml index 75c618a..ddd9065 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ gov.hhs.aspr.ms util - 4.2.0 + 4.2.1 jar Modeling Utils diff --git a/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoGenerator.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoGenerator.java index 05a8ce6..e94eb43 100644 --- a/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoGenerator.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoGenerator.java @@ -221,6 +221,7 @@ 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); @@ -228,10 +229,10 @@ private void probeTestClass(Class c) { 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) { @@ -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( @@ -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); diff --git a/src/main/java/gov/hhs/aspr/ms/util/misc/ColorConsole.java b/src/main/java/gov/hhs/aspr/ms/util/misc/ColorConsole.java new file mode 100644 index 0000000..8f70a4c --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/misc/ColorConsole.java @@ -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; + } + +} diff --git a/src/test/java/gov/hhs/aspr/ms/util/misc/AT_ColorConsole.java b/src/test/java/gov/hhs/aspr/ms/util/misc/AT_ColorConsole.java new file mode 100644 index 0000000..0a10022 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/misc/AT_ColorConsole.java @@ -0,0 +1,266 @@ +package gov.hhs.aspr.ms.util.misc; + +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; + +public class AT_ColorConsole { + + @Test + @UnitTestMethod(target=ColorConsole.class,name="black",args= {}) + public void testBlack() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="black_B",args= {}) + public void testBlack_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="red",args= {}) + public void testRed() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="red_B",args= {}) + public void testRed_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="green",args= {}) + public void testGreen() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="green_B",args= {}) + public void testGreen_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="yellow",args= {}) + public void testYellow() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="yellow_B",args= {}) + public void testYellow_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="blue",args= {}) + public void testBlue() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="blue_B",args= {}) + public void testBlue_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="magenta",args= {}) + public void testMagenta() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="magenta_B",args= {}) + public void testMagenta_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="cyan",args= {}) + public void testCyan() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="cyan_B",args= {}) + public void testCyan_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightGray",args= {}) + public void testLightGray() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightGray_B",args= {}) + public void testLightGray_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="darkGray",args= {}) + public void testDarkGray() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="darkGray_B",args= {}) + public void testDarkGray_B() { + //defer to manual testing + } + + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightRed",args= {}) + public void testLightRed() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightRed_B",args= {}) + public void testLightRed_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightGreen",args= {}) + public void testLightGreen() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightGreen_B",args= {}) + public void testLightGreen_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightYellow",args= {}) + public void testLightYellow() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightYellow_B",args= {}) + public void testLightYellow_B() { + //defer to manual testing + } + + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightBlue",args= {}) + public void testLightBlue() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightBlue_B",args= {}) + public void testLightBlue_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightMagenta",args= {}) + public void testLightMagenta() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightMagenta_B",args= {}) + public void testLightMagenta_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightCyan",args= {}) + public void testLightCyan() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lightCyan_B",args= {}) + public void testLightCyan_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="white",args= {}) + public void testWhite() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="white_B",args= {}) + public void testWhite_B() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="upperCase",args= {}) + public void testUpperCase() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="lowerCase",args= {}) + public void testLowerCase() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="noCase",args= {}) + public void testNoCase() { + //defer to manual testing + } + + + @Test + @UnitTestMethod(target=ColorConsole.class,name="bold",args= {}) + public void testBold() { + //defer to manual testing + } + + + @Test + @UnitTestMethod(target=ColorConsole.class,name="regular",args= {}) + public void testRegular() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="underline",args= {}) + public void testUnderline() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="clearline",args= {}) + public void testClearline() { + //defer to manual testing + } + + + @Test + @UnitTestMethod(target=ColorConsole.class,name="print",args= {String.class}) + public void testPrint() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="println",args= {String.class}) + public void testPrintln() { + //defer to manual testing + } + + @Test + @UnitTestMethod(target=ColorConsole.class,name="reset",args= {}) + public void testReset() { + //defer to manual testing + } + +}