Search in sources :

Example 6 with LogRefType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsReceiveSalesResponse.

@Test
public void toNewEntityWhenLogTypeIsReceiveSalesResponse() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.SALES_RESPONSE;
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String message = "<xml></xml>";
    String destination = "destination";
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    logRefType.setType(typeRefType);
    logRefType.setMessage(message);
    ExchangeLogType input = new ExchangeLogType();
    input.setType(LogType.RECEIVE_SALES_RESPONSE);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setIncoming(true);
    input.setDestination(destination);
    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());
    assertTrue(result.getTransferIncoming());
    assertEquals(LogType.RECEIVE_SALES_RESPONSE, result.getType());
    assertEquals(destination, result.getDestination());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) 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 7 with LogRefType

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

the class LogMapperTest method toNewEntityWhenLogTypeIsSendSalesReport.

@Test
public void toNewEntityWhenLogTypeIsSendSalesReport() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.SALES_REPORT;
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String message = "<xml></xml>";
    String destination = "destination";
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    logRefType.setType(typeRefType);
    logRefType.setMessage(message);
    ExchangeLogType input = new ExchangeLogType();
    input.setType(LogType.SEND_SALES_REPORT);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setIncoming(false);
    input.setDestination(destination);
    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());
    assertFalse(result.getTransferIncoming());
    assertEquals(LogType.SEND_SALES_REPORT, result.getType());
    assertEquals(destination, result.getDestination());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) 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 8 with LogRefType

use of eu.europa.ec.fisheries.schema.exchange.v1.LogRefType 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 9 with LogRefType

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

the class LogMapper method toModel.

public static ExchangeLogType toModel(ExchangeLog entity) {
    ExchangeLogType model = new ExchangeLogType();
    LogType logType = entity.getType();
    if (logType.equals(LogType.RECEIVE_MOVEMENT)) {
        ReceiveMovementType type = new ReceiveMovementType();
        type.setSource(entity.getSource());
        type.setRecipient(entity.getRecipient());
        logType = LogType.RECEIVE_MOVEMENT;
        model = type;
    } else if (logType.equals(LogType.SEND_MOVEMENT)) {
        SendMovementType type = new SendMovementType();
        type.setFwdDate(entity.getFwdDate());
        type.setFwdRule(entity.getFwdRule());
        type.setRecipient(entity.getRecipient());
        logType = LogType.SEND_MOVEMENT;
        model = type;
    } else if (logType.equals(LogType.SEND_POLL)) {
        SendPollType type = new SendPollType();
        type.setFwdDate(entity.getFwdDate());
        type.setRecipient(entity.getRecipient());
        logType = LogType.SEND_POLL;
        model = type;
    } else if (logType.equals(LogType.SEND_EMAIL)) {
        SendEmailType type = new SendEmailType();
        type.setFwdRule(entity.getFwdRule());
        type.setFwdDate(entity.getFwdDate());
        type.setRecipient(entity.getRecipient());
        logType = LogType.SEND_EMAIL;
        model = type;
    }
    model.setDateRecieved(entity.getDateReceived());
    model.setGuid(entity.getGuid());
    model.setSenderReceiver(entity.getSenderReceiver());
    model.setIncoming(entity.getTransferIncoming());
    model.setStatus(entity.getStatus());
    model.setDestination(entity.getDestination());
    model.setType(logType);
    model.setSource(entity.getSource());
    model.setTypeRefType(entity.getTypeRefType());
    if (entity.getTypeRefType() != null) {
        LogRefType logRefType = new LogRefType();
        logRefType.setRefGuid(entity.getTypeRefGuid());
        logRefType.setType(entity.getTypeRefType());
        logRefType.setMessage(entity.getTypeRefMessage());
        model.setTypeRef(logRefType);
    }
    return model;
}
Also used : SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) SendEmailType(eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) LogType(eu.europa.ec.fisheries.schema.exchange.v1.LogType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) ReceiveMovementType(eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType) SendMovementType(eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)

Example 10 with LogRefType

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

the class LogMapper method toStatusModel.

public static ExchangeLogStatusType toStatusModel(ExchangeLog exchangeLog) {
    ExchangeLogStatusType model = new ExchangeLogStatusType();
    if (exchangeLog.getType().equals(LogType.SEND_POLL)) {
        model.setIdentifier(exchangeLog.getRecipient());
    }
    model.setGuid(exchangeLog.getGuid());
    if (exchangeLog.getTypeRefType() != null) {
        LogRefType logRefType = new LogRefType();
        logRefType.setRefGuid(exchangeLog.getTypeRefGuid());
        logRefType.setType(exchangeLog.getTypeRefType());
        logRefType.setMessage(exchangeLog.getTypeRefMessage());
        model.setTypeRef(logRefType);
    }
    if (exchangeLog.getStatusHistory() != null) {
        List<ExchangeLogStatusHistoryType> historyModelList = new ArrayList<>();
        for (ExchangeLogStatus history : exchangeLog.getStatusHistory()) {
            ExchangeLogStatusHistoryType historyModel = new ExchangeLogStatusHistoryType();
            historyModel.setStatus(history.getStatus());
            historyModel.setTimestamp(history.getStatusTimestamp());
            historyModelList.add(historyModel);
        }
        model.getHistory().addAll(historyModelList);
    }
    return model;
}
Also used : ExchangeLogStatusType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType) ExchangeLogStatusHistoryType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType) ArrayList(java.util.ArrayList) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) ExchangeLogStatus(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)

Aggregations

LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)18 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)11 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)10 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)10 ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)10 Date (java.util.Date)10 Test (org.junit.Test)10 ExchangeLogException (eu.europa.ec.fisheries.uvms.exchange.service.exception.ExchangeLogException)5 ReceiveMovementType (eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType)3 SendMovementType (eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)3 SendPollType (eu.europa.ec.fisheries.schema.exchange.v1.SendPollType)3 SendEmailType (eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType)2 NotificationMessage (eu.europa.ec.fisheries.uvms.longpolling.notifications.NotificationMessage)2 ProcessedMovementResponse (eu.europa.ec.fisheries.schema.exchange.module.v1.ProcessedMovementResponse)1 MovementRefType (eu.europa.ec.fisheries.schema.exchange.movement.v1.MovementRefType)1 SetReportMovementType (eu.europa.ec.fisheries.schema.exchange.movement.v1.SetReportMovementType)1 ExchangeLogStatusHistoryType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusHistoryType)1 ExchangeLogStatusType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusType)1 LogType (eu.europa.ec.fisheries.schema.exchange.v1.LogType)1 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)1