Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove test duplication #255

Merged
merged 7 commits into from
Mar 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:

- name: Build
id: build
run: mvn -B -U -P regular "-Dsurefire.rerunFailingTestsCount=5" clean install
run: mvn -B -U -P embedded "-Dsurefire.rerunFailingTestsCount=5" clean install

- name: Archive Test Results
uses: actions/upload-artifact@v2
Expand Down
2 changes: 1 addition & 1 deletion .idea/copyright/apache_copyright.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/copyright/zeebe_community_license.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<dependency.agrona.version>1.14.0</dependency.agrona.version>
<dependency.assertj.version>3.22.0</dependency.assertj.version>
<dependency.awaitility.version>4.2.0</dependency.awaitility.version>
<dependency.classgraph.version>4.8.141</dependency.classgraph.version>
<dependency.commons.version>3.12.0</dependency.commons.version>
<dependency.errorprone.version>2.11.0</dependency.errorprone.version>
<dependency.eze.version>0.6.0</dependency.eze.version>
Expand Down Expand Up @@ -92,7 +93,7 @@
<plugin.version.surefire>3.0.0-M5</plugin.version.surefire>

<version.grpc>1.45.0</version.grpc>
<version.java>11</version.java>
<version.java>17</version.java>
<version.protobuf>3.19.4</version.protobuf>
</properties>

Expand Down Expand Up @@ -278,17 +279,23 @@
<version>${dependency.testcontainers.version}</version>
</dependency>

<!-- Only for dependency convergence issues -->
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${dependency.protobuf.version}</version>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<version>${dependency.classgraph.version}</version>
</dependency>

<!-- Only for dependency convergence issues -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>${dependency.guava.version}</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-java</artifactId>
<version>${dependency.protobuf.version}</version>
</dependency>
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
Expand Down
16 changes: 14 additions & 2 deletions qa/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@
<artifactId>slf4j-simple</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.github.classgraph</groupId>
<artifactId>classgraph</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -108,7 +120,7 @@

<profiles>
<profile>
<id>regular</id>
<id>embedded</id>
<build>
<plugins>
<plugin>
Expand All @@ -135,7 +147,7 @@
<version>${plugin.version.surefire}</version>
<configuration>
<excludes>
<exclude>**/regular/**/*.java</exclude>
<exclude>**/embedded/**/*.java</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
* Copyright © 2021 camunda services GmbH (info@camunda.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.process.test.qa;

import static org.assertj.core.api.Assertions.assertThat;

import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
import io.github.classgraph.ClassGraph;
import io.github.classgraph.ClassInfo;
import io.github.classgraph.ClassInfoList;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class ExtendAbstractsTest {

public static final Class<ZeebeProcessTest> EMBEDDED_ANNOTATION = ZeebeProcessTest.class;
public static final Class<io.camunda.zeebe.process.test.extension.testcontainer.ZeebeProcessTest>
TESTCONTAINER_ANNOTATION =
io.camunda.zeebe.process.test.extension.testcontainer.ZeebeProcessTest.class;
private static final String ABSTRACT_PACKAGE = "io.camunda.zeebe.process.test.qa.abstracts";
private static final String EMBEDDED_PACKAGE = "io.camunda.zeebe.process.test.qa.embedded";
private static final String TESTCONTAINER_PACKAGE =
"io.camunda.zeebe.process.test.qa.testcontainer";

private static final ClassInfoList EMBEDDED_CLASSES =
new ClassGraph()
.acceptPackages(EMBEDDED_PACKAGE)
.ignoreClassVisibility()
.enableAnnotationInfo()
.scan()
.getAllStandardClasses()
.filter(info -> !info.isInnerClass());

private static final ClassInfoList TESTCONTAINER_CLASSES =
new ClassGraph()
.acceptPackages(TESTCONTAINER_PACKAGE)
.ignoreClassVisibility()
.enableAnnotationInfo()
.scan()
.getAllStandardClasses()
.filter(info -> !info.isInnerClass());

@ParameterizedTest(name = "{0}")
@MethodSource("provideAbstractClasses")
void testAbstractClassIsExtendedWithEmbeddedExtension(
final String className, final Class<?> abstractClass) {
final ClassInfoList embeddedClass =
EMBEDDED_CLASSES
.filter(info -> info.getPackageName().contains("embedded"))
remcowesterhoud marked this conversation as resolved.
Show resolved Hide resolved
.filter(info -> info.extendsSuperclass(abstractClass))
.filter(info -> info.hasAnnotation(EMBEDDED_ANNOTATION));

assertThat(embeddedClass)
.withFailMessage(
"Expected 1 embedded implementation of %s, but found %d: %s",
className, embeddedClass.size(), embeddedClass)
.hasSize(1);
}

@ParameterizedTest(name = "{0}")
@MethodSource("provideAbstractClasses")
void testAbstractClassIsExtendedWithTestcontainerExtension(
final String className, final Class<?> abstractClass) {
final ClassInfoList testcontainerClass =
TESTCONTAINER_CLASSES
.filter(info -> info.getPackageName().contains("testcontainer"))
.filter(info -> info.extendsSuperclass(abstractClass))
.filter(info -> info.hasAnnotation(TESTCONTAINER_ANNOTATION));

assertThat(testcontainerClass)
.withFailMessage(
"Expected 1 testcontainer implementation of %s, but found %d: %s",
className, testcontainerClass.size(), testcontainerClass)
.hasSize(1);
}

private static Stream<Arguments> provideAbstractClasses() {
return new ClassGraph()
.acceptPackages(ABSTRACT_PACKAGE)
.scan()
.getAllStandardClasses()
.filter(ClassInfo::isAbstract)
.filter(info -> !info.isInnerClass())
.stream()
.map(info -> Arguments.of(info.getSimpleName(), info.loadClass()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.process.test.qa.regular.assertions;
package io.camunda.zeebe.process.test.qa.abstracts.assertions;

import static org.assertj.core.api.Assertions.assertThatThrownBy;

import io.camunda.zeebe.client.ZeebeClient;
import io.camunda.zeebe.client.api.response.DeploymentEvent;
import io.camunda.zeebe.process.test.assertions.BpmnAssert;
import io.camunda.zeebe.process.test.assertions.ProcessAssert;
import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
import io.camunda.zeebe.process.test.qa.util.Utilities;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackLoopingServiceTask;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackMultipleTasks;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

@ZeebeProcessTest
class DeploymentAssertTest {
public abstract class AbstractDeploymentAssertTest {

public static final String WRONG_VALUE = "wrong value";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.process.test.qa.regular.assertions;
package io.camunda.zeebe.process.test.qa.abstracts.assertions;

import static org.assertj.core.api.Assertions.assertThatThrownBy;

Expand All @@ -24,7 +24,6 @@
import io.camunda.zeebe.process.test.api.ZeebeTestEngine;
import io.camunda.zeebe.process.test.assertions.BpmnAssert;
import io.camunda.zeebe.process.test.assertions.IncidentAssert;
import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
import io.camunda.zeebe.process.test.qa.util.Utilities;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackLoopingServiceTask;
import io.camunda.zeebe.protocol.record.value.ErrorType;
Expand All @@ -37,8 +36,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

@ZeebeProcessTest
class IncidentAssertTest {
public abstract class AbstractIncidentAssertTest {

public static final String WRONG_VALUE = "wrong value";
public static final String ERROR_CODE = "error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.process.test.qa.regular.assertions;
package io.camunda.zeebe.process.test.qa.abstracts.assertions;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.assertj.core.api.Assertions.entry;
Expand All @@ -25,7 +25,6 @@
import io.camunda.zeebe.process.test.api.ZeebeTestEngine;
import io.camunda.zeebe.process.test.assertions.BpmnAssert;
import io.camunda.zeebe.process.test.assertions.IncidentAssert;
import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
import io.camunda.zeebe.process.test.qa.util.Utilities;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackLoopingServiceTask;
import io.camunda.zeebe.protocol.record.value.ErrorType;
Expand All @@ -37,8 +36,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

@ZeebeProcessTest
class JobAssertTest {
public abstract class AbstractJobAssertTest {

public static final String WRONG_VALUE = "wrong value";
public static final String ERROR_CODE = "error";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.process.test.qa.regular.assertions;
package io.camunda.zeebe.process.test.qa.abstracts.assertions;

import static org.assertj.core.api.AssertionsForClassTypes.assertThatThrownBy;

Expand All @@ -22,7 +22,6 @@
import io.camunda.zeebe.client.api.response.PublishMessageResponse;
import io.camunda.zeebe.process.test.api.ZeebeTestEngine;
import io.camunda.zeebe.process.test.assertions.BpmnAssert;
import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
import io.camunda.zeebe.process.test.qa.util.Utilities;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackMessageEvent;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackMessageStartEvent;
Expand All @@ -33,8 +32,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

@ZeebeProcessTest
class MessageAssertTest {
public abstract class AbstractMessageAssertTest {

public static final String CORRELATION_KEY = "correlationkey";
public static final String WRONG_CORRELATION_KEY = "wrongcorrelationkey";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.process.test.qa.regular.assertions;
package io.camunda.zeebe.process.test.qa.abstracts.assertions;

import static org.assertj.core.api.Assertions.assertThatThrownBy;

Expand All @@ -22,15 +22,13 @@
import io.camunda.zeebe.process.test.api.ZeebeTestEngine;
import io.camunda.zeebe.process.test.assertions.BpmnAssert;
import io.camunda.zeebe.process.test.assertions.ProcessAssert;
import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
import io.camunda.zeebe.process.test.qa.util.Utilities;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackLoopingServiceTask;
import java.util.concurrent.TimeoutException;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

@ZeebeProcessTest
class ProcessAssertTest {
public abstract class AbstractProcessAssertTest {

public static final String WRONG_VALUE = "wrong value";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.camunda.zeebe.process.test.qa.regular.assertions;
package io.camunda.zeebe.process.test.qa.abstracts.assertions;

import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.mock;
Expand All @@ -24,7 +24,6 @@
import io.camunda.zeebe.process.test.api.ZeebeTestEngine;
import io.camunda.zeebe.process.test.assertions.BpmnAssert;
import io.camunda.zeebe.process.test.assertions.IncidentAssert;
import io.camunda.zeebe.process.test.extension.ZeebeProcessTest;
import io.camunda.zeebe.process.test.qa.util.Utilities;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackLoopingServiceTask;
import io.camunda.zeebe.process.test.qa.util.Utilities.ProcessPackMessageEvent;
Expand All @@ -41,8 +40,7 @@
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;

@ZeebeProcessTest
class ProcessInstanceAssertTest {
public abstract class AbstractProcessInstanceAssertTest {

private static final String LINE_SEPARATOR = System.lineSeparator();
private static final Map<String, Object> TYPED_TEST_VARIABLES = new HashMap<>();
Expand Down
Loading