Skip to content

Commit

Permalink
Merge pull request #805 from eclipse-tractusx/main
Browse files Browse the repository at this point in the history
Sync with upstream
  • Loading branch information
dsmf authored Mar 7, 2024
2 parents 47b86cc + 460c29c commit fdf4c17
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
* EdcContractAgreementRequest represents the request to management/v2/contractagreements/request
*/
public record EdcContractAgreementRequest(@JsonProperty(
"https://w3id.org/edc/v0.0.1/ns/filterExpression") List<EdcContractAgreementFilterExpression> edcContractAgreementFilterExpressions) {
"https://w3id.org/edc/v0.0.1/ns/filterExpression") EdcContractAgreementFilterExpression edcContractAgreementFilterExpressions) {
/**
* EdcContractAgreementFilterExpression represents the filterExpression
* for EdcContractAgreementRequest
*/
public record EdcContractAgreementFilterExpression(
@JsonProperty("https://w3id.org/edc/v0.0.1/ns/operandLeft") String operandLeft,
@JsonProperty("https://w3id.org/edc/v0.0.1/ns/operator") String operator,
@JsonProperty("https://w3id.org/edc/v0.0.1/ns/operandRight") String operandRight) {
@JsonProperty("https://w3id.org/edc/v0.0.1/ns/operandRight") List<String> operandRight) {

}
}
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,14 +88,12 @@ 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)
.map(s -> new EdcContractAgreementFilterExpression(
EDC_CONTRACT_AGREEMENT_ID, "=", s))
.toList();
final EdcContractAgreementFilterExpression edcContractAgreementFilterExpression = new EdcContractAgreementFilterExpression(
EDC_CONTRACT_AGREEMENT_ID, "in", contractAgreementIds);

return new EdcContractAgreementRequest(list);
return new EdcContractAgreementRequest(edcContractAgreementFilterExpression);
}

private HttpHeaders headers() {
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

0 comments on commit fdf4c17

Please sign in to comment.