• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FIWARE / contract-management / #26

28 Jan 2025 10:59AM UTC coverage: 0.982% (-0.6%) from 1.629%
#26

push

web-flow
Merge pull request #3 from FIWARE/tpp-integration

Tpp integration

99 of 500 new or added lines in 14 files covered. (19.8%)

4 existing lines in 3 files now uncovered.

281 of 28625 relevant lines covered (0.98%)

0.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.75
/src/main/java/org/fiware/iam/dsp/RainbowAdapter.java
1
package org.fiware.iam.dsp;
2

3
import com.fasterxml.jackson.databind.ObjectMapper;
4
import io.micronaut.http.HttpResponse;
5
import io.micronaut.http.HttpStatus;
6
import jakarta.inject.Singleton;
7
import lombok.RequiredArgsConstructor;
8
import lombok.extern.slf4j.Slf4j;
9
import org.fiware.iam.exception.RainbowException;
10
import org.fiware.rainbow.api.AgreementApiClient;
11
import org.fiware.rainbow.model.AgreementCreateVO;
12
import org.fiware.rainbow.model.AgreementVO;
13
import reactor.core.publisher.Mono;
14

15

16
/**
17
 * Adapter to handle communication with Rainbow.
18
 */
19
@Singleton
20
@RequiredArgsConstructor
21
@Slf4j
1✔
22
public class RainbowAdapter {
23

24
        private final AgreementApiClient agreementApiClient;
25
        private final ObjectMapper objectMapper;
26

27
        /**
28
         * Create the agreement for the given organization and offer
29
         */
30
        public Mono<AgreementVO> createAgreement(String organizationId, String offeringId) {
31
                AgreementCreateVO agreementCreateVO = new AgreementCreateVO()
1✔
32
                                .identity(organizationId)
1✔
33
                                .dataServiceId(offeringId);
1✔
34

35
                return agreementApiClient
1✔
36
                                .createAgreement(agreementCreateVO)
1✔
37
                                .map(HttpResponse::body)
1✔
38
                                .map(body -> objectMapper.convertValue(body, AgreementVO.class))
1✔
39
                                .onErrorMap(t -> new RainbowException("Was not able to create agreement"));
1✔
40
        }
41

42
        /**
43
         * Delete the agreement with the given id
44
         */
45
        public Mono<Boolean> deleteAgreement(String agreementId) {
46
                return agreementApiClient.deleteAgreementById(agreementId)
1✔
47
                                .map(objectHttpResponse -> {
1✔
48
                                        if (objectHttpResponse.status().equals(HttpStatus.ACCEPTED)) {
1✔
49
                                                return true;
1✔
50
                                        }
51
                                        return false;
1✔
52
                                })
53
                                .onErrorResume(t -> {
1✔
NEW
54
                                        return Mono.just(false);
×
55
                                });
56
        }
57

58
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc