use of org.candlepin.auth.PrincipalData in project candlepin by candlepin.
the class EventTranslator method populate.
/**
* {@inheritDoc}
*/
@Override
public EventDTO populate(ModelTranslator modelTranslator, Event source, EventDTO destination) {
if (source == null) {
throw new IllegalArgumentException("source is null");
}
if (destination == null) {
throw new IllegalArgumentException("destination is null");
}
destination.setId(source.getId());
destination.setTargetName(source.getTargetName());
destination.setConsumerUuid(source.getConsumerUuid());
destination.setEntityId(source.getEntityId());
destination.setMessageText(source.getMessageText());
destination.setOwnerId(source.getOwnerId());
destination.setPrincipalStore(source.getPrincipalStore());
destination.setReferenceId(source.getReferenceId());
destination.setTimestamp(source.getTimestamp());
destination.setType(source.getType() != null ? source.getType().toString() : null);
destination.setTarget(source.getTarget() != null ? source.getTarget().toString() : null);
destination.setReferenceType(source.getReferenceType() != null ? source.getReferenceType().toString() : null);
destination.setEventData(source.getEventData());
if (modelTranslator != null) {
PrincipalData principalData = source.getPrincipal();
EventDTO.PrincipalDataDTO principalDataDTO = new EventDTO.PrincipalDataDTO(principalData.getType(), principalData.getName());
destination.setPrincipal(principalDataDTO);
}
return destination;
}
use of org.candlepin.auth.PrincipalData in project candlepin by candlepin.
the class EventTranslatorTest method verifyOutput.
@Override
protected void verifyOutput(Event source, EventDTO dest, boolean childrenGenerated) {
if (source != null) {
assertEquals(source.getId(), dest.getId());
assertEquals(source.getTargetName(), dest.getTargetName());
assertEquals(source.getConsumerUuid(), dest.getConsumerUuid());
assertEquals(source.getEntityId(), dest.getEntityId());
assertEquals(source.getOwnerId(), dest.getOwnerId());
assertEquals(source.getPrincipalStore(), dest.getPrincipalStore());
assertEquals(source.getMessageText(), dest.getMessageText());
assertEquals(source.getReferenceId(), dest.getReferenceId());
assertEquals(source.getTimestamp(), dest.getTimestamp());
assertEquals(source.getType().toString(), dest.getType());
assertEquals(source.getTarget().toString(), dest.getTarget());
assertEquals(source.getReferenceType().toString(), dest.getReferenceType());
assertEquals(source.getEventData(), dest.getEventData());
if (childrenGenerated) {
PrincipalData principalDataSource = source.getPrincipal();
EventDTO.PrincipalDataDTO principalDataDTO = dest.getPrincipal();
if (principalDataSource != null) {
assertEquals(principalDataSource.getType(), principalDataDTO.getType());
assertEquals(principalDataSource.getName(), principalDataDTO.getName());
} else {
assertNull(principalDataDTO);
}
} else {
assertNull(dest.getPrincipal());
}
} else {
assertNull(dest);
}
}
use of org.candlepin.auth.PrincipalData in project candlepin by candlepin.
the class ListenerWrapperTest method eventJson.
private String eventJson() throws Exception {
StringWriter sw = new StringWriter();
Event e = new Event();
e.setId("10");
e.setConsumerUuid("20");
e.setPrincipal(new PrincipalData("5678", "910112"));
mapper.writeValue(sw, e);
return sw.toString();
}
use of org.candlepin.auth.PrincipalData in project candlepin by candlepin.
the class AtomFeedResourceTest method getEvents.
private List<Event> getEvents(int count) {
List<Event> list = new ArrayList<>(count);
Target[] targets = Target.values();
Type[] types = Type.values();
for (int i = 0; i < count; i++) {
Event e = new Event();
e.setTarget(targets[i % targets.length]);
e.setType(types[i % types.length]);
e.setTimestamp(new Date());
e.setPrincipal(new PrincipalData());
list.add(e);
}
return list;
}
use of org.candlepin.auth.PrincipalData in project candlepin by candlepin.
the class EventAdapterImpl method addMessageText.
public void addMessageText(List<Event> events) {
for (Event event : events) {
String eventType = (event.getTarget().name() + event.getType().name());
String message = MESSAGES.get(eventType);
if (message == null) {
message = i18n.marktr("Unknown event for user {0} and target {1}");
}
PrincipalData pd = event.getPrincipal();
event.setMessageText(i18n.tr(message, pd.getName(), event.getTargetName()));
}
}
Aggregations