Search in sources :

Example 31 with ExchangeLog

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

the class LogMapperTest method toNewEntityWhenLogTypeIsReceiveMovement.

@Test
public void toNewEntityWhenLogTypeIsReceiveMovement() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.MOVEMENT;
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.SUCCESSFUL;
    String source = "FLUX";
    String message = "<xml></xml>";
    LogRefType logRefType = new LogRefType();
    logRefType.setRefGuid(typeRefGuid);
    logRefType.setType(typeRefType);
    logRefType.setMessage(message);
    ReceiveMovementType input = new ReceiveMovementType();
    input.setType(LogType.RECEIVE_MOVEMENT);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    input.setStatus(status);
    input.setSource(source);
    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(source, result.getSource());
    assertTrue(result.getTransferIncoming());
    assertEquals(LogType.RECEIVE_MOVEMENT, result.getType());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) ExchangeLogStatusTypeType(eu.europa.ec.fisheries.schema.exchange.v1.ExchangeLogStatusTypeType) LogRefType(eu.europa.ec.fisheries.schema.exchange.v1.LogRefType) ReceiveMovementType(eu.europa.ec.fisheries.schema.exchange.v1.ReceiveMovementType) Date(java.util.Date) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog) Test(org.junit.Test)

Example 32 with ExchangeLog

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

the class LogMapperTest method toNewEntityWhenLogTypeIsReceiveSalesReportAndStatusIsNotFilledIn.

@Test
public void toNewEntityWhenLogTypeIsReceiveSalesReportAndStatusIsNotFilledIn() throws Exception {
    // data set
    String typeRefGuid = "trg";
    TypeRefType typeRefType = TypeRefType.SALES_REPORT;
    Date dateReceived = new Date();
    String senderOrReceiver = "BEL";
    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_REPORT);
    input.setTypeRef(logRefType);
    input.setDateRecieved(dateReceived);
    input.setSenderReceiver(senderOrReceiver);
    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(ExchangeLogStatusTypeType.ISSUED, result.getStatus());
    assertEquals(1, result.getStatusHistory().size());
    assertEquals(result, result.getStatusHistory().get(0).getLog());
    assertEquals(ExchangeLogStatusTypeType.ISSUED, 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_REPORT, result.getType());
    assertEquals(destination, result.getDestination());
}
Also used : TypeRefType(eu.europa.ec.fisheries.schema.exchange.v1.TypeRefType) 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 33 with ExchangeLog

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

the class LogMapper method toSendMovementEntity.

private static ExchangeLog toSendMovementEntity(ExchangeLogType log) {
    SendMovementType type = (SendMovementType) log;
    ExchangeLog entity = new ExchangeLog();
    entity.setFwdDate(type.getFwdDate());
    entity.setFwdRule(type.getFwdRule());
    entity.setRecipient(type.getRecipient());
    entity.setTransferIncoming(false);
    return entity;
}
Also used : SendMovementType(eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Example 34 with ExchangeLog

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

the class LogMapper method toSendEmailEntity.

private static ExchangeLog toSendEmailEntity(ExchangeLogType log) {
    SendEmailType type = (SendEmailType) log;
    ExchangeLog entity = new ExchangeLog();
    entity.setTransferIncoming(false);
    entity.setFwdRule(type.getFwdRule());
    entity.setRecipient(type.getRecipient());
    entity.setFwdDate(type.getFwdDate());
    return entity;
}
Also used : SendEmailType(eu.europa.ec.fisheries.schema.exchange.v1.SendEmailType) ExchangeLog(eu.europa.ec.fisheries.uvms.exchange.entity.exchangelog.ExchangeLog)

Example 35 with ExchangeLog

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

the class LogMapper method toSendPollEntity.

private static ExchangeLog toSendPollEntity(ExchangeLogType log) {
    SendPollType type = (SendPollType) log;
    ExchangeLog entity = new ExchangeLog();
    entity.setTransferIncoming(false);
    entity.setRecipient(type.getRecipient());
    entity.setFwdDate(type.getFwdDate());
    return entity;
}
Also used : SendPollType(eu.europa.ec.fisheries.schema.exchange.v1.SendPollType) 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