forked from eclipse-tractusx/item-relationship-service
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #359 from catenax-ng/feature/TRI-1332-fix-decentra…
…l-flow feat(irs-api): Fix DiscoveryResponse
- Loading branch information
Showing
12 changed files
with
207 additions
and
81 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
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
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
31 changes: 31 additions & 0 deletions
31
.../src/main/java/org/eclipse/tractusx/irs/aaswrapper/registry/domain/DiscoveryResponse.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,31 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021,2022,2023 | ||
* 2022: ZF Friedrichshafen AG | ||
* 2022: ISTOS GmbH | ||
* 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* 2022,2023: BOSCH AG | ||
* Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. * | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.aaswrapper.registry.domain; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* The result of searching the Discovery Finder. Contains a list of {@link DiscoveryEndpoint}s. | ||
*/ | ||
public record DiscoveryResponse(List<DiscoveryEndpoint> endpoints) { | ||
} |
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
80 changes: 80 additions & 0 deletions
80
...va/org/eclipse/tractusx/irs/aaswrapper/registry/domain/DiscoveryFinderClientImplTest.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,80 @@ | ||
/******************************************************************************** | ||
* Copyright (c) 2021,2022,2023 | ||
* 2022: ZF Friedrichshafen AG | ||
* 2022: ISTOS GmbH | ||
* 2022,2023: Bayerische Motoren Werke Aktiengesellschaft (BMW AG) | ||
* 2022,2023: BOSCH AG | ||
* Copyright (c) 2021,2022,2023 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* 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. * | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations | ||
* under the License. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
********************************************************************************/ | ||
package org.eclipse.tractusx.irs.aaswrapper.registry.domain; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.mockito.Mockito.when; | ||
|
||
import java.util.List; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.ExtendWith; | ||
import org.mockito.Mock; | ||
import org.mockito.junit.jupiter.MockitoExtension; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
@ExtendWith(MockitoExtension.class) | ||
class DiscoveryFinderClientImplTest { | ||
@Mock | ||
private RestTemplate restTemplate; | ||
|
||
@Test | ||
void shouldReturnEmptyListWhenDiscoveryReturnsNull() { | ||
// Arrange | ||
final String discoveryFinderUrl = "https://discovery.mock/api/administration/connectors/discovery/search"; | ||
final String providerUrl = "https://discovery.mock/api/administration/connectors/discovery"; | ||
final List<String> bpns = List.of("BPN123"); | ||
final DiscoveryFinderClientImpl discoveryFinderClient = new DiscoveryFinderClientImpl(discoveryFinderUrl, | ||
restTemplate); | ||
when(restTemplate.postForObject(providerUrl, bpns, EdcDiscoveryResult[].class)).thenReturn(null); | ||
|
||
// Act | ||
final List<EdcDiscoveryResult> connectorEndpoints = discoveryFinderClient.findConnectorEndpoints(providerUrl, | ||
bpns); | ||
|
||
// Assert | ||
assertThat(connectorEndpoints).isNotNull().isEmpty(); | ||
} | ||
|
||
@Test | ||
void shouldReturnEmptyListWhenDiscoveryReturnsEmpty() { | ||
// Arrange | ||
final String discoveryFinderUrl = "https://discovery.mock/api/administration/connectors/discovery/search"; | ||
final String providerUrl = "https://discovery.mock/api/administration/connectors/discovery"; | ||
final List<String> bpns = List.of("BPN123"); | ||
final DiscoveryFinderClientImpl discoveryFinderClient = new DiscoveryFinderClientImpl(discoveryFinderUrl, | ||
restTemplate); | ||
final EdcDiscoveryResult[] discoveryResponse = { new EdcDiscoveryResult("BPN123", | ||
List.of("https://provider.edc")) | ||
}; | ||
|
||
when(restTemplate.postForObject(providerUrl, bpns, EdcDiscoveryResult[].class)).thenReturn(discoveryResponse); | ||
|
||
// Act | ||
final List<EdcDiscoveryResult> connectorEndpoints = discoveryFinderClient.findConnectorEndpoints(providerUrl, | ||
bpns); | ||
|
||
// Assert | ||
assertThat(connectorEndpoints).isNotNull().hasSize(1); | ||
} | ||
} |
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
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
Oops, something went wrong.