Search in sources :

Example 1 with ReceiveSalesReportRequest

use of eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeEventIncomingServiceBean method receiveSalesReport.

@Override
public void receiveSalesReport(@Observes @ReceiveSalesReportEvent ExchangeMessageEvent event) {
    try {
        ReceiveSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(event.getJmsMessage(), ReceiveSalesReportRequest.class);
        log.info("Receive sales report in Exchange module:{}", request);
        String report = request.getReport();
        PluginType plugin = request.getPluginType();
        String sender = request.getSenderOrReceiver();
        String messageGuid = request.getMessageGuid();
        ExchangeLogType log = exchangeLog.log(request, LogType.RECEIVE_SALES_REPORT, ExchangeLogStatusTypeType.ISSUED, TypeRefType.SALES_REPORT, report, true);
        forwardToRules(RulesModuleRequestMapper.createReceiveSalesReportRequest(report, messageGuid, plugin.name(), log.getGuid(), sender, request.getOnValue()));
    } catch (ExchangeModelMarshallException e) {
        try {
            String errorMessage = "Couldn't map to SetSalesReportRequest when processing sales report from plugin. The event was " + event.getJmsMessage().getText();
            firePluginFault(event, errorMessage, e);
        } catch (JMSException e1) {
            firePluginFault(event, "Couldn't map to SetSalesReportRequest when processing sales report from plugin.", e);
        }
    } catch (ExchangeLogException e) {
        firePluginFault(event, "Could not log the incoming sales report.", e);
    } catch (RulesModelMarshallException e) {
        firePluginFault(event, "Could not create a request for the Rules module for an incoming sales report.", e);
    }
}
Also used : ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) RulesModelMarshallException(eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException) ReceiveSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest) JMSException(javax.jms.JMSException) PluginType(eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)

Example 2 with ReceiveSalesReportRequest

use of eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest in project UVMS-ActivityModule-APP by UnionVMS.

the class ActivityMessageConsumerBeanTest method testThrowing.

@Test
@SneakyThrows
public void testThrowing() {
    mockStatic(MappedDiagnosticContext.class);
    PowerMockito.doNothing().when(MappedDiagnosticContext.class, "addMessagePropertiesToThreadMappedDiagnosticContext", Mockito.any(TextMessage.class));
    ReceiveSalesReportRequest request = new ReceiveSalesReportRequest();
    request.setMethod(ExchangeModuleMethod.RECEIVE_SALES_REPORT);
    ActiveMQTextMessage textMessage = new ActiveMQTextMessage(session);
    final String strReq = JAXBMarshaller.marshallJaxBObjectToString(request);
    Whitebox.setInternalState(textMessage, "text", new SimpleString(strReq));
    consumer.onMessage(textMessage);
    PowerMockito.verifyStatic();
    MappedDiagnosticContext.addMessagePropertiesToThreadMappedDiagnosticContext(textMessage);
    verify(errorEvent, times(1)).fire(any(EventMessage.class));
}
Also used : EventMessage(eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ReceiveSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) TextMessage(javax.jms.TextMessage) ActiveMQTextMessage(org.apache.activemq.artemis.jms.client.ActiveMQTextMessage) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test) SneakyThrows(lombok.SneakyThrows)

Aggregations

ReceiveSalesReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.ReceiveSalesReportRequest)2 PluginType (eu.europa.ec.fisheries.schema.exchange.plugin.types.v1.PluginType)1 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)1 EventMessage (eu.europa.ec.fisheries.uvms.activity.message.event.carrier.EventMessage)1 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)1 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)1 RulesModelMarshallException (eu.europa.ec.fisheries.uvms.rules.model.exception.RulesModelMarshallException)1 JMSException (javax.jms.JMSException)1 TextMessage (javax.jms.TextMessage)1 SneakyThrows (lombok.SneakyThrows)1 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)1 ActiveMQTextMessage (org.apache.activemq.artemis.jms.client.ActiveMQTextMessage)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1