diff --git a/README.md b/README.md index 2d20a589..e4fe6eb3 100644 --- a/README.md +++ b/README.md @@ -8,8 +8,34 @@ TODO PROTOTYPE: * enum status -TODO MVP: -* secure secrets (env vars ok, expiring tokens better) -* db migration tool (flyway) -* tests for uniqueness constraints all tables +Roadmaps +V0.0 (MVP) +GOAL: publish data for jive api test, report as json +* [3] e2e manual test working locally +* [2] provision nonprod db with access to credentials +* [2] use to publish data for jive api test +* [1] use hard-coded key (committed) to encode secrets so not plain text +* [2] publish docker image for server +* [1] publish java client as jar using github package https://blog.dipien. +* [3] misc testing / cleanupcom/how-to-publish-your-internal-artifacts-to-github-packages-5447e7e82e80 + +Est total: for mvp 14 points + +V0.1 (Phase 1 rollout) +GOAL: html report, documentation explaining value proposition and usage * Documentation explaining value proposition and usage +* render html report from json (manual strings or rocker templating engine) +* secure db credentials using vault or aws + +v0.2 (Phase 2 maintenance) +* retention cleanup (default 90 days for main/master/develop branch, 30 days for feature branch) +* admin user + +v0.3 (Configuration) +* retention configuration (specify global default retention duration and allow override duration for branches) +* api for roles and permissions +* tokens? + +Nice to have for later versions +* see if we can distinguish between different failure reasons for the same test to assign a similarity score to failures so we can see if failing for multiple reasons. +** test reports run over a fixed time period. Failures can be partioned by percent with same similarity (e.g. 90% for text A, 10% for text B) diff --git a/gradle.properties b/gradle.properties index 707f52df..df22b96e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,4 @@ springBootVersion = 2.4.5 -springDependencyVersion = 1.0.10.RELEASE \ No newline at end of file +springDependencyVersion = 1.0.10.RELEASE +lombokVersion = 1.18.20 +jakartaVersion = '2.3.3' \ No newline at end of file diff --git a/reportcard-client/build.gradle b/reportcard-client/build.gradle index b8a02f25..3f470e65 100644 --- a/reportcard-client/build.gradle +++ b/reportcard-client/build.gradle @@ -27,13 +27,6 @@ dependencies { implementation group: 'commons-io', name: 'commons-io', version: '2.8.0' implementation 'org.springframework.boot:spring-boot-starter-webflux' -// implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" -// implementation "com.squareup.okhttp3:logging-interceptor:$okHttpVersion" -// runtime 'org.slf4j:jul-to-slf4j:1.7.30' -} - -tasks.withType(Test) { - useJUnitPlatform() } sourceSets { diff --git a/reportcard-client/src/main/java/com/ericdriggs/reportcard/client/ClientApplication.java b/reportcard-client/src/main/java/com/ericdriggs/reportcard/client/ClientApplication.java index 1b33f796..a84fb5f1 100644 --- a/reportcard-client/src/main/java/com/ericdriggs/reportcard/client/ClientApplication.java +++ b/reportcard-client/src/main/java/com/ericdriggs/reportcard/client/ClientApplication.java @@ -1,12 +1,18 @@ package com.ericdriggs.reportcard.client; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.boot.ApplicationArguments; import org.springframework.boot.ApplicationRunner; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import reactor.core.publisher.Mono; + +import java.util.List; @SpringBootApplication public class ClientApplication implements ApplicationRunner { + private static Logger log = LoggerFactory.getLogger(ClientApplication.class); public static void main(String[] args) { SpringApplication.run(ClientApplication.class, args); @@ -15,20 +21,21 @@ public static void main(String[] args) { @Override public void run(ApplicationArguments args) { - //FIXME: either don't log args or mask password - System.out.println("# NonOptionArgs: " + args.getNonOptionArgs().size()); + //TODO: either don't log args or mask password(s) + log.info("# NonOptionArgs: " + args.getNonOptionArgs().size()); - System.out.println("NonOptionArgs:"); + log.info("NonOptionArgs:"); args.getNonOptionArgs().forEach(System.out::println); - System.out.println("# OptionArgs: " + args.getOptionNames().size()); - System.out.println("OptionArgs:"); + log.info("# OptionArgs: " + args.getOptionNames().size()); + log.info("OptionArgs:"); args.getOptionNames().forEach(optionName -> System.out.println(optionName + "=" + args.getOptionValues(optionName))); - PostRequest scannerPostRequest = ClientProperties.getReportPostPayload(args); - - - + PostRequest postRequest = ClientProperties.getReportPostPayload(args); + Mono postResultMono = PostWebClient.INSTANCE.postTestReport(postRequest); + String postResult = postResultMono.block(); + log.info("postResult:\n " + postResult); } + } \ No newline at end of file diff --git a/reportcard-model/build.gradle b/reportcard-model/build.gradle new file mode 100644 index 00000000..09a3f9ae --- /dev/null +++ b/reportcard-model/build.gradle @@ -0,0 +1,46 @@ +buildscript { + ext { + jakartaVersion = '2.3.3' + lombokVersion = '1.18.20' + jacksonVersion = '2.13.2' + junitVersion = '5.7.1' + } +} + +plugins { + id 'java' + id 'groovy' + id 'idea' +} + +configurations { + compileOnly { + extendsFrom annotationProcessor + } +} + +repositories { + mavenLocal() + mavenCentral() + jcenter() +} + +dependencies { + //Lombok + implementation "org.projectlombok:lombok:${lombokVersion}" + annotationProcessor "org.projectlombok:lombok:${lombokVersion}" + + //JSON + implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}" + + //XML + compile "jakarta.xml.bind:jakarta.xml.bind-api:${jakartaVersion}" + runtime "com.sun.xml.bind:jaxb-impl:${jakartaVersion}" + + //Mapping + implementation 'org.modelmapper:modelmapper:2.3.0' + + //Test + testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" + testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${junitVersion}" +} \ No newline at end of file diff --git a/reportcard-model/lombok.config b/reportcard-model/lombok.config new file mode 100644 index 00000000..2fd6dba9 --- /dev/null +++ b/reportcard-model/lombok.config @@ -0,0 +1,5 @@ +# This file is generated by the 'io.freefair.lombok' Gradle plugin +config.stopBubbling = true +lombok.addLombokGeneratedAnnotation = true +lombok.accessors.chain = true +lombok.equalsAndHashCode.callSuper = call \ No newline at end of file diff --git a/reportcard-model/src/main/java/com/ericdriggs/file/FileUtils.java b/reportcard-model/src/main/java/com/ericdriggs/file/FileUtils.java new file mode 100644 index 00000000..d4067431 --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/file/FileUtils.java @@ -0,0 +1,64 @@ +package com.ericdriggs.file; + +import lombok.SneakyThrows; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +public class FileUtils { + + public static String absolutePathFromRelativePath (String relativePath) { + return Path.of(Path.of("").toString(), relativePath).toAbsolutePath().toString(); + } + + public static String regexForExtension (String fileNameExtension) { + return ".*[.]" + fileNameExtension; + } + + public static List fileContentsFromPathAndRegex(String absolutePath, String fileNameRegex) { + List absolutePaths = filePathsForPathAndRegex(absolutePath, fileNameRegex); + return fileContentsFromPaths(absolutePaths); + } + + + public static List fileContentsFromPaths(List absolutePaths) { + List fileContents = new ArrayList<>(); + for ( String absolutePath : absolutePaths) { + fileContents.add(stringFromPath(absolutePath)); + } + return fileContents; + } + + + @SneakyThrows(IOException.class) + public static List filePathsForPathAndRegex(String absolutePath, String fileNameRegex) { + Path dirPath = Path.of(absolutePath); + + //not recursive + final int maxDepth = 1; + + try (Stream walk = Files.find( + dirPath, + maxDepth, + (path, basicFileAttributes) -> path.toFile().getName().matches(fileNameRegex))) { + + List result = walk.filter(Files::isRegularFile) + .map(x -> x.toAbsolutePath().toString()) + .collect(Collectors.toList()); + return result; + } + } + + @SneakyThrows(IOException.class) + public static String stringFromPath(String absolutePath) { + return Files.readString(Path.of(absolutePath)); + } + + + +} diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/ResultParserUtil.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/ResultParserUtil.java new file mode 100644 index 00000000..4a0acbef --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/ResultParserUtil.java @@ -0,0 +1,23 @@ +package com.ericdriggs.reportcard.model; + +import com.ericdriggs.reportcard.model.converter.surefire.SurefireConvertersUtil; +import com.ericdriggs.reportcard.xml.surefire.SurefireParserUtil; +import com.ericdriggs.reportcard.xml.surefire.Testsuite; + +import java.util.List; + +public enum ResultParserUtil { + + ;//static methods only + private static final String XML_EXTENSION_REGEX = ".*[.]xml"; + + public static TestResult fromSurefirePath(String absolutePath) { + return fromSurefirePathAndRegex(absolutePath, XML_EXTENSION_REGEX); + } + + + public static TestResult fromSurefirePathAndRegex(String absolutePath, String fileNameRegex) { + List testsuites = SurefireParserUtil.parseTestSuitesFromPathAndRegex(absolutePath, fileNameRegex); + return SurefireConvertersUtil.doFromSurefireToModelTestResult(testsuites); + } +} \ No newline at end of file diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestCase.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestCase.java similarity index 75% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestCase.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestCase.java index cf8ccdb4..53a533fa 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestCase.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestCase.java @@ -1,7 +1,8 @@ package com.ericdriggs.reportcard.model; -public class TestCase extends com.ericdriggs.reportcard.gen.db.tables.pojos.TestCase { +import com.ericdriggs.reportcard.xml.ResultCount; +public class TestCase extends com.ericdriggs.reportcard.pojos.TestCase { private TestStatus testStatus; public TestCase setTestStatus(TestStatus testStatus) { @@ -22,4 +23,8 @@ public TestStatus getTestStatus() { } return testStatus; } + + public ResultCount getResultCount() { + return testStatus.getResultCount(); + } } diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestResult.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestResult.java similarity index 81% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestResult.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestResult.java index b6288bc8..b607b202 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestResult.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestResult.java @@ -1,5 +1,6 @@ package com.ericdriggs.reportcard.model; +import com.ericdriggs.reportcard.xml.ResultCount; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -8,8 +9,8 @@ import java.util.Map; import java.util.Objects; -public class TestResult extends com.ericdriggs.reportcard.gen.db.tables.pojos.TestResult { - private List testSuites = new ArrayList<>(); +public class TestResult extends com.ericdriggs.reportcard.pojos.TestResult { + private List testSuites = new ArrayList<>(); public List getTestSuites() { return testSuites; @@ -71,4 +72,12 @@ protected String getExternalLinksJson(Map externalLinksMap) { } } + public ResultCount getResultCount() { + ResultCount resultCount = new ResultCount(); + for (TestSuite testSuite : testSuites) { + ResultCount testSuiteResultCount = testSuite.getResultCount(); + resultCount.add(resultCount); + } + return resultCount; + } } diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestStatus.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestStatus.java similarity index 90% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestStatus.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestStatus.java index be4420fe..6ae216bc 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestStatus.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestStatus.java @@ -1,5 +1,7 @@ package com.ericdriggs.reportcard.model; +import com.ericdriggs.reportcard.xml.ResultCount; + import java.util.HashMap; import java.util.Map; @@ -51,4 +53,7 @@ public static TestStatus fromStatusId(int statusId) { return testStatus; } + public ResultCount getResultCount() { + return this.getTestStatusType().getResultCount(); + } } diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestStatusType.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestStatusType.java new file mode 100644 index 00000000..eba8a9dd --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestStatusType.java @@ -0,0 +1,20 @@ +package com.ericdriggs.reportcard.model; + +import com.ericdriggs.reportcard.xml.ResultCount; + +public enum TestStatusType { + SUCCESS(new ResultCount().setTests(1).setSuccesses(1)), + SKIPPED(new ResultCount().setTests(1).setSkipped(1)), + FAILURE(new ResultCount().setTests(1).setFailures(1)), + ERROR(new ResultCount().setTests(1).setErrors(1)); + + private ResultCount resultCount; + + TestStatusType(ResultCount resultCount) { + this.resultCount = resultCount; + } + + public ResultCount getResultCount() { + return resultCount; + } +} diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestSuite.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestSuite.java new file mode 100644 index 00000000..757bc104 --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/TestSuite.java @@ -0,0 +1,35 @@ +package com.ericdriggs.reportcard.model; + +import com.ericdriggs.reportcard.xml.ResultCount; +import java.util.ArrayList; +import java.util.List; + +public class TestSuite extends com.ericdriggs.reportcard.pojos.TestSuite { + private List testCases = new ArrayList<>(); + + public List getTestCases() { + return testCases; + } + + public TestSuite setTestCases( List testCases) { + this.testCases = testCases; + return this; + } + + + public ResultCount getResultCount() { + ResultCount resultCount = new ResultCount(); + for(TestCase testCase : testCases) { + resultCount.add(testCase.getResultCount()); + } + return resultCount; + } + + public static ResultCount getResultCount(List testSuites) { + ResultCount resultCount = new ResultCount(); + for (TestSuite testSuite : testSuites) { + resultCount.add(testSuite.getResultCount()); + } + return resultCount; + } +} diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/converter/junit/JunitConvertersUtil.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/converter/junit/JunitConvertersUtil.java similarity index 87% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/converter/junit/JunitConvertersUtil.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/model/converter/junit/JunitConvertersUtil.java index 0cce1bfd..01de58d3 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/converter/junit/JunitConvertersUtil.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/converter/junit/JunitConvertersUtil.java @@ -18,25 +18,25 @@ public class JunitConvertersUtil { public final static Converter fromJunitToModelTestCase = new AbstractConverter() { - protected com.ericdriggs.reportcard.model.TestCase convert(com.ericdriggs.reportcard.xml.junit.Testcase source) { + protected TestCase convert(com.ericdriggs.reportcard.xml.junit.Testcase source) { return doFromJunitToModelTestCase(source); } }; public final static Converter fromJunitToModelTestSuite = new AbstractConverter() { - protected com.ericdriggs.reportcard.model.TestSuite convert(com.ericdriggs.reportcard.xml.junit.Testsuite source) { + protected TestSuite convert(com.ericdriggs.reportcard.xml.junit.Testsuite source) { return doFromJunitToModelTestSuite(source); } }; public final static Converter fromJunitToModelTestResult = new AbstractConverter() { - protected com.ericdriggs.reportcard.model.TestResult convert(com.ericdriggs.reportcard.xml.junit.Testsuites source) { + protected TestResult convert(com.ericdriggs.reportcard.xml.junit.Testsuites source) { return doFromJunitToModelTestResult(source); } }; public static TestCase doFromJunitToModelTestCase(Testcase source) { - com.ericdriggs.reportcard.model.TestCase modelTestCase = new com.ericdriggs.reportcard.model.TestCase(); + TestCase modelTestCase = new TestCase(); modelTestCase.setName(source.getName()); modelTestCase.setClassName(source.getClassname()); modelTestCase.setTime(source.getTime()); @@ -74,7 +74,7 @@ public static List doFromJunitToModelTestSuites(Testsuites source) { } public static TestSuite doFromJunitToModelTestSuite(Testsuite source) { - com.ericdriggs.reportcard.model.TestSuite modelTestSuite = new com.ericdriggs.reportcard.model.TestSuite(); + TestSuite modelTestSuite = new TestSuite(); modelTestSuite.setError(source.getErrors()); if (modelTestSuite.getError() == null) { modelTestSuite.setError(0); @@ -107,7 +107,7 @@ public static TestSuite doFromJunitToModelTestSuite(Testsuite source) { } public static TestResult doFromJunitToModelTestResult(Testsuites sources) { - com.ericdriggs.reportcard.model.TestResult modelTestResult = new com.ericdriggs.reportcard.model.TestResult(); + TestResult modelTestResult = new TestResult(); modelTestResult.setTestSuites(doFromJunitToModelTestSuites(sources)); modelTestResult.setTests(0); modelTestResult.setSkipped(0); diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireConvertersUtil.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireConvertersUtil.java similarity index 86% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireConvertersUtil.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireConvertersUtil.java index 28bdc247..3b55ca8f 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireConvertersUtil.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireConvertersUtil.java @@ -18,19 +18,19 @@ public class SurefireConvertersUtil { public final static Converter fromSurefireToModelTestCase = new AbstractConverter() { - protected com.ericdriggs.reportcard.model.TestCase convert(com.ericdriggs.reportcard.xml.surefire.Testcase source) { + protected TestCase convert(com.ericdriggs.reportcard.xml.surefire.Testcase source) { return doFromSurefireToModelTestCase(source); } }; public final static Converter fromSurefireToModelTestSuite = new AbstractConverter() { - protected com.ericdriggs.reportcard.model.TestSuite convert(com.ericdriggs.reportcard.xml.surefire.Testsuite source) { + protected TestSuite convert(com.ericdriggs.reportcard.xml.surefire.Testsuite source) { return doFromSurefireToModelTestSuite(source); } }; public final static Converter, TestResult> fromSurefireToModelTestResult = new AbstractConverter, TestResult>() { - protected com.ericdriggs.reportcard.model.TestResult convert(Collection source) { + protected TestResult convert(Collection source) { return doFromSurefireToModelTestResult(source); } }; @@ -44,7 +44,7 @@ public static List doFromSurefireToModelTestCases(List sourc } public static TestCase doFromSurefireToModelTestCase(Testcase source) { - com.ericdriggs.reportcard.model.TestCase modelTestCase = new com.ericdriggs.reportcard.model.TestCase(); + TestCase modelTestCase = new TestCase(); modelTestCase.setName(source.getName()); modelTestCase.setClassName(source.getClassname()); modelTestCase.setTime(new BigDecimal(source.getTime())); @@ -70,7 +70,7 @@ public static List doFromSurefireToModelTestSuites(Collection sources) { - com.ericdriggs.reportcard.model.TestResult modelTestResult = new com.ericdriggs.reportcard.model.TestResult(); + TestResult modelTestResult = new TestResult(); modelTestResult.setTestSuites(doFromSurefireToModelTestSuites(sources)); modelTestResult.setTests(0); modelTestResult.setSkipped(0); @@ -112,6 +112,7 @@ public static TestResult doFromSurefireToModelTestResult(Collection s modelTestResult.setError(0); modelTestResult.setTime(BigDecimal.ZERO); + boolean hasSkip = false; for (TestSuite testSuite : modelTestResult.getTestSuites()) { modelTestResult.setTime(modelTestResult.getTime().add(testSuite.getTime())); modelTestResult.setTests(modelTestResult.getTests() + testSuite.getTests()); @@ -119,6 +120,20 @@ public static TestResult doFromSurefireToModelTestResult(Collection s modelTestResult.setFailure(modelTestResult.getFailure() + testSuite.getFailure()); modelTestResult.setError(modelTestResult.getError() + testSuite.getError()); } + + if (modelTestResult.getSkipped() > 0) { + modelTestResult.setHasSkip(true); + } else { + modelTestResult.setHasSkip(false); + } + + if (modelTestResult.getFailure() > 0 || modelTestResult.getError() > 0) { + modelTestResult.setIsSuccess(false); + } + else { + modelTestResult.setIsSuccess(true); + } + return modelTestResult; } diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestCase.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestCase.java new file mode 100644 index 00000000..a98823ab --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestCase.java @@ -0,0 +1,23 @@ +/* + * This file is generated by jOOQ. + */ +package com.ericdriggs.reportcard.pojos; + + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class TestCase implements Serializable { + + private static final long serialVersionUID = -3938894842199056311L; + + private Long testCaseId; + private Long testSuiteFk; + private String name; + private String className; + private BigDecimal time; + private Byte testStatusFk; +} diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestResult.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestResult.java new file mode 100644 index 00000000..6a43f587 --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestResult.java @@ -0,0 +1,30 @@ +/* + * This file is generated by jOOQ. + */ +package com.ericdriggs.reportcard.pojos; + + +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.time.LocalDateTime; + + +@Data +public class TestResult implements Serializable { + + private static final long serialVersionUID = -4496620756225217991L; + + private Long testResultId; + private Long stageFk; + private Integer tests; + private Integer skipped; + private Integer error; + private Integer failure; + private BigDecimal time; + private LocalDateTime testResultCreated; + private Boolean isSuccess; + private Boolean hasSkip; + private String externalLinks; +} diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestStatus.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestStatus.java new file mode 100644 index 00000000..ce92d894 --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestStatus.java @@ -0,0 +1,17 @@ +/* + * This file is generated by jOOQ. + */ +package com.ericdriggs.reportcard.pojos; + +import lombok.Data; + +import java.io.Serializable; + +@Data +public class TestStatus implements Serializable { + + private static final long serialVersionUID = -5636574208624624202L; + + private Byte testStatusId; + private String testStatusName; +} diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestSuite.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestSuite.java new file mode 100644 index 00000000..c5ef4da0 --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/pojos/TestSuite.java @@ -0,0 +1,41 @@ +/* + * This file is generated by jOOQ. + */ +package com.ericdriggs.reportcard.pojos; + + +import lombok.Data; +import lombok.experimental.Accessors; + +import javax.annotation.processing.Generated; +import java.io.Serializable; +import java.math.BigDecimal; + +@Data +public class TestSuite implements Serializable { + + private static final long serialVersionUID = -200588524670176256L; + + private Long testSuiteId; + private Long testResultFk; + private Integer tests; + private Integer skipped; + private Integer error; + private Integer failure; + private BigDecimal time; + private String package_; + private String group; + private String properties; + private Boolean isSuccess; + private Boolean hasSkip; + + public String getPackage() { + return package_; + } + + public TestSuite setPackage(String package_) { + this.package_ = package_; + return this; + } +} + diff --git a/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/ResultCount.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/ResultCount.java new file mode 100644 index 00000000..cb62117d --- /dev/null +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/ResultCount.java @@ -0,0 +1,121 @@ +package com.ericdriggs.reportcard.xml; + +import lombok.Data; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.List; + +@Data +public class ResultCount { + /** + * tests="3" skipped="1" failures="0" errors="0" + */ + + private Integer errors; + private Integer failures; + private Integer skipped; + private Integer successes; + private Integer tests; + private BigDecimal time; + + /** + * Sums the fields of a resultCount + * + * @param that a ResultCount + * @return a new ResultCount sum of this and that + */ + public ResultCount add(ResultCount that) { + ResultCount resultCount = new ResultCount(); + resultCount.setErrors(addIntegers(this.getErrors(), that.getErrors())); + resultCount.setFailures(addIntegers(this.getFailures(), that.getFailures())); + resultCount.setSkipped(addIntegers(this.getSkipped(), that.getSkipped())); + resultCount.setSuccesses(addIntegers(this.getSuccesses(), that.getSuccesses())); + resultCount.setTests(addIntegers(this.getTests(), that.getTests())); + resultCount.setTime(addBigDecimal(this.getTime(), that.getTime())); + return resultCount; + } + + public static ResultCount aggregate(List resultCounts) { + ResultCount resultCount = new ResultCount(); + for (ResultCount r : resultCounts) { + resultCount = resultCount.add(r); + } + return resultCount; + } + + /** + * @return percent of tests which passed (skipped tests are excluded from total) + */ + public BigDecimal getPassedPercent() { + + final Integer passedCount = getPassedCount(); + final Integer failureErrorsTotal = getFailuresCount() + getErrorsCount(); + return BigDecimal.valueOf( + (100 * passedCount.doubleValue()) / + (passedCount.doubleValue() + failureErrorsTotal.doubleValue()) + ).setScale(2, RoundingMode.HALF_UP); + } + + public Integer getErrorsCount() { + return zeroIfNull(errors); + } + + public Integer getFailuresCount() { + return zeroIfNull(failures); + } + + public Integer getSkippedCount() { + return zeroIfNull(skipped); + } + + public Integer getTestsCount() { + return zeroIfNull(tests); + } + + public Integer getPassedCount() { + return getTestsCount() - getErrorsCount() - getFailuresCount() - getSkippedCount(); + } + + protected Integer zeroIfNull(Integer integer) { + if (integer == null) { + return 0; + } + return integer; + } + + /** + * Adds two Integers + * + * @param thiz an Integer, may be null + * @param that an Integer, may be null + * @return an Integer sum of thiz and that, may be 0 but never null + */ + private static Integer addIntegers(Integer thiz, Integer that) { + if (thiz == null) { + thiz = 0; + }if (that == null) { + that = 0; + } + return thiz + that; + } + + /** + * Adds two Integers + * + * @param thiz an Integer, may be null + * @param that an Integer, may be null + * @return an Integer sum of thiz and that, may be zero, never null + */ + private static BigDecimal addBigDecimal(BigDecimal thiz, BigDecimal that) { + if (thiz == null) { + thiz = BigDecimal.ZERO; + } + if (that == null) { + that = BigDecimal.ZERO; + } + return thiz.add(that); + } + + +} diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/XmlUtil.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/XmlUtil.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/XmlUtil.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/XmlUtil.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Error.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Error.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Error.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Error.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Failure.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Failure.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Failure.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Failure.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/JUnit.xsd b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/JUnit.xsd similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/JUnit.xsd rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/JUnit.xsd diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/JunitParserUtil.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/JunitParserUtil.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/JunitParserUtil.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/JunitParserUtil.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/ObjectFactory.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/ObjectFactory.java similarity index 99% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/ObjectFactory.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/ObjectFactory.java index 8135b7a9..67f28ce5 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/ObjectFactory.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/ObjectFactory.java @@ -11,6 +11,7 @@ import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; + import javax.xml.namespace.QName; diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Properties.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Properties.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Properties.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Properties.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Property.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Property.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Property.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Property.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Testcase.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Testcase.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Testcase.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Testcase.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuite.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuite.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuite.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuite.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuites.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuites.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuites.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/junit/Testsuites.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Error.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Error.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Error.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Error.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Failure.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Failure.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Failure.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Failure.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyError.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyError.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyError.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyError.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyFailure.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyFailure.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyFailure.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/FlakyFailure.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/ObjectFactory.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/ObjectFactory.java similarity index 99% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/ObjectFactory.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/ObjectFactory.java index 2b46c3a9..cb832ac3 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/ObjectFactory.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/ObjectFactory.java @@ -11,6 +11,7 @@ import javax.xml.bind.JAXBElement; import javax.xml.bind.annotation.XmlElementDecl; import javax.xml.bind.annotation.XmlRegistry; + import javax.xml.namespace.QName; diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Properties.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Properties.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Properties.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Properties.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Property.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Property.java similarity index 99% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Property.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Property.java index 0f7db23f..bc33ad89 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Property.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Property.java @@ -1,14 +1,13 @@ package com.ericdriggs.reportcard.xml.surefire; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - import javax.xml.bind.annotation.XmlAccessType; import javax.xml.bind.annotation.XmlAccessorType; import javax.xml.bind.annotation.XmlAttribute; import javax.xml.bind.annotation.XmlType; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunError.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunError.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunError.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunError.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunFailure.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunFailure.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunFailure.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/RerunFailure.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Skipped.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Skipped.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Skipped.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Skipped.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/SurefireParserUtil.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/SurefireParserUtil.java similarity index 78% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/SurefireParserUtil.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/SurefireParserUtil.java index b3d9d679..436366f3 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/SurefireParserUtil.java +++ b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/SurefireParserUtil.java @@ -1,6 +1,8 @@ package com.ericdriggs.reportcard.xml.surefire; +import com.ericdriggs.file.FileUtils; + import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Unmarshaller; @@ -13,6 +15,11 @@ private SurefireParserUtil() { //call statically } + public static List parseTestSuitesFromPathAndRegex(String absolutePath, String fileNameRegex) { + List xmlStringList = FileUtils.fileContentsFromPathAndRegex(absolutePath, fileNameRegex); + return parseTestSuites(xmlStringList); + } + public static List parseTestSuites(List xmlStringList) { List testsuites = new ArrayList<>(); for ( String xmlString : xmlStringList) { @@ -33,4 +40,5 @@ public static Testsuite parseTestSuite(String xmlString) { throw new RuntimeException(e); } } + } diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testcase.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testcase.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testcase.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testcase.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testsuite.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testsuite.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testsuite.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/Testsuite.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/surefire-test-report-3.0.xsd b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/surefire-test-report-3.0.xsd similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/surefire/surefire-test-report-3.0.xsd rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/surefire/surefire-test-report-3.0.xsd diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Any.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Any.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Any.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Any.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Class.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Class.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Class.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Class.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Classes.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Classes.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Classes.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Classes.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Define.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Define.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Define.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Define.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Dependencies.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Dependencies.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Dependencies.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Dependencies.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Exclude.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Exclude.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Exclude.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Exclude.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Group.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Group.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Group.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Group.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Groups.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Groups.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Groups.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Groups.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Include.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Include.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Include.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Include.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listener.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listener.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listener.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listener.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listeners.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listeners.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listeners.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Listeners.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelector.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelector.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelector.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelector.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelectors.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelectors.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelectors.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/MethodSelectors.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Methods.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Methods.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Methods.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Methods.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/ObjectFactory.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/ObjectFactory.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/ObjectFactory.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/ObjectFactory.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Package.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Package.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Package.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Package.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Packages.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Packages.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Packages.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Packages.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Parameter.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Parameter.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Parameter.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Parameter.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Run.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Run.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Run.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Run.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Script.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Script.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Script.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Script.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SelectorClass.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SelectorClass.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SelectorClass.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SelectorClass.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Suite.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Suite.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Suite.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Suite.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFile.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFile.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFile.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFile.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFiles.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFiles.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFiles.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/SuiteFiles.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Test.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Test.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Test.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/Test.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/TestngResults.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/TestngResults.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/TestngResults.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/TestngResults.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/testng-1.0.xsd b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/testng-1.0.xsd similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/testng-1.0.xsd rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/suite/testng-1.0.xsd diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Class.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Class.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Class.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Class.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Exception.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Exception.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Exception.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Exception.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Group.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Group.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Group.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Group.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Groups.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Groups.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Groups.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Groups.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Method.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Method.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Method.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Method.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ObjectFactory.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ObjectFactory.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ObjectFactory.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ObjectFactory.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Param.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Param.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Param.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Param.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Params.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Params.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Params.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Params.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ReporterOutput.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ReporterOutput.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ReporterOutput.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/ReporterOutput.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Suite.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Suite.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Suite.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Suite.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Test.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Test.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Test.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/Test.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestMethod.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestMethod.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestMethod.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestMethod.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestngResults.java b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestngResults.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestngResults.java rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/TestngResults.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/testng-result.xsd b/reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/testng-result.xsd similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/testng-result.xsd rename to reportcard-model/src/main/java/com/ericdriggs/reportcard/xml/testng/testresult/testng-result.xsd diff --git a/reportcard-model/src/test/java/com/ericdriggs/file/FileUtilsTest.java b/reportcard-model/src/test/java/com/ericdriggs/file/FileUtilsTest.java new file mode 100644 index 00000000..f4cbc6f3 --- /dev/null +++ b/reportcard-model/src/test/java/com/ericdriggs/file/FileUtilsTest.java @@ -0,0 +1,35 @@ +package com.ericdriggs.file; + +import org.junit.jupiter.api.Test; + +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +public class FileUtilsTest { + + final static String relativePath = "src/test/resources/format-samples/surefire-reports"; + final static String absolutePath = FileUtils.absolutePathFromRelativePath(relativePath); + final static String xmlRegex = FileUtils.regexForExtension("xml"); + @Test + public void findFilesTest() { + + + List fileNames = FileUtils.filePathsForPathAndRegex(absolutePath,xmlRegex ); + assertEquals(fileNames.size(), 3); + for (String s : fileNames) { + assertTrue(s.contains(relativePath)); + assertTrue(s.endsWith("xml")); + } + } + + @Test + public void readFilesTest() { + List fileContents = FileUtils.fileContentsFromPathAndRegex(relativePath,xmlRegex ); + assertEquals(fileContents.size(), 3); + for (String s : fileContents) { + assertTrue(s.contains("testsuite")); + } + } +} diff --git a/reportcard-model/src/test/java/com/ericdriggs/reportcard/model/ResultParserUtilTest.java b/reportcard-model/src/test/java/com/ericdriggs/reportcard/model/ResultParserUtilTest.java new file mode 100644 index 00000000..d4a96aff --- /dev/null +++ b/reportcard-model/src/test/java/com/ericdriggs/reportcard/model/ResultParserUtilTest.java @@ -0,0 +1,37 @@ +package com.ericdriggs.reportcard.model; + +import com.ericdriggs.file.FileUtils; +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNull; + +public class ResultParserUtilTest { + + + @Test + public void resultTest() { + final String relativePath = "src/test/resources/format-samples/surefire-reports"; + final String absolutePath = FileUtils.absolutePathFromRelativePath(relativePath); + + TestResult testResult = ResultParserUtil.fromSurefirePath(absolutePath); + assertEquals(3, testResult.getTestSuites().size()); + assertEquals(24, testResult.getTests()); + assertEquals(2, testResult.getSkipped()); + assertEquals(3, testResult.getError()); + assertEquals(9, testResult.getFailure()); + assertEquals(false, testResult.getIsSuccess()); + assertEquals(true, testResult.getHasSkip()); + + //These values are null because they are generated when persisted + assertNull(testResult.getTestResultId()); + assertNull(testResult.getStageFk()); + assertNull(testResult.getExternalLinks()); + assertNull(testResult.getTestResultCreated()); + + assertEquals(new BigDecimal(6).setScale(1), testResult.getTime().setScale(1)); + } + +} diff --git a/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/ResourceReader.java b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/ResourceReader.java new file mode 100644 index 00000000..97be65c3 --- /dev/null +++ b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/ResourceReader.java @@ -0,0 +1,34 @@ +package com.ericdriggs.reportcard.xml; + + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.StandardCharsets; +import java.util.stream.Collectors; + +public class ResourceReader { + + public static String resourceAsString(String filePath) { + InputStream inputStream = getFileAsIOStream(filePath); + return getInputStreamAsString(inputStream); + } + + private static String getInputStreamAsString(InputStream inputStream) { + return new BufferedReader( + new InputStreamReader(inputStream, StandardCharsets.UTF_8)) + .lines() + .collect(Collectors.joining("\n")); + } + + private static InputStream getFileAsIOStream(final String fileName) { + InputStream ioStream = ResourceReader.class + .getClassLoader() + .getResourceAsStream(fileName); + + if (ioStream == null) { + throw new IllegalArgumentException(fileName + " is not found"); + } + return ioStream; + } +} \ No newline at end of file diff --git a/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/ResultCountTest.java b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/ResultCountTest.java new file mode 100644 index 00000000..5ba3a4da --- /dev/null +++ b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/ResultCountTest.java @@ -0,0 +1,39 @@ +package com.ericdriggs.reportcard.xml; + +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.math.RoundingMode; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ResultCountTest { + + private static final Integer ERRORS_COUNT = 1; + private static final Integer FAILURES_COUNT = 3; + private static final Integer SKIPPED_COUNT = 5; + private static final Integer TESTS_COUNT = 20; + private static final BigDecimal TIME = BigDecimal.TEN; + private static final Integer PASSED_COUNT = TESTS_COUNT - ERRORS_COUNT - FAILURES_COUNT - SKIPPED_COUNT; //11 + private static final BigDecimal PASSED_PERCENTAGE = BigDecimal.valueOf(100 * PASSED_COUNT.doubleValue() / (TESTS_COUNT - SKIPPED_COUNT)).setScale(2, RoundingMode.HALF_UP); + private static ResultCount RESULT_COUNT = new ResultCount() + .setTests(TESTS_COUNT) + .setErrors(ERRORS_COUNT) + .setTime(TIME) + .setSkipped(SKIPPED_COUNT) + .setFailures(FAILURES_COUNT); + + @Test + public void testResultCountMethods() { + assertEquals(ERRORS_COUNT, RESULT_COUNT.getErrors()); + assertEquals(FAILURES_COUNT, RESULT_COUNT.getFailures()); + assertEquals(SKIPPED_COUNT, RESULT_COUNT.getSkipped()); + + assertEquals(FAILURES_COUNT, RESULT_COUNT.getFailuresCount()); + assertEquals(SKIPPED_COUNT, RESULT_COUNT.getSkippedCount()); + assertEquals(PASSED_COUNT, RESULT_COUNT.getPassedCount()); + assertEquals(PASSED_PERCENTAGE, RESULT_COUNT.getPassedPercent()); + assertEquals(TESTS_COUNT, RESULT_COUNT.getTestsCount()); + assertEquals(TIME, RESULT_COUNT.getTime()); + } +} diff --git a/reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/junit/JunitUnmarshallTest.java b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/junit/JunitUnmarshallTest.java similarity index 78% rename from reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/junit/JunitUnmarshallTest.java rename to reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/junit/JunitUnmarshallTest.java index 2a21ce92..3da1e1e3 100644 --- a/reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/junit/JunitUnmarshallTest.java +++ b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/junit/JunitUnmarshallTest.java @@ -2,8 +2,6 @@ import com.ericdriggs.reportcard.xml.ResourceReader; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -12,16 +10,13 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringBootTest -public class JunitUnmarshallTest { - @Autowired - ResourceReader resourceReader; +public class JunitUnmarshallTest { @Test void unmarshallXml() { - String xmlString = resourceReader.resourceAsString("classpath:format-samples/sample-junit.xml"); + String xmlString = ResourceReader.resourceAsString("format-samples/sample-junit.xml"); JAXBContext jaxbContext; try { diff --git a/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/surefire/SureFireTestResultTest.java b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/surefire/SureFireTestResultTest.java new file mode 100644 index 00000000..649c954b --- /dev/null +++ b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/surefire/SureFireTestResultTest.java @@ -0,0 +1,35 @@ +package com.ericdriggs.reportcard.xml.surefire; + +import com.ericdriggs.reportcard.xml.ResourceReader; +import org.junit.jupiter.api.Test; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import java.io.StringReader; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +public class SureFireTestResultTest { + + @Test + void unmarshallXml() { + String xmlString = ResourceReader.resourceAsString("format-samples/sample-surefire.xml"); + + JAXBContext jaxbContext; + try { + jaxbContext = JAXBContext.newInstance(Testsuite.class); + Unmarshaller jaxbUnmarshaller = jaxbContext.createUnmarshaller(); + Testsuite testsuite = (Testsuite) jaxbUnmarshaller.unmarshal(new StringReader(xmlString)); + System.out.println(testsuite); + assertEquals(3, testsuite.tests); + assertEquals(3, testsuite.testcase.size()); + assertNotNull(testsuite.testcase.get(0).getSkipped()); + assertNotNull(testsuite.testcase.get(1).getFailure()); + assertNotNull(testsuite.testcase.get(2).getError()); + } catch (JAXBException e) { + throw new RuntimeException(e); + } + } +} diff --git a/reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/surefire/SurefireUnmarshallTest.java b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/surefire/SurefireUnmarshallTest.java similarity index 80% rename from reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/surefire/SurefireUnmarshallTest.java rename to reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/surefire/SurefireUnmarshallTest.java index 668354a6..1299461b 100644 --- a/reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/surefire/SurefireUnmarshallTest.java +++ b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/surefire/SurefireUnmarshallTest.java @@ -2,8 +2,6 @@ import com.ericdriggs.reportcard.xml.ResourceReader; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -13,15 +11,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -@SpringBootTest public class SurefireUnmarshallTest { - @Autowired - ResourceReader resourceReader; - @Test void unmarshallXml() { - String xmlString = resourceReader.resourceAsString("classpath:format-samples/sample-surefire.xml"); + String xmlString = ResourceReader.resourceAsString("format-samples/sample-surefire.xml"); JAXBContext jaxbContext; try { @@ -37,6 +31,5 @@ void unmarshallXml() { } catch (JAXBException e) { throw new RuntimeException(e); } - } } diff --git a/reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/testng/suite/TestngUnmarshallTest.java b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/testng/suite/TestngUnmarshallTest.java similarity index 80% rename from reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/testng/suite/TestngUnmarshallTest.java rename to reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/testng/suite/TestngUnmarshallTest.java index 94b6494b..41038a0d 100644 --- a/reportcard-server/src/test/java/com/ericdriggs/reportcard/xml/testng/suite/TestngUnmarshallTest.java +++ b/reportcard-model/src/test/java/com/ericdriggs/reportcard/xml/testng/suite/TestngUnmarshallTest.java @@ -2,8 +2,6 @@ import com.ericdriggs.reportcard.xml.ResourceReader; import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; @@ -12,15 +10,11 @@ import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringBootTest public class TestngUnmarshallTest { - @Autowired - ResourceReader resourceReader; - @Test void unmarshallXml() { - String xmlString = resourceReader.resourceAsString("classpath:format-samples/sample-testng.xml"); + String xmlString = ResourceReader.resourceAsString("format-samples/sample-testng.xml"); JAXBContext jaxbContext; try { diff --git a/reportcard-model/src/test/resources/format-samples/sample-junit.xml b/reportcard-model/src/test/resources/format-samples/sample-junit.xml new file mode 100644 index 00000000..a866fbe2 --- /dev/null +++ b/reportcard-model/src/test/resources/format-samples/sample-junit.xml @@ -0,0 +1,820 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reportcard-model/src/test/resources/format-samples/sample-surefire.xml b/reportcard-model/src/test/resources/format-samples/sample-surefire.xml new file mode 100644 index 00000000..bb3a5412 --- /dev/null +++ b/reportcard-model/src/test/resources/format-samples/sample-surefire.xml @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This test was skipped + + + + java.lang.AssertionError: + Expected: "wrong" + got: "value" + + at org.junit.Assert.assertThat(Assert.java:778) + at org.junit.Assert.assertThat(Assert.java:736) + at org.apache.maven.surefire.test.FailingTest.defaultTestValueIs_Value(FailingTest.java:23) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44) + at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) + at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41) + at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20) + at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31) + at org.junit.rules.TestWatchman$1.evaluate(TestWatchman.java:48) + at org.junit.runners.BlockJUnit4ClassRunner.runNotIgnored(BlockJUnit4ClassRunner.java:79) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:71) + at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:49) + at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193) + at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52) + at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191) + at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42) + at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184) + at org.junit.runners.ParentRunner.run(ParentRunner.java:236) + at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:262) + at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:151) + at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:122) + at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) + at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) + at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) + at java.lang.reflect.Method.invoke(Method.java:601) + at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189) + at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165) + at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85) + at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:128) + at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:88) + + + + java.lang.SomeStackTrace: + at org.foo(foo.java:128) + at org.foo(Bar.java:88) + + + \ No newline at end of file diff --git a/reportcard-model/src/test/resources/format-samples/sample-testng.xml b/reportcard-model/src/test/resources/format-samples/sample-testng.xml new file mode 100644 index 00000000..ff8ac87c --- /dev/null +++ b/reportcard-model/src/test/resources/format-samples/sample-testng.xml @@ -0,0 +1,208 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/reportcard-model/src/test/resources/format-samples/surefire-reports/features.i-would-do-anything-for-love.xml b/reportcard-model/src/test/resources/format-samples/surefire-reports/features.i-would-do-anything-for-love.xml new file mode 100644 index 00000000..56759ed7 --- /dev/null +++ b/reportcard-model/src/test/resources/format-samples/surefire-reports/features.i-would-do-anything-for-love.xml @@ -0,0 +1,42 @@ + + + + + + + + + + java.lang.SomeStackTrace: + at org.foo(foo.java:128) + at org.foo(Bar.java:88) + + + + java.lang.SomeStackTrace: + at org.foo(foo.java:128) + at org.foo(Bar.java:88) + + + + java.lang.SomeStackTrace: + at org.foo(foo.java:128) + at org.foo(Bar.java:88) + + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed + * match true == BooleanGenerator.generateBoolean(0) .............................................. failed + + Stack Trace: + com.intuit.karate.exception.KarateException: i-would-do-anything-for-love.feature:15 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(0) (i-would-do-anything-for-love.feature:15) + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed + + diff --git a/reportcard-model/src/test/resources/format-samples/surefire-reports/features.never-gonna-give-you-up.xml b/reportcard-model/src/test/resources/format-samples/surefire-reports/features.never-gonna-give-you-up.xml new file mode 100644 index 00000000..acc96807 --- /dev/null +++ b/reportcard-model/src/test/resources/format-samples/surefire-reports/features.never-gonna-give-you-up.xml @@ -0,0 +1,125 @@ + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:9 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:9) + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:9 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:9) + +* match true == BooleanGenerator.generateBoolean(.2) ............................................. passed + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:9 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:9) + +* match true == BooleanGenerator.generateBoolean(.2) ............................................. passed +* match true == BooleanGenerator.generateBoolean(0) .............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:15 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(0) (never-gonna-give-you-up.feature:15) + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:9 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:9) + +* match true == BooleanGenerator.generateBoolean(.2) ............................................. passed +* match true == BooleanGenerator.generateBoolean(0) .............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:15 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(0) (never-gonna-give-you-up.feature:15) + +* match true == BooleanGenerator.generateBoolean(.5) ............................................. passed + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:9 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:9) + +* match true == BooleanGenerator.generateBoolean(.2) ............................................. passed +* match true == BooleanGenerator.generateBoolean(0) .............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:15 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(0) (never-gonna-give-you-up.feature:15) + +* match true == BooleanGenerator.generateBoolean(.5) ............................................. passed +* match true == BooleanGenerator.generateBoolean(.6) ............................................. passed + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:9 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:9) + +* match true == BooleanGenerator.generateBoolean(.2) ............................................. passed +* match true == BooleanGenerator.generateBoolean(0) .............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:15 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(0) (never-gonna-give-you-up.feature:15) + +* match true == BooleanGenerator.generateBoolean(.5) ............................................. passed +* match true == BooleanGenerator.generateBoolean(.6) ............................................. passed +* match true == BooleanGenerator.generateBoolean(.3) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:24 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.3) (never-gonna-give-you-up.feature:24) + + + * match true == BooleanGenerator.generateBoolean(1) .............................................. passed +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:9 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:9) + +* match true == BooleanGenerator.generateBoolean(.2) ............................................. passed +* match true == BooleanGenerator.generateBoolean(0) .............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:15 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(0) (never-gonna-give-you-up.feature:15) + +* match true == BooleanGenerator.generateBoolean(.5) ............................................. passed +* match true == BooleanGenerator.generateBoolean(.6) ............................................. passed +* match true == BooleanGenerator.generateBoolean(.3) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:24 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.3) (never-gonna-give-you-up.feature:24) + +* match true == BooleanGenerator.generateBoolean(.1) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: never-gonna-give-you-up.feature:27 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.1) (never-gonna-give-you-up.feature:27) + + diff --git a/reportcard-model/src/test/resources/format-samples/surefire-reports/features.what-does-the-fox-say.xml b/reportcard-model/src/test/resources/format-samples/surefire-reports/features.what-does-the-fox-say.xml new file mode 100644 index 00000000..86916542 --- /dev/null +++ b/reportcard-model/src/test/resources/format-samples/surefire-reports/features.what-does-the-fox-say.xml @@ -0,0 +1,150 @@ + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(.6) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:16 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.6) (what-does-the-fox-say.feature:16) + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(.6) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:16 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.6) (what-does-the-fox-say.feature:16) + +* match true == BooleanGenerator.generateBoolean(.7) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:19 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.7) (what-does-the-fox-say.feature:19) + + + * match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:6 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(ratio) (what-does-the-fox-say.feature:6) + +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(ratio) .......................................... passed +* match true == BooleanGenerator.generateBoolean(.6) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:16 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.6) (what-does-the-fox-say.feature:16) + +* match true == BooleanGenerator.generateBoolean(.7) ............................................. failed + +Stack Trace: +com.intuit.karate.exception.KarateException: what-does-the-fox-say.feature:19 - path: $, actual: true, expected: false, reason: not equal (Boolean) + at ✽.* match true == BooleanGenerator.generateBoolean(.7) (what-does-the-fox-say.feature:19) + +* match true == BooleanGenerator.generateBoolean(.8) ............................................. passed + + diff --git a/reportcard-server/build.gradle b/reportcard-server/build.gradle index 4442dea8..17a2cdf4 100644 --- a/reportcard-server/build.gradle +++ b/reportcard-server/build.gradle @@ -31,6 +31,9 @@ repositories { } dependencies { + dependencies { + implementation project(':reportcard-model') + } //Lombok implementation 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' @@ -180,6 +183,7 @@ jooq { } generate { generatedAnnotation = true + generatedSerialVersionUID = "HASH" daos = true relations = true deprecated = false diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/Comparators.java b/reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/Comparators.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/Comparators.java rename to reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/Comparators.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/ExecutionStagePath.java b/reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/ExecutionStagePath.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/ExecutionStagePath.java rename to reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/ExecutionStagePath.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/HostApplicationPipeline.java b/reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/HostApplicationPipeline.java similarity index 100% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/HostApplicationPipeline.java rename to reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/HostApplicationPipeline.java diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/ReportMetaData.java b/reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/ReportMetaData.java similarity index 98% rename from reportcard-server/src/main/java/com/ericdriggs/reportcard/model/ReportMetaData.java rename to reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/ReportMetaData.java index b2505931..5d1a9d99 100644 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/ReportMetaData.java +++ b/reportcard-server/src/generated/java/com/ericdriggs/reportcard/model/ReportMetaData.java @@ -47,7 +47,7 @@ public void validateAndSetDefaults() { } protected void addErrorIfMissing(Map errors, String val, String variableName) { - if (StringUtils.isEmpty(val)) { + if (!StringUtils.hasText(val)) { errors.put(variableName, "missing required field"); } } diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestStatusType.java b/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestStatusType.java deleted file mode 100644 index 322443b5..00000000 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestStatusType.java +++ /dev/null @@ -1,8 +0,0 @@ -package com.ericdriggs.reportcard.model; - -public enum TestStatusType { - SUCCESS, - SKIPPED, - FAILURE, - ERROR -} diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestSuite.java b/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestSuite.java deleted file mode 100644 index 8f06e994..00000000 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/model/TestSuite.java +++ /dev/null @@ -1,49 +0,0 @@ -package com.ericdriggs.reportcard.model; - -import java.util.ArrayList; -import java.util.List; - -public class TestSuite extends com.ericdriggs.reportcard.gen.db.tables.pojos.TestSuite { - private List testCases = new ArrayList<>(); - - public List getTestCases() { - return testCases; - } - - public TestSuite setTestCases( List testCases) { - this.testCases = testCases; - return this; - } - -// /** -// * Gets value from super or calculates it (super may be null> if row just inserted) -// * @return whether was successful -// */ -// @Override -// public Boolean getIsSuccess() { -// if (super.getIsSuccess() != null) { -// return super.getIsSuccess(); -// } else { -// int failure = Objects.requireNonNullElse(super.getFailure(), 0); -// int error = Objects.requireNonNullElse(super.getError(), 0); -// int skipped = Objects.requireNonNullElse(super.getSkipped(), 0); -// -// return failure + error + skipped == 0; -// } -// } -// -// /** -// * Gets value from super or calculates it (super may be null> if row just inserted) -// * @return whether has skip -// */ -// @Override -// public Boolean getHasSkip() { -// if (super.getHasSkip() != null) { -// return super.getHasSkip(); -// } else { -// int skipped = Objects.requireNonNullElse(super.getSkipped(), 0); -// return skipped > 0; -// } -// } - //TODO: serialize and desrialize properties from json to Map -} diff --git a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/ResultCount.java b/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/ResultCount.java deleted file mode 100644 index 18989168..00000000 --- a/reportcard-server/src/main/java/com/ericdriggs/reportcard/xml/ResultCount.java +++ /dev/null @@ -1,90 +0,0 @@ -package com.ericdriggs.reportcard.xml; - -import lombok.Data; - -import java.math.BigDecimal; -import java.util.List; - -@Data -public class ResultCount { - private Integer tests; - private Integer failures; - private Integer errors; - private BigDecimal time; - -// public static ResultCount aggregate(List resultCounts) { -// ResultCount resultCount = new ResultCount(); -// resultCount.setErrors( -// resultCounts -// .stream() -// .map(ResultCount::getErrors) -// .reduce(0,(a, b) -> a + b)); -// } - - /** - * Sums the fields of a resultCount - * @param that a ResultCount - * @return a new ResultCount sum of this and that - */ - public ResultCount add(ResultCount that) { - ResultCount resultCount = new ResultCount(); - resultCount.setErrors(addIntegers(this.getErrors(), that.getErrors())); - resultCount.setFailures(addIntegers(this.getFailures(), that.getFailures())); - resultCount.setTests(addIntegers(this.getTests(), that.getTests())); - resultCount.setTime(addBigDecimal(this.getTime(), that.getTime())); - return resultCount; - } - - public ResultCount aggregate(List resultCounts) { - ResultCount resultCount = new ResultCount(); - for (ResultCount r : resultCounts) { - resultCount = resultCount.add(r); - } - return resultCount; - } - - /** - * Adds two Integers - * - * @param thiz an Integer, may be null - * @param that an Integer, may be null - * @return an Integer sum of thiz and that, only null if both are null. - */ - private static Integer addIntegers(Integer thiz, Integer that) { - if (thiz == null) { - return that; - } else if (that == null) { - return null; - } else { - return thiz + that; - } - } - /** - * Adds two Integers - * - * @param thiz an Integer, may be null - * @param that an Integer, may be null - * @return an Integer sum of thiz and that, only null if both are null. - */ - private static BigDecimal addBigDecimal(BigDecimal thiz, BigDecimal that) { - if (thiz == null) { - return that; - } else if (that == null) { - return null; - } else { - return thiz.add(that); - } - } - - -// public ResultCount getResultCount() { -// for (Testsuite t : testsuite) { -// -// t.skipped.; -// t.time; -// t.failures; -// t.errors; -// } -// } - -} diff --git a/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/junit/JunitMapperTests.java b/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/junit/JunitMapperTests.java index b7f4d958..f468847f 100644 --- a/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/junit/JunitMapperTests.java +++ b/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/junit/JunitMapperTests.java @@ -1,9 +1,12 @@ package com.ericdriggs.reportcard.model.converter.junit; +import com.ericdriggs.reportcard.model.TestCase; import com.ericdriggs.reportcard.model.TestStatus; import com.ericdriggs.reportcard.xml.junit.Testsuite; import com.ericdriggs.reportcard.xml.junit.Testsuites; +import com.ericdriggs.reportcard.model.TestResult; +import com.ericdriggs.reportcard.model.TestSuite; import org.junit.jupiter.api.Test; import org.modelmapper.ModelMapper; @@ -25,7 +28,7 @@ public void testCaseTest() { assertNull(junitTestCase.getError()); assertNull(junitTestCase.getSkipped()); - com.ericdriggs.reportcard.model.TestCase modelTestCase = modelMapper.map(junitTestCase, com.ericdriggs.reportcard.model.TestCase.class); + TestCase modelTestCase = modelMapper.map(junitTestCase, TestCase.class); assertEquals(junitTestCase.getClassname(), modelTestCase.getClassName()); assertEquals(junitTestCase.getName(), modelTestCase.getName()); assertEquals(junitTestCase.getTime(), modelTestCase.getTime()); @@ -62,7 +65,7 @@ public void testSuiteTest() { } } // - com.ericdriggs.reportcard.model.TestSuite modelTestSuite = modelMapper.map(suite, com.ericdriggs.reportcard.model.TestSuite.class); + TestSuite modelTestSuite = modelMapper.map(suite, TestSuite.class); { assertEquals(1, modelTestSuite.getError()); assertEquals(1, modelTestSuite.getFailure()); @@ -72,7 +75,7 @@ public void testSuiteTest() { assertEquals(4, modelTestSuite.getTests()); assertEquals(new BigDecimal("4.92"), modelTestSuite.getTime()); { - List testcases = modelTestSuite.getTestCases(); + List testcases = modelTestSuite.getTestCases(); assertEquals(TestStatus.SUCCESS, testcases.get(0).getTestStatus()); //TODO: assert testcases; } @@ -91,7 +94,7 @@ public void testResultTest() { com.ericdriggs.reportcard.xml.junit.Testsuites suites = new Testsuites(); suites.setTestsuite(testsuites); - com.ericdriggs.reportcard.model.TestResult modelTestResult = modelMapper.map(suites, com.ericdriggs.reportcard.model.TestResult.class); + TestResult modelTestResult = modelMapper.map(suites, TestResult.class); assertEquals(8, modelTestResult.getTests()); assertEquals(2, modelTestResult.getError()); diff --git a/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireMapperTests.java b/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireMapperTests.java index e10ed74b..c911ba2f 100644 --- a/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireMapperTests.java +++ b/reportcard-server/src/test/java/com/ericdriggs/reportcard/model/converter/surefire/SurefireMapperTests.java @@ -1,7 +1,9 @@ package com.ericdriggs.reportcard.model.converter.surefire; +import com.ericdriggs.reportcard.model.TestCase; import com.ericdriggs.reportcard.model.TestStatus; -import com.ericdriggs.reportcard.model.converter.surefire.SurefireConvertersUtil; +import com.ericdriggs.reportcard.model.TestResult; +import com.ericdriggs.reportcard.model.TestSuite; import com.ericdriggs.reportcard.xml.surefire.Testsuite; import org.junit.jupiter.api.Test; import org.modelmapper.ModelMapper; @@ -10,7 +12,7 @@ import java.util.ArrayList; import java.util.List; -import static com.ericdriggs.reportcard.model.converter.surefire.SurefireConvertersUtil.*; +import static com.ericdriggs.reportcard.model.converter.surefire.SurefireConvertersUtil.doFromSurefireToModelTestResult; import static org.junit.jupiter.api.Assertions.*; @@ -26,7 +28,7 @@ public void testCaseTest() { assertNull(surefireTestCase.getError()); assertNull(surefireTestCase.getSkipped()); - com.ericdriggs.reportcard.model.TestCase modelTestCase = modelMapper.map(surefireTestCase, com.ericdriggs.reportcard.model.TestCase.class); + TestCase modelTestCase = modelMapper.map(surefireTestCase, TestCase.class); assertEquals(surefireTestCase.getClassname(), modelTestCase.getClassName()); assertEquals(surefireTestCase.getName(), modelTestCase.getName()); assertEquals(surefireTestCase.getTime(), modelTestCase.getTime().toPlainString()); @@ -74,7 +76,7 @@ public void testSuiteTest() { } } // - com.ericdriggs.reportcard.model.TestSuite modelTestSuite = modelMapper.map(suite, com.ericdriggs.reportcard.model.TestSuite.class); + TestSuite modelTestSuite = modelMapper.map(suite, TestSuite.class); { assertEquals(3, modelTestSuite.getError()); assertEquals(3, modelTestSuite.getFailure()); @@ -93,7 +95,7 @@ public void testSuiteTest() { assertEquals(8, modelTestSuite.getTests()); assertEquals(new BigDecimal("9.84"), modelTestSuite.getTime()); { - List testcases = modelTestSuite.getTestCases(); + List testcases = modelTestSuite.getTestCases(); assertEquals(TestStatus.SUCCESS, testcases.get(0).getTestStatus()); //TODO: assert testcases; } @@ -114,7 +116,7 @@ public void testResultTest() { testsuites.add(suite); //calculations are by value so add same twice is valid // com.ericdriggs.reportcard.model.TestResult modelTestResult = modelMapper.map(testsuites, com.ericdriggs.reportcard.model.TestResult.class); - com.ericdriggs.reportcard.model.TestResult modelTestResult = doFromSurefireToModelTestResult(testsuites); + TestResult modelTestResult = doFromSurefireToModelTestResult(testsuites); assertEquals(16, modelTestResult.getTests()); assertEquals(6, modelTestResult.getError()); assertEquals(6, modelTestResult.getFailure()); diff --git a/settings.gradle b/settings.gradle index d27523d0..c50973d2 100644 --- a/settings.gradle +++ b/settings.gradle @@ -6,7 +6,9 @@ pluginManagement { } rootProject.name = 'reportcard' -//include 'test-data-generator' //est-data-generator generates failing tests -- not part of build +// *** test-data-generator generates failing tests -- not part of build ***/ +//include 'test-data-generator' include 'reportcard-client' include 'reportcard-jooq-generator' +include 'reportcard-model' include 'reportcard-server'