Skip to content

Commit

Permalink
Merge pull request #91 from qase-tms/3.0.2
Browse files Browse the repository at this point in the history
3.0.2
  • Loading branch information
savkk committed Dec 30, 2022
2 parents 5d9a344 + 241cc20 commit ce1997d
Show file tree
Hide file tree
Showing 45 changed files with 177 additions and 108 deletions.
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;
}
}

0 comments on commit ce1997d

Please sign in to comment.