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

wistefan / tmforum-api / #61

18 Oct 2023 12:35PM UTC coverage: 67.631% (+0.1%) from 67.488%
#61

push

web-flow
Configurable NGSI-LD Query format (#32)

* Build different NGSI queries depending if the attr is relationship or property

* Add tests to validate query parser with relationships

* Add missing testing class

* Fix bug removing well known attributes in query parser using fixed-size list

* Use scorpio OR queries

* Fix the type of product spec bundle references

* Update the type of product specs relationships

* Fix errors mapping categories and product specs as references

* Fix config issues with ProductOfferingTerm

* Allow to configure NGSI-LD query options

* Add default NGSI-LD query configuration

* fix config

* fix test call

* fix it

---------

Co-authored-by: Stefan Wiedemann <wistefan@googlemail.com>

65 of 65 new or added lines in 47 files covered. (100.0%)

2804 of 4146 relevant lines covered (67.63%)

0.68 hits per line

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

0.0
/party-catalog/src/main/java/org/fiware/tmforum/party/rest/EventSubscriptionApiController.java
1
package org.fiware.tmforum.party.rest;
2

3
import io.micronaut.core.annotation.NonNull;
4
import io.micronaut.http.HttpResponse;
5
import io.micronaut.http.annotation.Controller;
6
import lombok.extern.slf4j.Slf4j;
7
import org.fiware.party.api.EventsSubscriptionApi;
8
import org.fiware.party.model.EventSubscriptionInputVO;
9
import org.fiware.party.model.EventSubscriptionVO;
10
import org.fiware.tmforum.common.notification.EventHandler;
11
import org.fiware.tmforum.common.querying.QueryParser;
12
import org.fiware.tmforum.common.domain.subscription.Subscription;
13
import org.fiware.tmforum.common.repository.TmForumRepository;
14
import org.fiware.tmforum.common.rest.AbstractSubscriptionApiController;
15
import org.fiware.tmforum.common.validation.ReferenceValidationService;
16
import org.fiware.tmforum.party.TMForumMapper;
17
import org.fiware.tmforum.party.domain.individual.Individual;
18
import org.fiware.tmforum.party.domain.organization.Organization;
19
import reactor.core.publisher.Mono;
20

21
import java.util.List;
22
import java.util.Map;
23

24
import static java.util.Map.entry;
25
import static org.fiware.tmforum.common.notification.EventConstants.EVENT_GROUP_INDIVIDUAL;
26
import static org.fiware.tmforum.common.notification.EventConstants.EVENT_GROUP_ORGANIZATION;
27

28
@Slf4j
×
29
@Controller("${general.basepath:/}")
30
public class EventSubscriptionApiController extends AbstractSubscriptionApiController implements EventsSubscriptionApi {
31
    private final TMForumMapper tmForumMapper;
32
        private static final Map<String, String> EVENT_GROUP_TO_ENTITY_NAME_MAPPING = Map.ofEntries(
×
33
                entry(EVENT_GROUP_INDIVIDUAL, Individual.TYPE_INDIVIDUAL),
×
34
                entry(EVENT_GROUP_ORGANIZATION, Organization.TYPE_ORGANIZATION)
×
35
        );
36
    private static final List<String> EVENT_GROUPS = List.of(EVENT_GROUP_INDIVIDUAL, EVENT_GROUP_ORGANIZATION);
×
37

38
    public EventSubscriptionApiController(QueryParser queryParser, ReferenceValidationService validationService,
39
                                          TmForumRepository repository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
40
        super(queryParser, validationService, repository, EVENT_GROUP_TO_ENTITY_NAME_MAPPING, eventHandler);
×
41
        this.tmForumMapper = tmForumMapper;
×
42
    }
×
43

44
    @Override
45
    public Mono<HttpResponse<EventSubscriptionVO>> registerListener(
46
            @NonNull EventSubscriptionInputVO eventSubscriptionInputVO) {
47
        Subscription subscription = buildSubscription(eventSubscriptionInputVO.getCallback(),
×
48
                eventSubscriptionInputVO.getQuery(), EVENT_GROUPS);
×
49

50
        return create(subscription)
×
51
                .map(tmForumMapper::map)
×
52
                .map(HttpResponse::created);
×
53
    }
54

55
    @Override
56
    public Mono<HttpResponse<Object>> unregisterListener(@NonNull String id) {
57
        return delete(id);
×
58
    }
59
}
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

© 2025 Coveralls, Inc