Search in sources :

Example 16 with ExchangeLogStatusTypeType

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

the class LogMapperTest method toModelWhenEntityIsReceiveSalesReport.

@Test
public void toModelWhenEntityIsReceiveSalesReport() {
    Date dateReceived = new Date();
    String guid = "Paradise";
    String senderReceiver = "Chris Martin";
    boolean incoming = true;
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.PROBABLY_TRANSMITTED;
    String destination = "destination";
    ExchangeLog entity = new ExchangeLog();
    entity.setDateReceived(dateReceived);
    entity.setGuid(guid);
    entity.setSenderReceiver(senderReceiver);
    entity.setTransferIncoming(incoming);
    entity.setStatus(status);
    entity.setType(LogType.RECEIVE_SALES_REPORT);
    entity.setDestination(destination);
    ExchangeLogType model = LogMapper.toModel(entity);
    assertEquals(LogType.RECEIVE_SALES_REPORT, model.getType());
    assertEquals(dateReceived, model.getDateRecieved());
    assertEquals(guid, model.getGuid());
    assertEquals(senderReceiver, model.getSenderReceiver());
    assertEquals(incoming, model.isIncoming());
    assertEquals(status, model.getStatus());
    assertEquals(destination, model.getDestination());
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) Date(java.util.Date) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) Test(org.junit.Test)

Example 17 with ExchangeLogStatusTypeType

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

the class LogMapperTest method toModelWhenEntityIsPollLog.

@Test
public void toModelWhenEntityIsPollLog() {
    Date dateReceived = new Date();
    String guid = "Paradise";
    String senderReceiver = "Chris Martin";
    boolean incoming = true;
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.PROBABLY_TRANSMITTED;
    Date fwdDate = new Date();
    String recipient = "Viva la vida";
    ExchangeLog entity = new ExchangeLog();
    entity.setDateReceived(dateReceived);
    entity.setGuid(guid);
    entity.setSenderReceiver(senderReceiver);
    entity.setTransferIncoming(incoming);
    entity.setStatus(status);
    entity.setFwdDate(fwdDate);
    entity.setRecipient(recipient);
    entity.setType(LogType.SEND_POLL);
    ExchangeLogType model = LogMapper.toModel(entity);
    assertEquals(LogType.SEND_POLL, model.getType());
    assertEquals(dateReceived, model.getDateRecieved());
    assertEquals(guid, model.getGuid());
    assertEquals(senderReceiver, model.getSenderReceiver());
    assertEquals(incoming, model.isIncoming());
    assertEquals(status, model.getStatus());
    assertEquals(fwdDate, ((SendPollType) model).getFwdDate());
    assertEquals(recipient, ((SendPollType) model).getRecipient());
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) Date(java.util.Date) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) Test(org.junit.Test)

Example 18 with ExchangeLogStatusTypeType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsSendPoll.

@Test
public void toNewEntityWhenLogTypeIsSendPoll() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.POLL;
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String message = "<xml></xml>";
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    logRefType.setType(typeRefType);
    logRefType.setMessage(message);
    Date fwdDate = new Date();
    String recipient = "potter@wb.com";
    SendPollType input = new SendPollType();
    input.setType(LogType.SEND_POLL);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setFwdDate(fwdDate);
    input.setRecipient(recipient);
    String username = "stainii";
    // execute
    ExchangeLog result = LogMapper.toNewEntity(input, username);
    // assert
    assertEquals(typeRefGuid, result.getTypeRefGuid());
    assertEquals(typeRefType, result.getTypeRefType());
    assertEquals(dateReceived, result.getDateReceived());
    assertEquals(senderOrReceiver, result.getSenderReceiver());
    assertEquals(status, result.getStatus());
    assertEquals(1, result.getStatusHistory().size());
    assertEquals(result, result.getStatusHistory().get(0).getLog());
    assertEquals(status, result.getStatusHistory().get(0).getStatus());
    assertNotNull(result.getStatusHistory().get(0).getStatusTimestamp());
    assertEquals(username, result.getStatusHistory().get(0).getUpdatedBy());
    assertNotNull(result.getStatusHistory().get(0).getUpdateTime());
    assertEquals(username, result.getUpdatedBy());
    assertNotNull(result.getUpdateTime());
    assertEquals(fwdDate, result.getFwdDate());
    assertEquals(recipient, result.getRecipient());
    assertFalse(result.getTransferIncoming());
    assertEquals(LogType.SEND_POLL, result.getType());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) Date(java.util.Date) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) Test(org.junit.Test)

Example 19 with ExchangeLogStatusTypeType

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

the class ExchangeLogServiceBeanTest method updateStatusByLogGuidWhenSuccess.

@Test
public void updateStatusByLogGuidWhenSuccess() throws Exception {
    // data set
    ArgumentCaptor<ExchangeLogStatusType> captorForExchangeLogStatusType = ArgumentCaptor.forClass(ExchangeLogStatusType.class);
    ExchangeLogType expectedUpdatedLog = new ExchangeLogType();
    String logGuid = "123456";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    // mock
    doReturn(expectedUpdatedLog).when(exchangeLogModel).updateExchangeLogStatus(isA(ExchangeLogStatusType.class), eq("SYSTEM"));
    // execute
    ExchangeLogType actualUpdatedLog = exchangeLogService.updateStatus(logGuid, status);
    // verify and assert
    verify(exchangeLogModel).updateExchangeLogStatus(captorForExchangeLogStatusType.capture(), eq("SYSTEM"));
    assertSame(expectedUpdatedLog, actualUpdatedLog);
    ExchangeLogStatusType capturedExchangeLogStatusType = captorForExchangeLogStatusType.getValue();
    assertEquals(logGuid, capturedExchangeLogStatusType.getGuid());
    assertEquals(1, capturedExchangeLogStatusType.getHistory().size());
    assertEquals(status, capturedExchangeLogStatusType.getHistory().get(0).getStatus());
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) Test(org.junit.Test)

Example 20 with ExchangeLogStatusTypeType

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

the class ExchangeEventIncomingServiceBean method sendSalesReport.

@Override
public void sendSalesReport(@Observes @SendSalesReportEvent ExchangeMessageEvent message) {
    try {
        SendSalesReportRequest request = JAXBMarshaller.unmarshallTextMessage(message.getJmsMessage(), SendSalesReportRequest.class);
        ExchangeLogStatusTypeType validationStatus = request.getValidationStatus();
        exchangeLog.log(request, LogType.SEND_SALES_REPORT, validationStatus, TypeRefType.SALES_REPORT, request.getReport(), false);
        if (validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL || validationStatus == ExchangeLogStatusTypeType.SUCCESSFUL_WITH_WARNINGS) {
            eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest pluginRequest = new eu.europa.ec.fisheries.schema.exchange.plugin.v1.SendSalesReportRequest();
            pluginRequest.setRecipient(request.getSenderOrReceiver());
            pluginRequest.setReport(request.getReport());
            if (request.getSenderOrReceiver() != null) {
                pluginRequest.setSenderOrReceiver(request.getSenderOrReceiver());
            }
            pluginRequest.setMethod(ExchangePluginMethod.SEND_SALES_RESPONSE);
            exchangeEventOutgoingService.sendSalesReportToFLUX(pluginRequest);
        } else {
            log.error("Received invalid report from the Sales module: " + request.getReport());
        }
    } catch (ExchangeModelMarshallException | ExchangeMessageException e) {
        fireExchangeFault(message, "Error when sending a Sales response to FLUX", e);
    } catch (ExchangeLogException e) {
        fireExchangeFault(message, "Could not log the outgoing sales report.", e);
    }
}
Also used : ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) SendSalesReportRequest(eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesReportRequest) ExchangeMessageException(eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException) ExchangeModelMarshallException(eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException) ExchangeLogException(eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)

Aggregations

ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)27 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)21 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)21 Test (org.junit.Test)21 Date (java.util.Date)20 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)11 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)10 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)7 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)4 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)3 ExchangeModelMarshallException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelMarshallException)3 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)3 ArrayList (java.util.ArrayList)3 ExchangeMessageException (eu.europa.ec.fisheries.uvms.exchange.message.exception.ExchangeMessageException)2 SendSalesReportRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesReportRequest)1 SendSalesResponseRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.SendSalesResponseRequest)1 UpdateLogStatusRequest (eu.europa.ec.fisheries.schema.exchange.module.v1.UpdateLogStatusRequest)1 ExchangeHistoryListQuery (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeHistoryListQuery)1 ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)1 PollStatus (eu.europa.ec.fisheries.schema.exchange.v1.PollStatus)1