Skip to content

Commit

Permalink
Context broker notifications (#43)
Browse files Browse the repository at this point in the history
* Renamed class

* Added ngsi-subscription classes

* Added ngsi-subscription handling logic

* Added ngsi-subscription handling logic

* Added ngsi-subscription handling logic

* Added ngsi-subscription handling logic

* Moved callback method to superclass

* Updated event handler

* Updated fields filtering in the event handler

* Separated tmforum and ngsi-ld event handlers

* Refactored ngsi-ld subscription callback handling
  • Loading branch information
beknazaresenbek authored Jan 30, 2024
1 parent 6e642ee commit 541a03c
Show file tree
Hide file tree
Showing 161 changed files with 1,524 additions and 1,371 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/conformance-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
matrix:
# product-catalog is not included, since the tests currently are not accessible.
# customer-management, customer-bill-management, product-ordering-management is not included, since the tests contain invalid references.
module: [ party-catalog, product-inventory, resource-catalog, resource-function-activation, resource-inventory, service-catalog ]
module: [ party-catalog, party-role, product-inventory, resource-catalog, resource-function-activation, resource-inventory, service-catalog ]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/parallel-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
fail-fast: false
matrix:
module: [ customer-bill-management, customer-management, party-catalog, product-catalog, product-inventory, product-ordering-management, resource-catalog, resource-function-activation, resource-inventory, service-catalog ]
module: [ customer-bill-management, customer-management, party-catalog, party-role, product-catalog, product-inventory, product-ordering-management, resource-catalog, resource-function-activation, resource-inventory, service-catalog ]

steps:
- uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-caches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ jobs:
- name: Execute tests
id: test
run: |
mvn clean test integration-test verify -Dcache=${{matrix.cache}}
mvn clean test integration-test verify -Dbroker=scorpio -Dcache=${{matrix.cache}}
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.fiware.tmforum.account;

import org.fiware.tmforum.common.domain.subscription.Subscription;
import org.fiware.tmforum.common.domain.subscription.TMForumSubscription;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.fiware.tmforum.common.domain.TimePeriod;
import io.github.wistefan.mapping.MappingException;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.account.model.*;
import org.fiware.tmforum.account.domain.*;
import java.net.MalformedURLException;
Expand Down Expand Up @@ -125,7 +123,7 @@ public interface TMForumMapper {
SettlementAccountVO map(SettlementAccountUpdateVO settlementAccountUpdateVO, String id);

@Mapping(target = "query", source = "rawQuery")
EventSubscriptionVO map(Subscription subscription);
EventSubscriptionVO map(TMForumSubscription subscription);

TimePeriod map(TimePeriodVO value);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
import io.micronaut.http.annotation.Controller;
import lombok.extern.slf4j.Slf4j;
import org.fiware.account.api.BillFormatApi;
import org.fiware.account.api.BillFormatApi;
import org.fiware.account.model.BillFormatCreateVO;
import org.fiware.account.model.BillFormatUpdateVO;
import org.fiware.account.model.BillFormatVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillFormat;
import org.fiware.tmforum.common.exception.TmForumException;
import org.fiware.tmforum.common.exception.TmForumExceptionReason;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.common.validation.ReferencedEntity;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillFormat;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
Expand All @@ -33,7 +32,8 @@ public class BillFormatApiController extends AbstractApiController<BillFormat> i
private final TMForumMapper tmForumMapper;

public BillFormatApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository productBillFormatRepository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
TmForumRepository productBillFormatRepository, TMForumMapper tmForumMapper,
TMForumEventHandler eventHandler) {
super(queryParser, validationService, productBillFormatRepository, eventHandler);
this.tmForumMapper = tmForumMapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import org.fiware.account.model.BillPresentationMediaCreateVO;
import org.fiware.account.model.BillPresentationMediaUpdateVO;
import org.fiware.account.model.BillPresentationMediaVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillPresentationMedia;
import org.fiware.tmforum.common.exception.TmForumException;
import org.fiware.tmforum.common.exception.TmForumExceptionReason;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.common.validation.ReferencedEntity;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillPresentationMedia;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
Expand All @@ -32,7 +32,8 @@ public class BillPresentationMediaApiController extends AbstractApiController<Bi
private final TMForumMapper tmForumMapper;

public BillPresentationMediaApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository productBillPresentationMediaRepository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
TmForumRepository productBillPresentationMediaRepository,
TMForumMapper tmForumMapper, TMForumEventHandler eventHandler) {
super(queryParser, validationService, productBillPresentationMediaRepository, eventHandler);
this.tmForumMapper = tmForumMapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,20 @@
import io.micronaut.http.annotation.Controller;
import lombok.extern.slf4j.Slf4j;
import org.fiware.account.api.BillingAccountApi;
import org.fiware.account.api.BillingAccountApi;
import org.fiware.account.model.BillingAccountCreateVO;
import org.fiware.account.model.BillingAccountUpdateVO;
import org.fiware.account.model.BillingAccountVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillingAccount;
import org.fiware.tmforum.common.exception.TmForumException;
import org.fiware.tmforum.common.exception.TmForumExceptionReason;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.common.validation.ReferencedEntity;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillingAccount;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
Expand All @@ -34,7 +33,8 @@ public class BillingAccountApiController extends AbstractApiController<BillingAc
private final TMForumMapper tmForumMapper;

public BillingAccountApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository productBillingAccountRepository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
TmForumRepository productBillingAccountRepository, TMForumMapper tmForumMapper,
TMForumEventHandler eventHandler) {
super(queryParser, validationService, productBillingAccountRepository, eventHandler);
this.tmForumMapper = tmForumMapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import org.fiware.account.model.BillingCycleSpecificationCreateVO;
import org.fiware.account.model.BillingCycleSpecificationUpdateVO;
import org.fiware.account.model.BillingCycleSpecificationVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillingCycleSpecification;
import org.fiware.tmforum.common.exception.TmForumException;
import org.fiware.tmforum.common.exception.TmForumExceptionReason;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.common.validation.ReferencedEntity;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.BillingCycleSpecification;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
Expand All @@ -32,7 +32,8 @@ public class BillingCycleSpecificationApiController extends AbstractApiControlle
private final TMForumMapper tmForumMapper;

public BillingCycleSpecificationApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository productBillingCycleSpecificationRepository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
TmForumRepository productBillingCycleSpecificationRepository,
TMForumMapper tmForumMapper, TMForumEventHandler eventHandler) {
super(queryParser, validationService, productBillingCycleSpecificationRepository, eventHandler);
this.tmForumMapper = tmForumMapper;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package org.fiware.tmforum.account.rest;

import io.github.wistefan.mapping.EntityVOMapper;
import io.micronaut.core.annotation.NonNull;
import io.micronaut.http.HttpResponse;
import io.micronaut.http.annotation.Controller;
import lombok.extern.slf4j.Slf4j;
import org.fiware.account.api.EventsSubscriptionApi;
import org.fiware.account.model.EventSubscriptionInputVO;
import org.fiware.account.model.EventSubscriptionVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.common.domain.subscription.Subscription;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.*;
import org.fiware.tmforum.common.configuration.GeneralProperties;
import org.fiware.tmforum.common.domain.subscription.TMForumSubscription;
import org.fiware.tmforum.common.notification.NgsiLdEventHandler;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractSubscriptionApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.account.domain.BillFormat;
import org.fiware.tmforum.account.domain.BillingAccount;
import org.fiware.tmforum.account.domain.BillingCycleSpecification;
import org.fiware.tmforum.account.domain.BillPresentationMedia;
import org.fiware.tmforum.account.domain.FinancialAccount;
import org.fiware.tmforum.account.domain.PartyAccount;
import org.fiware.tmforum.account.domain.SettlementAccount;
import org.fiware.tmforum.account.TMForumMapper;
import reactor.core.publisher.Mono;

import java.util.List;
Expand All @@ -45,17 +42,30 @@ public class EventSubscriptionApiController extends AbstractSubscriptionApiContr
private static final List<String> EVENT_GROUPS = List.of(EVENT_GROUP_BILL_FORMAT, /*EVENT_GROUP_BILLING_ACCOUNT,*/
EVENT_GROUP_BILLING_CYCLE_SPECIFICATION, EVENT_GROUP_BILL_PRESENTATION_MEDIA, EVENT_GROUP_FINANCIAL_ACCOUNT,
EVENT_GROUP_PARTY_ACCOUNT, EVENT_GROUP_SETTLEMENT_ACCOUNT);
private static final Map<String, Class<?>> ENTITY_NAME_TO_ENTITY_CLASS_MAPPING = Map.ofEntries(
entry(BillFormat.TYPE_BILLF, BillFormat.class),
entry(BillingAccount.TYPE_BILLINGAC, BillingAccount.class),
entry(BillingCycleSpecification.TYPE_BILLCL, BillingCycleSpecification.class),
entry(BillPresentationMedia.TYPE_BILLPM, BillPresentationMedia.class),
entry(FinancialAccount.TYPE_FINANCIALAC, FinancialAccount.class),
entry(PartyAccount.TYPE_PARTYAC, PartyAccount.class),
entry(SettlementAccount.TYPE_SETTLEMENTAC, SettlementAccount.class)
);

public EventSubscriptionApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository repository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
super(queryParser, validationService, repository, EVENT_GROUP_TO_ENTITY_NAME_MAPPING, eventHandler);
TmForumRepository repository, TMForumMapper tmForumMapper,
TMForumEventHandler tmForumEventHandler, NgsiLdEventHandler ngsiLdEventHandler,
GeneralProperties generalProperties, EntityVOMapper entityVOMapper) {
super(queryParser, validationService, repository, EVENT_GROUP_TO_ENTITY_NAME_MAPPING,
ENTITY_NAME_TO_ENTITY_CLASS_MAPPING, tmForumEventHandler, ngsiLdEventHandler,
generalProperties, entityVOMapper);
this.tmForumMapper = tmForumMapper;
}

@Override
public Mono<HttpResponse<EventSubscriptionVO>> registerListener(
@NonNull EventSubscriptionInputVO eventSubscriptionInputVO) {
Subscription subscription = buildSubscription(eventSubscriptionInputVO.getCallback(),
TMForumSubscription subscription = buildSubscription(eventSubscriptionInputVO.getCallback(),
eventSubscriptionInputVO.getQuery(), EVENT_GROUPS);

return create(subscription)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,22 @@
import org.fiware.account.model.FinancialAccountCreateVO;
import org.fiware.account.model.FinancialAccountUpdateVO;
import org.fiware.account.model.FinancialAccountVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.FinancialAccount;
import org.fiware.tmforum.common.exception.TmForumException;
import org.fiware.tmforum.common.exception.TmForumExceptionReason;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.common.validation.ReferencedEntity;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.FinancialAccount;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;

@Slf4j
Expand All @@ -33,7 +32,8 @@ public class FinancialAccountApiController extends AbstractApiController<Financi
private final TMForumMapper tmForumMapper;

public FinancialAccountApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository productFinancialAccountRepository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
TmForumRepository productFinancialAccountRepository,
TMForumMapper tmForumMapper, TMForumEventHandler eventHandler) {
super(queryParser, validationService, productFinancialAccountRepository, eventHandler);
this.tmForumMapper = tmForumMapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import org.fiware.account.model.PartyAccountCreateVO;
import org.fiware.account.model.PartyAccountUpdateVO;
import org.fiware.account.model.PartyAccountVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.PartyAccount;
import org.fiware.tmforum.common.exception.TmForumException;
import org.fiware.tmforum.common.exception.TmForumExceptionReason;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.common.validation.ReferencedEntity;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.PartyAccount;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
Expand All @@ -34,7 +34,8 @@ public class PartyAccountApiController extends AbstractApiController<PartyAccoun


public PartyAccountApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository productPartyAccountRepository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
TmForumRepository productPartyAccountRepository, TMForumMapper tmForumMapper,
TMForumEventHandler eventHandler) {
super(queryParser, validationService, productPartyAccountRepository, eventHandler);
this.tmForumMapper = tmForumMapper;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import org.fiware.account.model.SettlementAccountCreateVO;
import org.fiware.account.model.SettlementAccountUpdateVO;
import org.fiware.account.model.SettlementAccountVO;
import org.fiware.tmforum.common.notification.EventHandler;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.SettlementAccount;
import org.fiware.tmforum.common.exception.TmForumException;
import org.fiware.tmforum.common.exception.TmForumExceptionReason;
import org.fiware.tmforum.common.mapping.IdHelper;
import org.fiware.tmforum.common.notification.TMForumEventHandler;
import org.fiware.tmforum.common.querying.QueryParser;
import org.fiware.tmforum.common.repository.TmForumRepository;
import org.fiware.tmforum.common.rest.AbstractApiController;
import org.fiware.tmforum.common.validation.ReferenceValidationService;
import org.fiware.tmforum.common.validation.ReferencedEntity;
import org.fiware.tmforum.account.TMForumMapper;
import org.fiware.tmforum.account.domain.SettlementAccount;
import reactor.core.publisher.Mono;

import javax.annotation.Nullable;
Expand All @@ -34,7 +34,8 @@ public class SettlementAccountApiController extends AbstractApiController<Settle


public SettlementAccountApiController(QueryParser queryParser, ReferenceValidationService validationService,
TmForumRepository productSettlementAccountRepository, TMForumMapper tmForumMapper, EventHandler eventHandler) {
TmForumRepository productSettlementAccountRepository,
TMForumMapper tmForumMapper, TMForumEventHandler eventHandler) {
super(queryParser, validationService, productSettlementAccountRepository, eventHandler);
this.tmForumMapper = tmForumMapper;
}
Expand Down
Loading

0 comments on commit 541a03c

Please sign in to comment.