-
Notifications
You must be signed in to change notification settings - Fork 245
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
70 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
...spi/src/test/java/org/eclipse/edc/connector/dataplane/spi/pipeline/StreamFailureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* 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.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.stream.Stream; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.eclipse.edc.connector.dataplane.spi.pipeline.StreamFailure.Reason.GENERAL_ERROR; | ||
import static org.eclipse.edc.connector.dataplane.spi.pipeline.StreamFailure.Reason.NOT_AUTHORIZED; | ||
import static org.eclipse.edc.connector.dataplane.spi.pipeline.StreamFailure.Reason.NOT_FOUND; | ||
|
||
public class StreamFailureTest { | ||
private StreamFailure streamFailure; | ||
private String failureMessage; | ||
|
||
@BeforeEach | ||
void setup() { | ||
failureMessage = "FAILURE MESSAGE"; | ||
} | ||
|
||
@Test | ||
void verify_with_failureDetail_message_startWith_notFound() { | ||
|
||
streamFailure = new StreamFailure(List.of(failureMessage), NOT_FOUND); | ||
assertThat(streamFailure.getFailureDetail()).startsWith(NOT_FOUND.toString()); | ||
} | ||
|
||
@Test | ||
void verify_with_failureDetail_message_startWith_notAuthorized() { | ||
|
||
streamFailure = new StreamFailure(List.of(failureMessage), NOT_AUTHORIZED); | ||
assertThat(streamFailure.getFailureDetail()).startsWith(NOT_AUTHORIZED.toString()); | ||
} | ||
|
||
@Test | ||
void verify_with_failureDetail_message_startWith_generalError() { | ||
|
||
streamFailure = new StreamFailure(List.of(failureMessage), GENERAL_ERROR); | ||
assertThat(streamFailure.getFailureDetail()).startsWith(GENERAL_ERROR.toString()); | ||
} | ||
|
||
@Test | ||
void verify_with_failureDetail_message_only_contains_reason_when_message_is_empty() { | ||
|
||
assertThat(Stream.of(StreamFailure.Reason.values()) | ||
.allMatch(enumVal -> { | ||
return new StreamFailure(Collections.emptyList(), enumVal) | ||
.getFailureDetail() | ||
.equals(enumVal.toString()); | ||
})).isTrue(); | ||
} | ||
} |