• 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
/agreement/src/main/java/org/fiware/tmforum/agreement/rest/EventSubscriptionApiController.java
1
package org.fiware.tmforum.agreement.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.agreement.api.EventsSubscriptionApi;
8
import org.fiware.agreement.model.EventSubscriptionInputVO;
9
import org.fiware.agreement.model.EventSubscriptionVO;
10
import org.fiware.tmforum.agreement.TMForumMapper;
11
import org.fiware.tmforum.agreement.domain.Agreement;
12
import org.fiware.tmforum.agreement.domain.AgreementSpecification;
13
import org.fiware.tmforum.common.notification.EventHandler;
14
import org.fiware.tmforum.common.querying.QueryParser;
15
import org.fiware.tmforum.common.domain.subscription.Subscription;
16
import org.fiware.tmforum.common.repository.TmForumRepository;
17
import org.fiware.tmforum.common.rest.AbstractSubscriptionApiController;
18
import org.fiware.tmforum.common.validation.ReferenceValidationService;
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_AGREEMENT;
26
import static org.fiware.tmforum.common.notification.EventConstants.EVENT_GROUP_AGREEMENT_SPECIFICATION;
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_AGREEMENT, Agreement.TYPE_AG),
×
34
                entry(EVENT_GROUP_AGREEMENT_SPECIFICATION, AgreementSpecification.TYPE_AGSP)
×
35
        );
36
    private static final List<String> EVENT_GROUPS = List.of(
×
37
            EVENT_GROUP_AGREEMENT, EVENT_GROUP_AGREEMENT_SPECIFICATION);
38

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

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

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

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