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

Feature/420 add contractagreements #474

Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -19,7 +19,6 @@
********************************************************************************/
package org.eclipse.tractusx.irs.edc.client.contract.service;

import java.util.Arrays;
import java.util.List;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -48,7 +47,7 @@
public class EdcContractAgreementService {

public static final String EDC_REQUEST_SUFFIX = "/request";
public static final String EDC_CONTRACT_AGREEMENT_ID = "https://w3id.org/edc/v0.0.1/ns/id";
public static final String EDC_CONTRACT_AGREEMENT_ID = "id";
private final EdcConfiguration config;
private final RestTemplate edcRestTemplate;

Expand All @@ -58,7 +57,7 @@ public EdcContractAgreementService(final EdcConfiguration config,
this.edcRestTemplate = edcRestTemplate;
}

public List<EdcContractAgreementsResponse> getContractAgreements(final String... contractAgreementIds)
public List<EdcContractAgreementsResponse> getContractAgreements(final List<String> contractAgreementIds)
throws ContractAgreementException {

final EdcContractAgreementRequest edcContractAgreementRequest = buildContractAgreementRequest(
Expand Down Expand Up @@ -89,9 +88,9 @@ public EdcContractAgreementNegotiationResponse getContractAgreementNegotiation(f
return contractNegotiationResponseEntity.getBody();
}

private EdcContractAgreementRequest buildContractAgreementRequest(final String... contractAgreementIds) {
private EdcContractAgreementRequest buildContractAgreementRequest(final List<String> contractAgreementIds) {

final List<EdcContractAgreementFilterExpression> list = Arrays.stream(contractAgreementIds)
final List<EdcContractAgreementFilterExpression> list = contractAgreementIds.stream()
.map(s -> new EdcContractAgreementFilterExpression(
EDC_CONTRACT_AGREEMENT_ID, "=", s))
.toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ void setUp() {
@Test
void shouldReturnContractAgreements() throws ContractAgreementException {
//GIVEN
String[] contractAgreementIds = { "contractAgreementId" };
List<String> contractAgreementIds = List.of("contractAgreementId");

final EdcContractAgreementsResponse[] edcContractAgreementsResponse = new EdcContractAgreementsResponse[1];
edcContractAgreementsResponse[0] = EdcContractAgreementsResponse.builder().contractAgreementId("id")
Expand All @@ -93,7 +93,7 @@ void shouldReturnContractAgreements() throws ContractAgreementException {
@Test
void shouldThrowContractAgreementExceptionWhenResponseBodyIsEmtpy() {
//GIVEN
String[] contractAgreementIds = { "contractAgreementId" };
List<String> contractAgreementIds = List.of("contractAgreementId");

when(restTemplate.exchange(anyString(), any(), any(), eq(EdcContractAgreementsResponse[].class))).thenReturn(
ResponseEntity.ok(new EdcContractAgreementsResponse[0]));
Expand Down
Loading
Loading