use of eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType in project UVMS-ExchangeModule-APP by UnionVMS.
the class LogMapperTest method toNewEntityWhenLogTypeIsSendMovement.
@Test
public void toNewEntityWhenLogTypeIsSendMovement() throws Exception {
// data set
String typeRefGuid = "trg";
TypeRefType typeRefType = TypeRefType.MOVEMENT;
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 fwdRule = "fantastic rules and where to find them";
String recipient = "potter@wb.com";
SendMovementType input = new SendMovementType();
input.setType(LogType.SEND_MOVEMENT);
input.setTypeRef(logRefType);
input.setDateRecieved(dateReceived);
input.setSenderReceiver(senderOrReceiver);
input.setStatus(status);
input.setFwdDate(fwdDate);
input.setFwdRule(fwdRule);
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(fwdRule, result.getFwdRule());
assertEquals(recipient, result.getRecipient());
assertFalse(result.getTransferIncoming());
assertEquals(LogType.SEND_MOVEMENT, result.getType());
}
use of eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType in project UVMS-ExchangeModule-APP by UnionVMS.
the class LogMapperTest method toModelWhenEntityIsSendMovementLog.
@Test
public void toModelWhenEntityIsSendMovementLog() {
Date dateReceived = new Date();
String guid = "Paradise";
String senderReceiver = "Chris Martin";
boolean incoming = true;
ExchangeLogStatusTypeType status = ExchangeLogStatusTypeType.PROBABLY_TRANSMITTED;
String fwdRule = "Coldplay";
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.setFwdRule(fwdRule);
entity.setFwdDate(fwdDate);
entity.setRecipient(recipient);
entity.setType(LogType.SEND_MOVEMENT);
ExchangeLogType model = LogMapper.toModel(entity);
assertEquals(LogType.SEND_MOVEMENT, model.getType());
assertEquals(dateReceived, model.getDateRecieved());
assertEquals(guid, model.getGuid());
assertEquals(senderReceiver, model.getSenderReceiver());
assertEquals(incoming, model.isIncoming());
assertEquals(status, model.getStatus());
assertEquals(fwdRule, ((SendMovementType) model).getFwdRule());
assertEquals(fwdDate, ((SendMovementType) model).getFwdDate());
assertEquals(recipient, ((SendMovementType) model).getRecipient());
}
use of eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType 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;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType in project UVMS-ExchangeModule-APP by UnionVMS.
the class ExchangeLogMapper method getSendMovementExchangeLog.
public static ExchangeLogType getSendMovementExchangeLog(SendMovementToPluginType sendReport) throws ExchangeLogException {
if (sendReport == null) {
throw new ExchangeLogException("No request");
}
SendMovementType log = new SendMovementType();
log.setDateRecieved(sendReport.getTimestamp());
log.setType(LogType.SEND_MOVEMENT);
LogRefType logRefType = new LogRefType();
logRefType.setRefGuid(sendReport.getMovement().getGuid());
logRefType.setType(TypeRefType.MOVEMENT);
log.setTypeRef(logRefType);
String senderReceiver = getSendMovementSenderReceiver(sendReport);
log.setSenderReceiver(senderReceiver);
// TODO send fwdDate, fwdRule and recipient from Rules
log.setFwdDate(sendReport.getFwdDate());
log.setFwdRule(sendReport.getFwdRule());
log.setRecipient(sendReport.getRecipient());
return log;
}
use of eu.europa.ec.fisheries.schema.exchange.v1.SendMovementType 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;
}
Aggregations