Search in sources :

Example 1 with MessageInfoType

use of org.talend.esb.sam._2011._03.common.MessageInfoType in project tesb-rt-se by Talend.

the class EventTypeMapperTest method testEmpty.

/**
 * Test with empty eventType parts to check for Nullpointer exceptions
 */
@Test
public void testEmpty() {
    EventType eventType = new EventType();
    EventTypeMapper.map(eventType);
    eventType.setCustomInfo(new CustomInfoType());
    EventTypeMapper.map(eventType);
    eventType.setMessageInfo(new MessageInfoType());
    EventTypeMapper.map(eventType);
    eventType.setOriginator(new OriginatorType());
    EventTypeMapper.map(eventType);
}
Also used : CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType) Test(org.junit.Test)

Example 2 with MessageInfoType

use of org.talend.esb.sam._2011._03.common.MessageInfoType in project tesb-rt-se by Talend.

the class MonitoringServiceFullTest method testSendEvents.

// @Before
// public void setUp() throws Exception {
// executeSqlScript("create.sql", true);
// }
@Test
public void testSendEvents() throws PutEventsFault, MalformedURLException, URISyntaxException {
    Client client = ClientProxy.getClient(monitoringService);
    HTTPConduit conduit = (HTTPConduit) client.getConduit();
    HTTPClientPolicy clientConfig = new HTTPClientPolicy();
    clientConfig.setReceiveTimeout(100000);
    conduit.setClient(clientConfig);
    jdbcTemplate.update("delete from EVENTS");
    List<EventType> events = new ArrayList<EventType>();
    EventType eventType = new EventType();
    eventType.setEventType(EventEnumType.REQ_OUT);
    URL messageContentFile = this.getClass().getResource("/testmessage.xml").toURI().toURL();
    eventType.setContent(new DataHandler(messageContentFile));
    CustomInfoType ciType = new CustomInfoType();
    CustomInfoType.Item prop1 = new CustomInfoType.Item();
    prop1.setKey("mykey1");
    prop1.setValue("myValue1");
    ciType.getItem().add(prop1);
    CustomInfoType.Item prop2 = new CustomInfoType.Item();
    prop2.setKey("mykey2");
    prop2.setValue("myValue2");
    ciType.getItem().add(prop2);
    eventType.setCustomInfo(ciType);
    MessageInfoType mit = new MessageInfoType();
    mit.setFlowId("uuid");
    eventType.setMessageInfo(mit);
    events.add(eventType);
    String result = monitoringService.putEvents(events);
    Assert.assertEquals("success", result);
    long id = jdbcTemplate.queryForObject("select id from EVENTS", Long.class);
    Event readEvent = eventRepository.readEvent(id);
    Assert.assertEquals(EventTypeEnum.REQ_OUT, readEvent.getEventType());
    Map<String, String> customInfo = readEvent.getCustomInfo();
    Assert.assertEquals("myValue1", customInfo.get("mykey1"));
    Assert.assertEquals("myValue2", customInfo.get("mykey2"));
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType) ArrayList(java.util.ArrayList) DataHandler(javax.activation.DataHandler) URL(java.net.URL) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) CustomInfoType(org.talend.esb.sam._2011._03.common.CustomInfoType) HTTPClientPolicy(org.apache.cxf.transports.http.configuration.HTTPClientPolicy) Event(org.talend.esb.sam.common.event.Event) Client(org.apache.cxf.endpoint.Client) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType) Test(org.junit.Test)

Example 3 with MessageInfoType

use of org.talend.esb.sam._2011._03.common.MessageInfoType in project tesb-rt-se by Talend.

the class EventMapper method map.

/**
 * convert Event bean to EventType manually.
 *
 * @param event the event
 * @return the event type
 */
public static EventType map(Event event) {
    EventType eventType = new EventType();
    eventType.setTimestamp(Converter.convertDate(event.getTimestamp()));
    eventType.setEventType(convertEventType(event.getEventType()));
    OriginatorType origType = mapOriginator(event.getOriginator());
    eventType.setOriginator(origType);
    MessageInfoType miType = mapMessageInfo(event.getMessageInfo());
    eventType.setMessageInfo(miType);
    eventType.setCustomInfo(convertCustomInfo(event.getCustomInfo()));
    eventType.setContentCut(event.isContentCut());
    if (event.getContent() != null) {
        DataHandler datHandler = getDataHandlerForString(event);
        eventType.setContent(datHandler);
    }
    return eventType;
}
Also used : EventType(org.talend.esb.sam._2011._03.common.EventType) OriginatorType(org.talend.esb.sam._2011._03.common.OriginatorType) DataHandler(javax.activation.DataHandler) MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType)

Example 4 with MessageInfoType

use of org.talend.esb.sam._2011._03.common.MessageInfoType in project tesb-rt-se by Talend.

the class EventMapper method mapMessageInfo.

/**
 * Mapping message info.
 *
 * @param messageInfo the message info
 * @return the message info type
 */
private static MessageInfoType mapMessageInfo(MessageInfo messageInfo) {
    if (messageInfo == null) {
        return null;
    }
    MessageInfoType miType = new MessageInfoType();
    miType.setMessageId(messageInfo.getMessageId());
    miType.setFlowId(messageInfo.getFlowId());
    miType.setPorttype(convertString(messageInfo.getPortType()));
    miType.setOperationName(messageInfo.getOperationName());
    miType.setTransport(messageInfo.getTransportType());
    return miType;
}
Also used : MessageInfoType(org.talend.esb.sam._2011._03.common.MessageInfoType)

Aggregations

MessageInfoType (org.talend.esb.sam._2011._03.common.MessageInfoType)4 EventType (org.talend.esb.sam._2011._03.common.EventType)3 DataHandler (javax.activation.DataHandler)2 Test (org.junit.Test)2 CustomInfoType (org.talend.esb.sam._2011._03.common.CustomInfoType)2 OriginatorType (org.talend.esb.sam._2011._03.common.OriginatorType)2 URL (java.net.URL)1 ArrayList (java.util.ArrayList)1 Client (org.apache.cxf.endpoint.Client)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1 HTTPClientPolicy (org.apache.cxf.transports.http.configuration.HTTPClientPolicy)1 Event (org.talend.esb.sam.common.event.Event)1