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

feat: Enhancing debug information for HttpDataSource transfers #4303

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ public StreamFailure(List<String> messages, Reason reason) {
this.reason = reason;
}

@Override
public String getFailureDetail() {
zub4t marked this conversation as resolved.
Show resolved Hide resolved
var str = super.getFailureDetail();
return (str != null && !str.isEmpty()) ? (reason + ": " + str) : (reason + "");
}

zub4t marked this conversation as resolved.
Show resolved Hide resolved
public Reason getReason() {
return reason;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Copyright (c) 2024 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://www.apache.org/licenses/LICENSE-2.0
*
* SPDX-License-Identifier: Apache-2.0
*
* Contributors:
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG) - Initial implementation
*
*/

package org.eclipse.edc.connector.dataplane.spi.pipeline;

import org.junit.jupiter.api.Test;

import java.util.Collections;
import java.util.List;

import static org.assertj.core.api.Assertions.assertThat;
import static org.eclipse.edc.connector.dataplane.spi.pipeline.StreamFailure.Reason.NOT_FOUND;

public class StreamFailureTest {
private final String failureMessage = "failure message";
zub4t marked this conversation as resolved.
Show resolved Hide resolved

@Test
void verify_with_failureDetail_message_starts_with_reason() {
assertThat(new StreamFailure(List.of(failureMessage), NOT_FOUND)
.getFailureDetail()
.startsWith(NOT_FOUND.toString())
).isTrue();
zub4t marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
void verify_with_failureDetail_message_only_contains_reason_when_message_is_empty() {
zub4t marked this conversation as resolved.
Show resolved Hide resolved
assertThat(new StreamFailure(Collections.emptyList(), NOT_FOUND)
.getFailureDetail()
.equals(NOT_FOUND.toString())
).isTrue();
}
}