From 92d83d62ab1183887f88d1e37786c84d78d1fad4 Mon Sep 17 00:00:00 2001 From: Jens Pelzetter Date: Fri, 9 Aug 2019 10:23:19 +0200 Subject: [PATCH] Tests for equals and hashCode for SciProject and assciated classes, JenkinsFile --- Jenkinsfile | 48 +++++++++++++++++++ .../sciproject/EqualsAndHashCodeTest.java | 38 +++++++++++++++ 2 files changed, 86 insertions(+) create mode 100644 Jenkinsfile create mode 100644 sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..45c9fbb --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,48 @@ +pipeline { + agent any + tools { + maven 'apache-maven-3.6.0' + } + stages { + stage('Build and Test') { + steps { + dir('') { + // sh 'mvn clean package test -Pwildfly-remote-h2-mem' + sh 'mvn clean package -Pwildfly-remote-h2-mem' + } + } + post { + always { + sh 'sudo systemctl restart wildfly' + } + } + } + stage("Analyse") { + steps { + dir('') { + sh 'mvn package pmd:pmd pmd:cpd spotbugs:spotbugs' + } + } + } + } + post { + success { + mail to: 'developers@scientificcms.org', + subject: "${currentBuild.fullDisplayName} was successful", + body: "Build ${env.BUILD_URL} was successful." + } + failure { + mail to: 'developers@scientificcms.org', + subject: "${currentBuild.fullDisplayName} FAILED!!!", + body: "Build ${env.BUILD_URL} failed." + } + always { + junit testResults: '**/target/surefire-reports/*.xml' + + recordIssues enabledForFailure: true, tools: [java(), javaDoc()] + recordIssues enabledForFailure: false, tool: spotBugs() + recordIssues enabledForFailure: false, tool: cpd(pattern: '**/target/cpd.xml') + recordIssues enabledForFailure: false, tool: pmdParser(pattern: '**/target/pmd.xml') + } + } +} diff --git a/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java b/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java new file mode 100644 index 0000000..63acd4e --- /dev/null +++ b/sci-types-project/src/test/java/org/scientificcms/contenttypes/sciproject/EqualsAndHashCodeTest.java @@ -0,0 +1,38 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.scientificcms.contenttypes.sciproject; + +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; +import org.libreccm.tests.categories.UnitTest; +import org.libreccm.testutils.EqualsVerifier; + +import java.util.Arrays; +import java.util.Collection; + +/** + * + * @author Jens Pelzetter + */ +@RunWith(Parameterized.class) +@org.junit.experimental.categories.Category(UnitTest.class) +public class EqualsAndHashCodeTest extends EqualsVerifier { + + @Parameterized.Parameters(name = "{0}") + public static Collection> data() { + + return Arrays.asList(new Class[]{ + Contact.class, + Membership.class, + SciProject.class + }); + } + + public EqualsAndHashCodeTest(final Class clazz) { + super(clazz); + } + +}