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

wistefan / tmforum-api / #49

29 Sep 2023 06:20AM UTC coverage: 67.488% (-4.3%) from 71.815%
#49

push

web-flow
Notifications (#23)

* Squashed commits

* Added cache invalidation for entity deletion

* Updated error message

618 of 618 new or added lines in 86 files covered. (100.0%)

2794 of 4140 relevant lines covered (67.49%)

0.67 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.domain.subscription.Subscription;
15
import org.fiware.tmforum.common.repository.TmForumRepository;
16
import org.fiware.tmforum.common.rest.AbstractSubscriptionApiController;
17
import org.fiware.tmforum.common.validation.ReferenceValidationService;
18
import reactor.core.publisher.Mono;
19

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

23
import static java.util.Map.entry;
24
import static org.fiware.tmforum.common.notification.EventConstants.EVENT_GROUP_AGREEMENT;
25
import static org.fiware.tmforum.common.notification.EventConstants.EVENT_GROUP_AGREEMENT_SPECIFICATION;
26

27
@Slf4j
×
28
@Controller("${general.basepath:/}")
29
public class EventSubscriptionApiController extends AbstractSubscriptionApiController implements EventsSubscriptionApi {
30
    private final TMForumMapper tmForumMapper;
31
        private static final Map<String, String> EVENT_GROUP_TO_ENTITY_NAME_MAPPING = Map.ofEntries(
×
32
                entry(EVENT_GROUP_AGREEMENT, Agreement.TYPE_AG),
×
33
                entry(EVENT_GROUP_AGREEMENT_SPECIFICATION, AgreementSpecification.TYPE_AGSP)
×
34
        );
35
    private static final List<String> EVENT_GROUPS = List.of(
×
36
            EVENT_GROUP_AGREEMENT, EVENT_GROUP_AGREEMENT_SPECIFICATION);
37

38
    public EventSubscriptionApiController(ReferenceValidationService validationService,
39
                                          TmForumRepository repository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
40
        super(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