Search in sources :

Example 11 with ExchangeLog

use of eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog 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 12 with ExchangeLog

use of eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog 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 13 with ExchangeLog

use of eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog 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 14 with ExchangeLog

use of eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog in project UVMS-ExchangeModule-APP by UnionVMS.

the class MockData method getLogEntities.

public static List<ExchangeLog> getLogEntities() {
    ExchangeLog log1 = new ExchangeLog();
    log1.setType(LogType.RECEIVE_FA_QUERY_MSG);
    log1.setTypeRefGuid("SomeRefGuid_1AAA");
    log1.setTransferIncoming(false);
    log1.setGuid("AAA-BBB-CCC");
    log1.setTypeRefType(TypeRefType.FA_QUERY);
    ExchangeLog log2 = new ExchangeLog();
    log2.setType(LogType.RECEIVE_FA_QUERY_MSG);
    log2.setTypeRefGuid("SomeRefGuid_2BBB");
    log2.setTransferIncoming(true);
    log2.setGuid("CCC-DDD-EEE");
    log2.setTypeRefType(TypeRefType.FA_RESPONSE);
    return Arrays.asList(log1, log2);
}
Also used : ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Example 15 with ExchangeLog

use of eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog in project UVMS-ExchangeModule-APP by UnionVMS.

the class ExchangeLogModelBean method enrichDtosWithRelatedLogsInfo.

private void enrichDtosWithRelatedLogsInfo(List<ExchangeLogType> exchangeLogList) {
    List<String> guids = new ArrayList<>();
    for (ExchangeLogType log : exchangeLogList) {
        guids.add(log.getGuid());
    }
    List<ExchangeLog> relatedLogs = logDao.getExchangeLogByRangeOfRefGuids(guids);
    if (CollectionUtils.isNotEmpty(relatedLogs)) {
        for (ExchangeLog logEntity : relatedLogs) {
            RelatedLogInfo refLogInfo = new RelatedLogInfo();
            refLogInfo.setGuid(logEntity.getGuid());
            refLogInfo.setType(logEntity.getTypeRefType().toString());
            for (ExchangeLogType logType : exchangeLogList) {
                if (StringUtils.equals(logEntity.getTypeRefGuid(), logType.getGuid())) {
                    logType.getRelatedLogData().add(refLogInfo);
                }
            }
        }
    }
}
Also used : RelatedLogInfo(eu.europa.ec.fisheries.schema.exchange.v1.RelatedLogInfo) ExchangeLogType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType) ArrayList(java.util.ArrayList) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Aggregations

ExchangeLog (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)39 ExchangeLogType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogType)23 ExchangeLogStatusTypeType (eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType)21 Date (java.util.Date)21 Test (org.junit.Test)21 TypeRefType (eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType)12 ExchangeDaoException (eu.europa.ec.fisheries.uvms.exchange.exception.ExchangeDaoException)11 LogRefType (eu.europa.ec.fisheries.schema.exchange.v1.LogRefType)10 ExchangeModelException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeModelException)7 InputArgumentException (eu.europa.ec.fisheries.uvms.exchange.model.exception.InputArgumentException)7 ArrayList (java.util.ArrayList)5 ExchangeLogStatus (eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLogStatus)4 NoEntityFoundException (eu.europa.ec.fisheries.uvms.exchange.exception.NoEntityFoundException)3 ExchangeSearchMapperException (eu.europa.ec.fisheries.uvms.exchange.model.exception.ExchangeSearchMapperException)3 ParseException (java.text.ParseException)3 NoResultException (javax.persistence.NoResultException)3 PersistenceException (javax.persistence.PersistenceException)3 SendEmailType (eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType)2 SendMovementType (eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType)2 SendPollType (eu.europa.ec.fisheries.schema.exchange.v1.SendPollType)2