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

FIWARE / contract-management / #69

30 Oct 2025 07:38AM UTC coverage: 1.686% (+0.04%) from 1.651%
#69

Pull #12

wistefan
improve organization creation and cleanup
Pull Request #12: Support for central marketplace and policy creation

117 of 1238 new or added lines in 31 files covered. (9.45%)

5 existing lines in 2 files now uncovered.

587 of 34807 relevant lines covered (1.69%)

0.02 hits per line

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

0.0
/src/main/java/org/fiware/iam/tmforum/handlers/CatalogEventHandler.java
1
package org.fiware.iam.tmforum.handlers;
2

3
import com.fasterxml.jackson.databind.ObjectMapper;
4
import io.micronaut.context.annotation.Requires;
5
import io.micronaut.http.HttpResponse;
6
import jakarta.inject.Singleton;
7
import lombok.RequiredArgsConstructor;
8
import lombok.extern.slf4j.Slf4j;
9
import org.fiware.iam.configuration.GeneralProperties;
10
import org.fiware.iam.handlers.CatalogHandler;
11
import org.fiware.iam.tmforum.productcatalog.model.*;
12
import reactor.core.publisher.Mono;
13

14
import java.util.List;
15
import java.util.Map;
16
import java.util.Optional;
17

18
@Requires(condition = GeneralProperties.TmForumCondition.class)
19
@RequiredArgsConstructor
20
@Singleton
21
@Slf4j
×
22
public class CatalogEventHandler implements TMForumEventHandler {
23

24
    private static final String CREATE_EVENT = "CatalogCreateEvent";
25
    private static final String DELETE_EVENT = "CatalogDeleteEvent";
26
    private static final String STATE_CHANGE_EVENT = "CatalogStateChangeEvent";
27

NEW
28
    private static final List<String> SUPPORTED_EVENT_TYPES = List.of(CREATE_EVENT, DELETE_EVENT, STATE_CHANGE_EVENT);
×
29

30
    private final ObjectMapper objectMapper;
31
    private final List<CatalogHandler> catalogHandlers;
32

33
    @Override
34
    public boolean isEventTypeSupported(String eventType) {
NEW
35
        return SUPPORTED_EVENT_TYPES.contains(eventType);
×
36
    }
37

38
    @Override
39
    public Mono<HttpResponse<?>> handleEvent(String eventType, Map<String, Object> event) {
NEW
40
        return switch (eventType) {
×
NEW
41
            case CREATE_EVENT -> handleCatalogCreation(event);
×
NEW
42
            case STATE_CHANGE_EVENT -> handleCatalogStateChange(event);
×
NEW
43
            case DELETE_EVENT -> handleCatalogDeletion(event);
×
NEW
44
            default -> throw new IllegalArgumentException("Even type %s is not supported.".formatted(eventType));
×
45
        };
46
    }
47

48
    private Mono<HttpResponse<?>> handleCatalogCreation(Map<String, Object> createEvent) {
NEW
49
        CatalogCreateEventVO catalogCreateEventVO = objectMapper.convertValue(createEvent, CatalogCreateEventVO.class);
×
NEW
50
        CatalogVO catalogVO = Optional.ofNullable(catalogCreateEventVO.getEvent())
×
NEW
51
                .map(CatalogCreateEventPayloadVO::getCatalog)
×
NEW
52
                .orElseThrow(() -> new IllegalArgumentException("The event does not contain a catalog."));
×
53

NEW
54
        List<Mono<HttpResponse<?>>> responses = catalogHandlers.stream()
×
NEW
55
                .map(handler -> handler.handleCatalogCreation(catalogVO))
×
NEW
56
                .toList();
×
57

NEW
58
        return zipToResponse(responses);
×
59

60
    }
61

62

63
    private Mono<HttpResponse<?>> handleCatalogStateChange(Map<String, Object> createEvent) {
NEW
64
        CatalogStateChangeEventVO catalogStateChangeEventVO = objectMapper.convertValue(createEvent, CatalogStateChangeEventVO.class);
×
NEW
65
        CatalogVO catalogVO = Optional.ofNullable(catalogStateChangeEventVO.getEvent())
×
NEW
66
                .map(CatalogStateChangeEventPayloadVO::getCatalog)
×
NEW
67
                .orElseThrow(() -> new IllegalArgumentException("The event does not contain a catalog."));
×
68

NEW
69
        List<Mono<HttpResponse<?>>> responses = catalogHandlers.stream()
×
NEW
70
                .map(handler -> handler.handleCatalogStateChange(catalogVO))
×
NEW
71
                .toList();
×
72

NEW
73
        return zipToResponse(responses);
×
74

75
    }
76

77
    private Mono<HttpResponse<?>> handleCatalogDeletion(Map<String, Object> deleteEvent) {
NEW
78
        CatalogDeleteEventVO catalogDeleteEventVO = objectMapper.convertValue(deleteEvent, CatalogDeleteEventVO.class);
×
NEW
79
        CatalogVO catalogVO = Optional.ofNullable(catalogDeleteEventVO.getEvent())
×
NEW
80
                .map(CatalogDeleteEventPayloadVO::getCatalog)
×
NEW
81
                .orElseThrow(() -> new IllegalArgumentException("The event does not contain a catalog."));
×
NEW
82
        List<Mono<HttpResponse<?>>> responses = catalogHandlers.stream()
×
NEW
83
                .map(handler -> handler.handleCatalogStateChange(catalogVO))
×
NEW
84
                .toList();
×
85

NEW
86
        return zipToResponse(responses);
×
87
    }
88
}
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