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

wistefan / tmforum-api / #62

19 Oct 2023 01:12PM UTC coverage: 68.167% (+0.5%) from 67.631%
#62

push

web-flow
Account management api implementation (#34)

* Creating the directories

* Adding pom

* now adding pom, error on last commit

* Account complete implementation, no testing

* Solving problems with git config

* Adding some left out classes and some tests

* Adding FinancialAccount Integration Test and solving some errors on the main classes

* adding Integration Test and solved errors for Party, Bill, Settlement and Financial Account, and BillFormat

* Adding final integration tests and adapting api to query format

* Fixing Event Subscription

* Cleaning the code from comments

---------

Co-authored-by: MVazquez <marcosvazquezcampos@MacBook-Air-de-Marcos.local>

475 of 475 new or added lines in 32 files covered. (100.0%)

3150 of 4621 relevant lines covered (68.17%)

0.68 hits per line

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

0.0
/account/src/main/java/org/fiware/tmforum/account/rest/EventSubscriptionApiController.java
1
package org.fiware.tmforum.account.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.account.api.EventsSubscriptionApi;
8
import org.fiware.account.model.EventSubscriptionInputVO;
9
import org.fiware.account.model.EventSubscriptionVO;
10
import org.fiware.tmforum.common.notification.EventHandler;
11
import org.fiware.tmforum.common.domain.subscription.Subscription;
12
import org.fiware.tmforum.common.querying.QueryParser;
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.account.domain.BillFormat;
17
import org.fiware.tmforum.account.domain.BillingAccount;
18
import org.fiware.tmforum.account.domain.BillingCycleSpecification;
19
import org.fiware.tmforum.account.domain.BillPresentationMedia;
20
import org.fiware.tmforum.account.domain.FinancialAccount;
21
import org.fiware.tmforum.account.domain.PartyAccount;
22
import org.fiware.tmforum.account.domain.SettlementAccount;
23
import org.fiware.tmforum.account.TMForumMapper;
24
import reactor.core.publisher.Mono;
25

26
import java.util.List;
27
import java.util.Map;
28

29
import static java.util.Map.entry;
30
import static org.fiware.tmforum.common.notification.EventConstants.*;
31

32
@Slf4j
×
33
@Controller("${general.basepath:/}")
34
public class EventSubscriptionApiController extends AbstractSubscriptionApiController implements EventsSubscriptionApi {
35
    private final TMForumMapper tmForumMapper;
36
    private static final Map<String, String> EVENT_GROUP_TO_ENTITY_NAME_MAPPING = Map.ofEntries(
×
37
            entry(EVENT_GROUP_BILL_FORMAT, BillFormat.TYPE_BILLF),
×
38
            entry(EVENT_GROUP_BILLING_ACCOUNT, BillingAccount.TYPE_PARTYAC),
×
39
            entry(EVENT_GROUP_BILLING_CYCLE_SPECIFICATION, BillingCycleSpecification.TYPE_BILLCL),
×
40
            entry(EVENT_GROUP_BILL_PRESENTATION_MEDIA, BillPresentationMedia.TYPE_BILLPM),
×
41
            entry(EVENT_GROUP_FINANCIAL_ACCOUNT, FinancialAccount.TYPE_FINANCIALAC),
×
42
            entry(EVENT_GROUP_PARTY_ACCOUNT, PartyAccount.TYPE_PARTYAC),
×
43
            entry(EVENT_GROUP_SETTLEMENT_ACCOUNT, SettlementAccount.TYPE_PARTYAC)
×
44
    );
45
    private static final List<String> EVENT_GROUPS = List.of(EVENT_GROUP_BILL_FORMAT, /*EVENT_GROUP_BILLING_ACCOUNT,*/
×
46
    EVENT_GROUP_BILLING_CYCLE_SPECIFICATION, EVENT_GROUP_BILL_PRESENTATION_MEDIA, EVENT_GROUP_FINANCIAL_ACCOUNT,
47
            EVENT_GROUP_PARTY_ACCOUNT, EVENT_GROUP_SETTLEMENT_ACCOUNT);
48

49
    public EventSubscriptionApiController(QueryParser queryParser, ReferenceValidationService validationService,
50
                                          TmForumRepository repository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
51
        super(queryParser, validationService, repository, EVENT_GROUP_TO_ENTITY_NAME_MAPPING, eventHandler);
×
52
        this.tmForumMapper = tmForumMapper;
×
53
    }
×
54

55
    @Override
56
    public Mono<HttpResponse<EventSubscriptionVO>> registerListener(
57
            @NonNull EventSubscriptionInputVO eventSubscriptionInputVO) {
58
        Subscription subscription = buildSubscription(eventSubscriptionInputVO.getCallback(),
×
59
                eventSubscriptionInputVO.getQuery(), EVENT_GROUPS);
×
60

61
        return create(subscription)
×
62
                .map(tmForumMapper::map)
×
63
                .map(HttpResponse::created);
×
64
    }
65

66
    @Override
67
    public Mono<HttpResponse<Object>> unregisterListener(@NonNull String id) {
68
        return delete(id);
×
69
    }
70
}
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