当前位置: 首页>>代码示例>>Java>>正文


Java RecordedEvent类代码示例

本文整理汇总了Java中com.github.msemys.esjc.RecordedEvent的典型用法代码示例。如果您正苦于以下问题:Java RecordedEvent类的具体用法?Java RecordedEvent怎么用?Java RecordedEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RecordedEvent类属于com.github.msemys.esjc包,在下文中一共展示了RecordedEvent类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: domainEventMessageOf

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
@SuppressWarnings({ "rawtypes", "unchecked" })
public static DomainEventMessage domainEventMessageOf(final ResolvedEvent event) {
   try {
      final RecordedEvent originalEvent = event.originalEvent();
      final Class<?> payloadType = Class.forName(originalEvent.eventType);
      final Object payload = gson.fromJson(new String(originalEvent.data, UTF_8), payloadType);
      final Map<String, ?> metaData = gson.fromJson(new String(originalEvent.metadata, UTF_8), METADATA_TYPE);

      final Map<String, ?> eventMetadata = (Map<String, ?>) metaData.get(Constants.EVENT_METADATA_KEY);
      final long sequenceNumber = originalEvent.eventNumber;
      final DateTime dateTime = new DateTime(originalEvent.created.toEpochMilli(), DateTimeZone.UTC);
      final String identifier = String.valueOf(originalEvent.eventId);
      final Object aggregateIdentifier = metaData.get(Constants.AGGREGATE_ID_KEY);
      return new GenericDomainEventMessage(identifier, dateTime, aggregateIdentifier, sequenceNumber, payload, new MetaData(eventMetadata));
   } catch (final ClassNotFoundException e) {
      throw new RuntimeException(e);
   }

}
 
开发者ID:Qyotta,项目名称:axon-eventstore,代码行数:20,代码来源:EsjcEventstoreUtil.java

示例2: matchesSafely

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
@Override
protected boolean matchesSafely(RecordedEvent actual) {
    if (!expected.eventId.equals(actual.eventId)) {
        return false;
    }

    if (!expected.type.equals(actual.eventType)) {
        return false;
    }

    String expectedDataString = newString(expected.data);
    String expectedMetadataString = newString(expected.metadata);

    String actualDataString = newString(actual.data);
    String actualMetadataDataString = newString(actual.metadata);

    return expectedDataString.equals(actualDataString) && expectedMetadataString.equals(actualMetadataDataString);
}
 
开发者ID:msemys,项目名称:esjc,代码行数:19,代码来源:RecordedEventMatcher.java

示例3: matchesSafely

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
@Override
protected boolean matchesSafely(List<RecordedEvent> actual) {
    if (expected.size() == actual.size()) {
        for (int i = 0; i < expected.size(); i++) {
            EventData expectedItem = expected.get(i);
            RecordedEvent actualItem = actual.get(i);

            elementMatcher = RecordedEventMatcher.equalTo(expectedItem);
            elementIndex = i;

            if (!elementMatcher.matches(actualItem)) {
                return false;
            }
        }

        return true;
    } else {
        return false;
    }
}
 
开发者ID:msemys,项目名称:esjc,代码行数:21,代码来源:RecordedEventListMatcher.java

示例4: describeMismatchSafely

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
@Override
protected void describeMismatchSafely(List<RecordedEvent> actual, Description mismatchDescription) {
    mismatchDescription.appendText("collection with size ").appendValue(actual.size());

    if (elementMatcher != null && elementIndex < actual.size()) {
        RecordedEvent actualItem = actual.get(elementIndex);

        mismatchDescription
            .appendText(" has event ")
            .appendValue(actualItem.eventType)
            .appendText(" ")
            .appendValue(actualItem.eventId)
            .appendText(" at index ")
            .appendValue(elementIndex);
    }
}
 
开发者ID:msemys,项目名称:esjc,代码行数:17,代码来源:RecordedEventListMatcher.java

示例5: equalTo

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
@Factory
public static Matcher<RecordedEvent> equalTo(EventData item) {
    return new RecordedEventMatcher(item);
}
 
开发者ID:msemys,项目名称:esjc,代码行数:5,代码来源:RecordedEventMatcher.java

示例6: containsInOrder

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
@Factory
public static Matcher<List<RecordedEvent>> containsInOrder(List<EventData> items) {
    return new RecordedEventListMatcher(items);
}
 
开发者ID:msemys,项目名称:esjc,代码行数:5,代码来源:RecordedEventListMatcher.java

示例7: getSourceType

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
@Override
public final Class<RecordedEvent> getSourceType() {
    return RecordedEvent.class;
}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:5,代码来源:RecordedEvent2CommonEventConverter.java

示例8: testConvertJsonJsonJson

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
/**
 * Tests envelope JSON + meta JSON + data JSON
 */
@Test
public final void testConvertJsonJsonJson() throws IOException {

    // PREPARE
    final EnhancedMimeType envelope = EnhancedMimeType.create("application", "json",
            Charset.forName("utf-8"));
    final int json = 1;
    final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
    registry.add(EscMeta.SER_TYPE, envelope.getBaseType(), new EscMetaJsonDeSerializer());
    registry.add(MyEvent.SER_TYPE, "application/json", new MyEvent.MyEventJsonDeSerializer());
    registry.add(MyMeta.SER_TYPE, "application/json", new MyMeta.MyMetaJsonDeSerializer());

    final MyEvent myEvent = new MyEvent(UUID.randomUUID(), "Hello, JSON!");
    final MyMeta myMeta = new MyMeta("michael");
    final CommonEvent commonEvent = new SimpleCommonEvent(new EventId(myEvent.getId()), MyEvent.TYPE,
            myEvent, MyMeta.TYPE, myMeta);

    final CommonEvent2EventDataConverter converter = new CommonEvent2EventDataConverter(registry,
            envelope);
    final EventData eventData = converter.convert(commonEvent);

    final EventRecord eventRecord = EventRecord.newBuilder()
            .setEventId(ByteString.copyFrom(UUIDConverter.toBytes(eventData.eventId)))
            .setEventStreamId("mystream").setEventNumber(1).setEventType(eventData.type)
            .setDataContentType(json).setData(ByteString.copyFrom(eventData.data))
            .setMetadataContentType(1).setMetadata(ByteString.copyFrom(eventData.metadata))
            .setCreated(System.currentTimeMillis()).build();
    final RecordedEvent recordedEvent = new RecordedEvent(eventRecord);
    final RecordedEvent2CommonEventConverter testee = new RecordedEvent2CommonEventConverter(registry);

    // TEST
    final CommonEvent result = testee.convert(recordedEvent);

    // VERIFY
    assertThat(result.getId()).isEqualTo(new EventId(myEvent.getId()));
    assertThat(result.getDataType()).isEqualTo(MyEvent.TYPE);
    assertThat(result.getMetaType()).isEqualTo(MyMeta.TYPE);

    assertThat(result.getData()).isInstanceOf(MyEvent.class);
    final MyEvent copyMyEvent = (MyEvent) result.getData();
    assertThat(copyMyEvent.getId()).isEqualTo(myEvent.getId());
    assertThat(copyMyEvent.getDescription()).isEqualTo(myEvent.getDescription());

    assertThat(result.getMeta()).isInstanceOf(MyMeta.class);
    final MyMeta copyMyMeta = (MyMeta) result.getMeta();
    assertThat(copyMyMeta.getUser()).isEqualTo(myMeta.getUser());

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:52,代码来源:RecordedEvent2CommonEventConverterTest.java

示例9: testConvertJsonJsonOther

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
/**
 * Tests envelope JSON + meta JSON + data XML (non JSON)
 */
@Test
public final void testConvertJsonJsonOther() throws IOException {

    // PREPARE
    final EnhancedMimeType envelope = EnhancedMimeType.create("application", "json",
            Charset.forName("utf-8"));
    final int json = 1;
    final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
    registry.add(EscMeta.SER_TYPE, envelope.getBaseType(), new EscMetaJsonDeSerializer());
    registry.add(Base64Data.SER_TYPE, envelope.getBaseType(), new Base64DataJsonDeSerializer());
    registry.add(MyMeta.SER_TYPE, "application/json", new MyMeta.MyMetaJsonDeSerializer());
    registry.add(MyEvent.SER_TYPE, "application/xml", new XmlDeSerializer(JAXB_CLASSES));

    final MyEvent myEvent = new MyEvent(UUID.randomUUID(), "Hello, XML!");
    final MyMeta myMeta = new MyMeta("michael");
    final CommonEvent commonEvent = new SimpleCommonEvent(new EventId(myEvent.getId()), MyEvent.TYPE,
            myEvent, MyMeta.TYPE, myMeta);

    final CommonEvent2EventDataConverter converter = new CommonEvent2EventDataConverter(registry,
            envelope);
    final EventData eventData = converter.convert(commonEvent);

    final EventRecord eventRecord = EventRecord.newBuilder()
            .setEventId(ByteString.copyFrom(UUIDConverter.toBytes(eventData.eventId)))
            .setEventStreamId("mystream").setEventNumber(1).setEventType(eventData.type)
            .setDataContentType(json).setData(ByteString.copyFrom(eventData.data))
            .setMetadataContentType(1).setMetadata(ByteString.copyFrom(eventData.metadata))
            .setCreated(System.currentTimeMillis()).build();
    final RecordedEvent recordedEvent = new RecordedEvent(eventRecord);
    final RecordedEvent2CommonEventConverter testee = new RecordedEvent2CommonEventConverter(registry);

    // TEST
    final CommonEvent result = testee.convert(recordedEvent);

    // VERIFY
    assertThat(result.getId()).isEqualTo(new EventId(myEvent.getId()));
    assertThat(result.getDataType()).isEqualTo(MyEvent.TYPE);
    assertThat(result.getMetaType()).isEqualTo(MyMeta.TYPE);

    assertThat(result.getData()).isInstanceOf(MyEvent.class);
    final MyEvent copyMyEvent = (MyEvent) result.getData();
    assertThat(copyMyEvent.getId()).isEqualTo(myEvent.getId());
    assertThat(copyMyEvent.getDescription()).isEqualTo(myEvent.getDescription());

    assertThat(result.getMeta()).isInstanceOf(MyMeta.class);
    final MyMeta copyMyMeta = (MyMeta) result.getMeta();
    assertThat(copyMyMeta.getUser()).isEqualTo(myMeta.getUser());

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:53,代码来源:RecordedEvent2CommonEventConverterTest.java

示例10: testConvertJsonOtherOther

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
/**
 * Tests envelope JSON + meta JSON + data XML (non JSON)
 */
@Test
public final void testConvertJsonOtherOther() throws IOException {

    // PREPARE
    final EnhancedMimeType envelope = EnhancedMimeType.create("application", "json",
            Charset.forName("utf-8"));
    final int json = 1;
    final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
    registry.add(EscMeta.SER_TYPE, envelope.getBaseType(), new EscMetaJsonDeSerializer());
    registry.add(Base64Data.SER_TYPE, envelope.getBaseType(), new Base64DataJsonDeSerializer());
    registry.add(MyMeta.SER_TYPE, "application/xml", new XmlDeSerializer(JAXB_CLASSES));
    registry.add(MyEvent.SER_TYPE, "application/xml", new XmlDeSerializer(JAXB_CLASSES));

    final MyEvent myEvent = new MyEvent(UUID.randomUUID(), "Hello, XML!");
    final MyMeta myMeta = new MyMeta("michael");
    final CommonEvent commonEvent = new SimpleCommonEvent(new EventId(myEvent.getId()), MyEvent.TYPE,
            myEvent, MyMeta.TYPE, myMeta);

    final CommonEvent2EventDataConverter converter = new CommonEvent2EventDataConverter(registry,
            envelope);
    final EventData eventData = converter.convert(commonEvent);

    final EventRecord eventRecord = EventRecord.newBuilder()
            .setEventId(ByteString.copyFrom(UUIDConverter.toBytes(eventData.eventId)))
            .setEventStreamId("mystream").setEventNumber(1).setEventType(eventData.type)
            .setDataContentType(json).setData(ByteString.copyFrom(eventData.data))
            .setMetadataContentType(1).setMetadata(ByteString.copyFrom(eventData.metadata))
            .setCreated(System.currentTimeMillis()).build();
    final RecordedEvent recordedEvent = new RecordedEvent(eventRecord);
    final RecordedEvent2CommonEventConverter testee = new RecordedEvent2CommonEventConverter(registry);

    // TEST
    final CommonEvent result = testee.convert(recordedEvent);

    // VERIFY
    assertThat(result.getId()).isEqualTo(new EventId(myEvent.getId()));
    assertThat(result.getDataType()).isEqualTo(MyEvent.TYPE);
    assertThat(result.getMetaType()).isEqualTo(MyMeta.TYPE);

    assertThat(result.getData()).isInstanceOf(MyEvent.class);
    final MyEvent copyMyEvent = (MyEvent) result.getData();
    assertThat(copyMyEvent.getId()).isEqualTo(myEvent.getId());
    assertThat(copyMyEvent.getDescription()).isEqualTo(myEvent.getDescription());

    assertThat(result.getMeta()).isInstanceOf(MyMeta.class);
    final MyMeta copyMyMeta = (MyMeta) result.getMeta();
    assertThat(copyMyMeta.getUser()).isEqualTo(myMeta.getUser());

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:53,代码来源:RecordedEvent2CommonEventConverterTest.java

示例11: testConvertXmlXmlXml

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
/**
 * Tests envelope XML + meta XML + data XML
 */
@Test
public final void testConvertXmlXmlXml() throws IOException {

    // PREPARE
    final EnhancedMimeType envelope = EnhancedMimeType.create("application", "xml",
            Charset.forName("utf-8"));
    final int json = 0;
    final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
    registry.add(EscMeta.SER_TYPE, envelope.getBaseType(), new XmlDeSerializer(JAXB_CLASSES));
    registry.add(MyEvent.SER_TYPE, "application/xml", new XmlDeSerializer(JAXB_CLASSES));
    registry.add(MyMeta.SER_TYPE, "application/xml", new XmlDeSerializer(JAXB_CLASSES));

    final MyEvent myEvent = new MyEvent(UUID.randomUUID(), "Hello, JSON!");
    final MyMeta myMeta = new MyMeta("michael");
    final CommonEvent commonEvent = new SimpleCommonEvent(new EventId(myEvent.getId()), MyEvent.TYPE,
            myEvent, MyMeta.TYPE, myMeta);

    final CommonEvent2EventDataConverter converter = new CommonEvent2EventDataConverter(registry,
            envelope);
    final EventData eventData = converter.convert(commonEvent);

    final EventRecord eventRecord = EventRecord.newBuilder()
            .setEventId(ByteString.copyFrom(UUIDConverter.toBytes(eventData.eventId)))
            .setEventStreamId("mystream").setEventNumber(1).setEventType(eventData.type)
            .setDataContentType(json).setData(ByteString.copyFrom(eventData.data))
            .setMetadataContentType(1).setMetadata(ByteString.copyFrom(eventData.metadata))
            .setCreated(System.currentTimeMillis()).build();
    final RecordedEvent recordedEvent = new RecordedEvent(eventRecord);
    final RecordedEvent2CommonEventConverter testee = new RecordedEvent2CommonEventConverter(registry);

    // TEST
    final CommonEvent result = testee.convert(recordedEvent);

    // VERIFY
    assertThat(result.getId()).isEqualTo(new EventId(myEvent.getId()));
    assertThat(result.getDataType()).isEqualTo(MyEvent.TYPE);
    assertThat(result.getMetaType()).isEqualTo(MyMeta.TYPE);

    assertThat(result.getData()).isInstanceOf(MyEvent.class);
    final MyEvent copyMyEvent = (MyEvent) result.getData();
    assertThat(copyMyEvent.getId()).isEqualTo(myEvent.getId());
    assertThat(copyMyEvent.getDescription()).isEqualTo(myEvent.getDescription());

    assertThat(result.getMeta()).isInstanceOf(MyMeta.class);
    final MyMeta copyMyMeta = (MyMeta) result.getMeta();
    assertThat(copyMyMeta.getUser()).isEqualTo(myMeta.getUser());

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:52,代码来源:RecordedEvent2CommonEventConverterTest.java

示例12: testConvertXmlXmlOther

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
/**
 * Tests envelope XML + meta XML + data JSON (non XML)
 */
@Test
public final void testConvertXmlXmlOther() throws IOException {

    // PREPARE
    final EnhancedMimeType envelope = EnhancedMimeType.create("application", "xml",
            Charset.forName("utf-8"));
    final int json = 0;
    final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
    registry.add(EscMeta.SER_TYPE, envelope.getBaseType(), new XmlDeSerializer(JAXB_CLASSES));
    registry.add(Base64Data.SER_TYPE, envelope.getBaseType(), new XmlDeSerializer(JAXB_CLASSES));
    registry.add(MyMeta.SER_TYPE, "application/xml", new XmlDeSerializer(JAXB_CLASSES));
    registry.add(MyEvent.SER_TYPE, "application/json", new MyEvent.MyEventJsonDeSerializer());

    final MyEvent myEvent = new MyEvent(UUID.randomUUID(), "Hello, XML!");
    final MyMeta myMeta = new MyMeta("michael");
    final CommonEvent commonEvent = new SimpleCommonEvent(new EventId(myEvent.getId()), MyEvent.TYPE,
            myEvent, MyMeta.TYPE, myMeta);

    final CommonEvent2EventDataConverter converter = new CommonEvent2EventDataConverter(registry,
            envelope);
    final EventData eventData = converter.convert(commonEvent);

    final EventRecord eventRecord = EventRecord.newBuilder()
            .setEventId(ByteString.copyFrom(UUIDConverter.toBytes(eventData.eventId)))
            .setEventStreamId("mystream").setEventNumber(1).setEventType(eventData.type)
            .setDataContentType(json).setData(ByteString.copyFrom(eventData.data))
            .setMetadataContentType(1).setMetadata(ByteString.copyFrom(eventData.metadata))
            .setCreated(System.currentTimeMillis()).build();
    final RecordedEvent recordedEvent = new RecordedEvent(eventRecord);
    final RecordedEvent2CommonEventConverter testee = new RecordedEvent2CommonEventConverter(registry);

    // TEST
    final CommonEvent result = testee.convert(recordedEvent);

    // VERIFY
    assertThat(result.getId()).isEqualTo(new EventId(myEvent.getId()));
    assertThat(result.getDataType()).isEqualTo(MyEvent.TYPE);
    assertThat(result.getMetaType()).isEqualTo(MyMeta.TYPE);

    assertThat(result.getData()).isInstanceOf(MyEvent.class);
    final MyEvent copyMyEvent = (MyEvent) result.getData();
    assertThat(copyMyEvent.getId()).isEqualTo(myEvent.getId());
    assertThat(copyMyEvent.getDescription()).isEqualTo(myEvent.getDescription());

    assertThat(result.getMeta()).isInstanceOf(MyMeta.class);
    final MyMeta copyMyMeta = (MyMeta) result.getMeta();
    assertThat(copyMyMeta.getUser()).isEqualTo(myMeta.getUser());

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:53,代码来源:RecordedEvent2CommonEventConverterTest.java

示例13: testConvertXmlOtherOther

import com.github.msemys.esjc.RecordedEvent; //导入依赖的package包/类
/**
 * Tests envelope XML + meta JSON + data JSON (non XML)
 */
@Test
public final void testConvertXmlOtherOther() throws IOException {

    // PREPARE
    final EnhancedMimeType envelope = EnhancedMimeType.create("application", "xml",
            Charset.forName("utf-8"));
    final int json = 0;
    final SimpleSerializerDeserializerRegistry registry = new SimpleSerializerDeserializerRegistry();
    registry.add(EscMeta.SER_TYPE, envelope.getBaseType(), new XmlDeSerializer(JAXB_CLASSES));
    registry.add(Base64Data.SER_TYPE, envelope.getBaseType(), new XmlDeSerializer(JAXB_CLASSES));
    registry.add(MyMeta.SER_TYPE, "application/json", new MyMeta.MyMetaJsonDeSerializer());
    registry.add(MyEvent.SER_TYPE, "application/json", new MyEvent.MyEventJsonDeSerializer());

    final MyEvent myEvent = new MyEvent(UUID.randomUUID(), "Hello, JSON!");
    final MyMeta myMeta = new MyMeta("michael");
    final CommonEvent commonEvent = new SimpleCommonEvent(new EventId(myEvent.getId()), MyEvent.TYPE,
            myEvent, MyMeta.TYPE, myMeta);

    final CommonEvent2EventDataConverter converter = new CommonEvent2EventDataConverter(registry,
            envelope);
    final EventData eventData = converter.convert(commonEvent);

    final EventRecord eventRecord = EventRecord.newBuilder()
            .setEventId(ByteString.copyFrom(UUIDConverter.toBytes(eventData.eventId)))
            .setEventStreamId("mystream").setEventNumber(1).setEventType(eventData.type)
            .setDataContentType(json).setData(ByteString.copyFrom(eventData.data))
            .setMetadataContentType(1).setMetadata(ByteString.copyFrom(eventData.metadata))
            .setCreated(System.currentTimeMillis()).build();
    final RecordedEvent recordedEvent = new RecordedEvent(eventRecord);
    final RecordedEvent2CommonEventConverter testee = new RecordedEvent2CommonEventConverter(registry);

    // TEST
    final CommonEvent result = testee.convert(recordedEvent);

    // VERIFY
    assertThat(result.getId()).isEqualTo(new EventId(myEvent.getId()));
    assertThat(result.getDataType()).isEqualTo(MyEvent.TYPE);
    assertThat(result.getMetaType()).isEqualTo(MyMeta.TYPE);

    assertThat(result.getData()).isInstanceOf(MyEvent.class);
    final MyEvent copyMyEvent = (MyEvent) result.getData();
    assertThat(copyMyEvent.getId()).isEqualTo(myEvent.getId());
    assertThat(copyMyEvent.getDescription()).isEqualTo(myEvent.getDescription());

    assertThat(result.getMeta()).isInstanceOf(MyMeta.class);
    final MyMeta copyMyMeta = (MyMeta) result.getMeta();
    assertThat(copyMyMeta.getUser()).isEqualTo(myMeta.getUser());

}
 
开发者ID:fuinorg,项目名称:event-store-commons,代码行数:53,代码来源:RecordedEvent2CommonEventConverterTest.java


注:本文中的com.github.msemys.esjc.RecordedEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。