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

3.0.2 #91

Merged
merged 2 commits into from Dec 30, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -7,7 +7,7 @@
<groupId>io.qase</groupId>
<artifactId>qase-java</artifactId>
<packaging>pom</packaging>
<version>3.0.1</version>
<version>3.0.2</version>
<modules>
<module>qase-api</module>
<module>qase-testng</module>
Expand Down
2 changes: 1 addition & 1 deletion qase-api/README.md
Expand Up @@ -8,7 +8,7 @@ Add the following dependency and repository to your pom.xml:
<dependency>
<groupId>io.qase</groupId>
<artifactId>qase-api</artifactId>
<version>3.0.1</version>
<version>3.0.2</version>
</dependency>

```
Expand Down
2 changes: 1 addition & 1 deletion qase-api/pom.xml
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>qase-java</artifactId>
<groupId>io.qase</groupId>
<version>3.0.1</version>
<version>3.0.2</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 4 additions & 0 deletions qase-api/src/main/java/io/qase/api/annotation/CaseId.java
Expand Up @@ -2,9 +2,13 @@

import java.lang.annotation.*;

/**
* @deprecated use {@link QaseId} instead.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Deprecated
public @interface CaseId {
long value();
}
3 changes: 3 additions & 0 deletions qase-api/src/main/java/io/qase/api/annotation/CaseTitle.java
Expand Up @@ -3,6 +3,9 @@
import java.lang.annotation.*;


/**
* @deprecated use {@link QaseTitle} instead.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
Expand Down
10 changes: 10 additions & 0 deletions qase-api/src/main/java/io/qase/api/annotation/QaseId.java
@@ -0,0 +1,10 @@
package io.qase.api.annotation;

import java.lang.annotation.*;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface QaseId {
long value();
}
11 changes: 11 additions & 0 deletions qase-api/src/main/java/io/qase/api/annotation/QaseTitle.java
@@ -0,0 +1,11 @@
package io.qase.api.annotation;

import java.lang.annotation.*;


@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface QaseTitle {
String value();
}
12 changes: 4 additions & 8 deletions qase-api/src/main/java/io/qase/api/services/Attachments.java
Expand Up @@ -2,7 +2,7 @@

import io.qase.api.CasesStorage;
import io.qase.api.StepStorage;
import io.qase.api.annotation.CaseId;
import io.qase.api.annotation.QaseId;
import io.qase.api.annotation.Step;
import io.qase.api.config.QaseConfig;
import io.qase.api.exceptions.QaseException;
Expand All @@ -13,11 +13,7 @@
import io.qase.guice.Injectors;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Optional;
import java.util.*;
import java.util.function.Consumer;
import java.util.function.Supplier;
import java.util.stream.Collectors;
Expand All @@ -28,7 +24,7 @@ public class Attachments {

/**
* Adds attachments to the current context.
* The context could be either {@link io.qase.api.annotation.CaseId} or {@link io.qase.api.annotation.Step}
* The context could be either {@link io.qase.api.annotation.QaseId} or {@link io.qase.api.annotation.Step}
*
* @throws QaseException if the invocation context can not be found
* */
Expand Down Expand Up @@ -92,7 +88,7 @@ private static AttachmentContext lookupCurrentContext() {
return AttachmentContext.TEST_CASE;
}
throw new UncheckedQaseException(new QaseException(String.format(
"It is expected either %s or %s-annotated method be called.", Step.class.getName(), CaseId.class.getName()
"It is expected either %s or %s-annotated method be called.", Step.class.getName(), QaseId.class.getName()
)));
}

Expand Down
25 changes: 25 additions & 0 deletions qase-api/src/main/java/io/qase/api/utils/IntegrationUtils.java
Expand Up @@ -2,6 +2,8 @@

import io.qase.api.annotation.CaseId;
import io.qase.api.annotation.CaseTitle;
import io.qase.api.annotation.QaseId;
import io.qase.api.annotation.QaseTitle;

import java.io.PrintWriter;
import java.io.StringWriter;
Expand All @@ -24,6 +26,10 @@ public static String getStacktrace(Throwable throwable) {
}

public static Long getCaseId(Method method) {
Long qaseId = getQaseId(method);
if (qaseId != null) {
return qaseId;
}
if (method.isAnnotationPresent(CaseId.class)) {
return method
.getDeclaredAnnotation(CaseId.class).value();
Expand All @@ -32,9 +38,28 @@ public static Long getCaseId(Method method) {
}

public static String getCaseTitle(Method method) {
String qaseTitle = getQaseTitle(method);
if (qaseTitle != null) {
return qaseTitle;
}
if (method.isAnnotationPresent(CaseTitle.class)) {
return method.getDeclaredAnnotation(CaseTitle.class).value();
}
return null;
}

private static Long getQaseId(Method method) {
if (method.isAnnotationPresent(QaseId.class)) {
return method
.getDeclaredAnnotation(QaseId.class).value();
}
return null;
}

private static String getQaseTitle(Method method) {
if (method.isAnnotationPresent(QaseTitle.class)) {
return method.getDeclaredAnnotation(QaseTitle.class).value();
}
return null;
}
}