Skip to content

Commit 98db9e8

Browse files
authored
Feature/v6.0.1 (#80)
* Initial commit * Added test attachment version * Added support for test attachments * Minor updates * Added helper to encode stream -> base64string * Added null check in `encodeSpace` method * Added `async` methods * Fixed issue #79 * Bumped to version `6.0.1`
1 parent 1415d7b commit 98db9e8

23 files changed

+904
-24
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
# 6.0.1
44

55
- Added support for TestCaseResult in **TestApi**.
6+
- PR: [feat: added test results endpoints #78](https://github.com/hkarthik7/azure-devops-java-sdk/pull/78)
7+
- Added support for Test attachments.
8+
- Fixed issues:
9+
- Issue: [Mapping error on empty response from client.helpers().featureManagement().featureToggle #76](https://github.com/hkarthik7/azure-devops-java-sdk/issues/76)
10+
- Issue: [Get repository from project won't work if project name has space in it #79](https://github.com/hkarthik7/azure-devops-java-sdk/issues/79)
611

712
# 6.0.0
813

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Build Status](https://dev.azure.com/harishkarthic/azure-devops-java-sdk/_apis/build/status/hkarthik7.azure-devops-java-sdk?branchName=main)](https://dev.azure.com/harishkarthic/azure-devops-java-sdk/_build/latest?definitionId=8&branchName=main)
44
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/hkarthik7/azure-devops-java-sdk/blob/main/LICENSE)
55
[![Documentation Status](https://readthedocs.org/projects/azure-devops-java-sdk-docs/badge/?version=latest)](https://azure-devops-java-sdk-docs.readthedocs.io/en/latest/?badge=latest)
6-
[![Maven Central](https://img.shields.io/maven-central/v/io.github.hkarthik7/azd.svg)](https://search.maven.org/artifact/io.github.hkarthik7/azd/6.0.0/jar)
6+
[![Maven Central](https://img.shields.io/maven-central/v/io.github.hkarthik7/azd.svg)](https://search.maven.org/artifact/io.github.hkarthik7/azd/6.0.1/jar)
77

88
**azd** library provides a convenient way to manage and interact with **Azure DevOps Services** REST API with ease. This SDK offers a set of APIs and utilities
99
with declarative syntax and provide functionalities to the significant services.
@@ -33,7 +33,7 @@ To download the library and use it in your project, just add below in your pom.x
3333
<dependency>
3434
<groupId>io.github.hkarthik7</groupId>
3535
<artifactId>azd</artifactId>
36-
<version>6.0.0</version>
36+
<version>6.0.1</version>
3737
</dependency>
3838
```
3939

@@ -43,7 +43,7 @@ To download the library and use it in your project, just add below in your pom.x
4343
<dependency>
4444
<groupId>io.github.hkarthik7</groupId>
4545
<artifactId>azd</artifactId>
46-
<version>6.0.0</version>
46+
<version>6.0.1</version>
4747
<classifier>javadoc</classifier>
4848
</dependency>
4949
```
@@ -54,7 +54,7 @@ To download the library and use it in your project, just add below in your pom.x
5454
<dependency>
5555
<groupId>io.github.hkarthik7</groupId>
5656
<artifactId>azd</artifactId>
57-
<version>6.0.0</version>
57+
<version>6.0.1</version>
5858
<classifier>sources</classifier>
5959
</dependency>
6060
```

azd/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>io.github.hkarthik7</groupId>
88
<artifactId>azd</artifactId>
9-
<version>6.0.0</version>
9+
<version>6.0.1</version>
1010
<packaging>jar</packaging>
1111

1212
<name>azd</name>

azd/src/main/java/org/azd/authentication/OAuthAccessTokenCredential.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.azd.authentication;
22

33
import org.azd.exceptions.AzDException;
4+
import org.azd.helpers.URLHelper;
45
import org.azd.oauth.OAuthAccessTokenBuilder;
56
import org.azd.oauth.types.AuthorizedToken;
67

@@ -75,7 +76,7 @@ public OAuthAccessTokenCredential(String organizationUrl, String projectName,
7576
Objects.requireNonNull(authCode, "Auth code cannot be null.");
7677

7778
this.organizationUrl = organizationUrl;
78-
this.projectName = projectName;
79+
this.projectName = URLHelper.encodeSpace(projectName);
7980
this.appSecret = appSecret;
8081
this.authCode = authCode;
8182
this.callbackUrl = callbackUrl;
@@ -119,7 +120,7 @@ public String getProjectName() {
119120
*/
120121
@Override
121122
public void setProjectName(String projectName) {
122-
this.projectName = projectName;
123+
this.projectName = URLHelper.encodeSpace(projectName);
123124
}
124125

125126
/**
@@ -150,12 +151,12 @@ public void setAccessToken(String accessToken) {
150151
private void authenticate() {
151152
var oauthBuilder = new OAuthAccessTokenBuilder();
152153
try {
153-
if (authorizedToken != null)
154-
if (oauthBuilder.hasTokenExpired(authorizedToken))
155-
authorizedToken = oauthBuilder.getRefreshToken(appSecret, authorizedToken.getRefreshToken(), callbackUrl);
156-
else authorizedToken = oauthBuilder.getAccessToken(appSecret, authCode, callbackUrl);
157-
if (authorizedToken != null)
154+
if (authorizedToken != null) {
155+
authorizedToken = oauthBuilder.hasTokenExpired(authorizedToken) ?
156+
oauthBuilder.getRefreshToken(appSecret, authorizedToken.getRefreshToken(), callbackUrl) :
157+
oauthBuilder.getAccessToken(appSecret, authCode, callbackUrl);
158158
setAccessToken(authorizedToken.getAccessToken());
159+
}
159160
} catch (AzDException e) {
160161
throw new RuntimeException(e);
161162
}

azd/src/main/java/org/azd/authentication/PersonalAccessTokenCredential.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.azd.authentication;
22

3+
import org.azd.helpers.URLHelper;
4+
35
import java.util.Base64;
46
import java.util.Objects;
57

@@ -45,7 +47,7 @@ public PersonalAccessTokenCredential(String organizationUrl, String projectName,
4547
Objects.requireNonNull(personalAccessToken, "Access token cannot be null.");
4648

4749
this.organizationUrl = organizationUrl;
48-
this.projectName = projectName;
50+
this.projectName = URLHelper.encodeSpace(projectName);
4951
setAccessToken(personalAccessToken);
5052
}
5153

@@ -117,6 +119,6 @@ public String getProjectName() {
117119
*/
118120
@Override
119121
public void setProjectName(String projectName) {
120-
this.projectName = projectName;
122+
this.projectName = URLHelper.encodeSpace(projectName);
121123
}
122124
}

azd/src/main/java/org/azd/common/ApiVersion.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ public abstract class ApiVersion {
5151
public static final String SECURITY = "7.1-preview.1";
5252
public static final String SERVICE_ENDPOINTS = "7.1-preview.4";
5353
public static final String SERVICE_HOOKS = "7.1-preview.1";
54+
public static final String TEST_ATTACHMENTS = "7.1";
5455
public static final String TEST_RUNS = "7.1-preview.3";
5556
public static final String TEST_RESULTS = "7.2-preview.6";
5657
public static final String VARIABLE_GROUPS = "7.1-preview.2";

azd/src/main/java/org/azd/connection/Connection.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.azd.connection;
22

33
import org.azd.exceptions.AzDException;
4+
import org.azd.helpers.URLHelper;
45
import org.azd.oauth.OAuthApi;
56
import org.azd.oauth.types.AuthorizedToken;
67

@@ -38,7 +39,7 @@ public Connection() {
3839
*/
3940
private Connection(String organization, String project, String personalAccessToken, AuthorizedToken oauthToken, String appSecret, String appCallBackURL, TokenRefreshedHandler tokenRefreshedHandler) {
4041
this.organization = organization;
41-
this.project = project;
42+
this.project = URLHelper.encodeSpace(project);
4243
this.personalAccessToken = personalAccessToken;
4344
this.oauthToken = oauthToken;
4445
this.appSecret = appSecret;
@@ -158,7 +159,7 @@ public String getProject() {
158159
* @param project pass the project name
159160
*/
160161
public void setProject(String project) {
161-
this.project = project;
162+
this.project = URLHelper.encodeSpace(project);
162163
}
163164

164165
/**
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.azd.enums;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
@JsonIgnoreProperties(ignoreUnknown = true)
7+
public enum AttachmentType {
8+
/**
9+
* Attachment type CodeCoverage.
10+
*/
11+
@JsonProperty("codeCoverage")
12+
CODE_COVERAGE,
13+
/**
14+
* Attachment type ConsoleLog.
15+
*/
16+
@JsonProperty("consoleLog")
17+
CONSOLE_LOG,
18+
/**
19+
* Attachment type GeneralAttachment , use this as default type unless you have other type.
20+
*/
21+
@JsonProperty("generalAttachment")
22+
GENERAL_ATTACHMENT
23+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package org.azd.enums;
2+
3+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
4+
import com.fasterxml.jackson.annotation.JsonProperty;
5+
6+
/**
7+
* Attachment type By Default it will be GeneralAttachment. Used in test attachment.
8+
*/
9+
@JsonIgnoreProperties(ignoreUnknown = true)
10+
public enum TestAttachmentType {
11+
@JsonProperty("generalAttachment")
12+
GENERAL_ATTACHMENT,
13+
@JsonProperty("afnStrip")
14+
AFN_STRIP,
15+
@JsonProperty("bugFilingData")
16+
BUG_FILING_DATA,
17+
@JsonProperty("codeCoverage")
18+
CODE_COVERAGE,
19+
@JsonProperty("intermediateCollectorData")
20+
INTERMEDIATE_COLLECTOR_DATA,
21+
@JsonProperty("runConfig")
22+
RUN_CONFIG,
23+
@JsonProperty("testImpactDetails")
24+
TEST_IMPACT_DETAILS,
25+
@JsonProperty("tmiTestRunDeploymentFiles")
26+
TMI_TEST_RUN_DEPLOYMENT_FILES,
27+
@JsonProperty("tmiTestRunReverseDeploymentFiles")
28+
TMI_TEST_RUN_REVERSE_DEPLOYMENT_FILES,
29+
@JsonProperty("tmiTestResultDetail")
30+
TMI_TEST_RESULT_DETAIL,
31+
@JsonProperty("tmiTestRunSummary")
32+
TMI_TEST_RUN_SUMMARY
33+
}

azd/src/main/java/org/azd/helpers/URLHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class URLHelper {
1717
* @return the encoded string value
1818
*/
1919
public static String encodeSpace(String s) {
20+
if (Utils.isNullOrEmpty(s)) return s;
2021
if (s.contains(" ")) return s.replace(" ", "%20");
2122
return s;
2223
}

0 commit comments

Comments
 (0)