Skip to content

Commit

Permalink
Merge pull request #51 from DANS-KNAW-jp/toString
Browse files Browse the repository at this point in the history
added toString methods for testing convenience
  • Loading branch information
janvanmansum authored Aug 16, 2024
2 parents bd683f5 + 8bf24d0 commit 211dbf8
Show file tree
Hide file tree
Showing 11 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/src/main/java/nl/knaw/dans/lib/dataverse/AdminApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import nl.knaw.dans.lib.dataverse.model.DataMessage;
import nl.knaw.dans.lib.dataverse.model.user.AuthenticatedUser;
Expand All @@ -31,6 +32,7 @@
* @see <a href="https://guides.dataverse.org/en/latest/api/native-api.html#admin" target="_blank">Dataverse documentation</a>
*/
@Slf4j
@ToString
public class AdminApi extends AbstractApi {

private final Path targetBase;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import org.apache.hc.core5.http.io.HttpClientResponseHandler;

Expand All @@ -31,6 +32,7 @@
* @see <a href="https://guides.dataverse.org/en/latest/api/dataaccess.html#basic-file-access" target="_blank">Dataverse documentation</a>
*/
@Slf4j
@ToString
public class BasicFileAccessApi extends AbstractTargetedApi {
BasicFileAccessApi(HttpClientWrapper httpClientWrapper, String id, boolean isPersistentId) {
super(httpClientWrapper, id, isPersistentId, null, Paths.get("api/access/datafile"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@ToString
public class BuiltinUserApi extends AbstractApi {

BuiltinUserApi(HttpClientWrapper httpClientWrapper) {
Expand Down
8 changes: 7 additions & 1 deletion lib/src/main/java/nl/knaw/dans/lib/dataverse/DatasetApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import java.util.Map;
import java.util.Optional;

import static java.text.MessageFormat.format;
import static java.util.Collections.emptyMap;
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;
Expand All @@ -62,6 +63,11 @@ public class DatasetApi extends AbstractTargetedApi {
this(httpClientWrapper, id, isPersistentId, null);
}

@Override
public String toString() {
return format("DatasetApi(id=''{0}, isPersistentId={1})", id, isPersistentId);
}

DatasetApi(HttpClientWrapper httpClientWrapper, String id, boolean isPersistentId, String invocationId) {
super(httpClientWrapper, id, isPersistentId, invocationId, Paths.get("api/datasets/"));
}
Expand Down Expand Up @@ -550,7 +556,7 @@ public DataverseHttpResponse<HashMap> setRetentionPeriod(RetentionPeriod retenti
public DataverseHttpResponse<HashMap> setRetentionPeriod(String json) throws IOException, DataverseException {
return httpClientWrapper.postJsonString(subPath("files/actions/:set-retention"), json, params(emptyMap()), extraHeaders, HashMap.class);
}

/*
* Helper methods
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import nl.knaw.dans.lib.dataverse.model.DataMessage;
import nl.knaw.dans.lib.dataverse.model.Role;
import nl.knaw.dans.lib.dataverse.model.RoleAssignment;
Expand Down Expand Up @@ -43,6 +44,7 @@
*
* @see <a href="https://guides.dataverse.org/en/latest/api/native-api.html#dataverse-collections" target="_blank">Dataverse documentation</a>
*/
@ToString
public class DataverseApi extends AbstractApi {

private static final Logger log = LoggerFactory.getLogger(DataverseApi.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import nl.knaw.dans.lib.dataverse.model.dataset.MetadataField;
import nl.knaw.dans.lib.dataverse.model.dataverse.DataverseItem;
Expand All @@ -30,6 +31,7 @@
* Object that lets your code talk to a Dataverse server.
*/
@Slf4j
@ToString
public class DataverseClient {
private final HttpClientWrapper httpClientWrapper;
private SearchApi searchApi;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/main/java/nl/knaw/dans/lib/dataverse/FileApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import nl.knaw.dans.lib.dataverse.model.dataset.FileList;
import nl.knaw.dans.lib.dataverse.model.file.FileMeta;
Expand All @@ -31,6 +32,7 @@
import static java.util.Collections.emptyMap;

@Slf4j
@ToString
public class FileApi extends AbstractTargetedApi {

FileApi(HttpClientWrapper httpClientWrapper, String id, boolean isPersistentId) {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/main/java/nl/knaw/dans/lib/dataverse/LicenseApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import nl.knaw.dans.lib.dataverse.model.DataMessage;
import nl.knaw.dans.lib.dataverse.model.license.License;
Expand All @@ -31,6 +32,7 @@
* @see <a href="https://guides.dataverse.org/en/latest/api/native-api.html#id188" target="_blank">Dataverse documentation</a>
*/
@Slf4j
@ToString
public class LicenseApi extends AbstractApi {
private final Path targetBase;

Expand Down
2 changes: 2 additions & 0 deletions lib/src/main/java/nl/knaw/dans/lib/dataverse/SearchApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;
import nl.knaw.dans.lib.dataverse.model.search.ResultItem;
import nl.knaw.dans.lib.dataverse.model.search.SearchResult;
Expand All @@ -31,6 +32,7 @@
import java.util.stream.Collectors;

@Slf4j
@ToString
public class SearchApi extends AbstractApi {
private final Path subPath = Paths.get("api", "search");

Expand Down
2 changes: 2 additions & 0 deletions lib/src/main/java/nl/knaw/dans/lib/dataverse/SwordApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;

@Slf4j
@ToString
public class SwordApi extends AbstractApi {

SwordApi(HttpClientWrapper httpClientWrapper) {
Expand Down
2 changes: 2 additions & 0 deletions lib/src/main/java/nl/knaw/dans/lib/dataverse/TokenApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
*/
package nl.knaw.dans.lib.dataverse;

import lombok.ToString;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@ToString
public class TokenApi extends AbstractApi {
TokenApi(HttpClientWrapper httpClientWrapper) {
super(httpClientWrapper);
Expand Down

0 comments on commit 211dbf8

Please sign in to comment.