コード例 #1
0
  /**
   * Analyzes the data file identified by the given resource name.
   *
   * @param aResourceName the name of the resource (= data file) to analyse, cannot be <code>null
   *     </code>.
   * @return the analysis results, never <code>null</code>.
   * @throws Exception in case of exceptions.
   */
  private I2CDataSet analyseDataFile(
      final String aResourceName, final int aSclIndex, final int aSdaIndex) throws Exception {
    URL resource = ResourceUtils.getResource(getClass(), aResourceName);
    AcquisitionResult container = DataTestUtils.getCapturedData(resource);
    ToolContext toolContext = DataTestUtils.createToolContext(container);

    ToolProgressListener progressListener = Mockito.mock(ToolProgressListener.class);
    AnnotationListener annotationListener = Mockito.mock(AnnotationListener.class);

    I2CAnalyserTask worker = new I2CAnalyserTask(toolContext, progressListener, annotationListener);
    worker.setLineAIndex(aSclIndex);
    worker.setLineBIndex(aSdaIndex);
    worker.setDetectSDA_SCL(false);
    worker.setReportACK(false);
    worker.setReportNACK(false);
    worker.setReportStart(false);
    worker.setReportStop(false);

    // Simulate we're running in a separate thread by directly calling the main
    // working routine...
    I2CDataSet result = worker.call();
    assertNotNull(result);

    return result;
  }
コード例 #2
0
  @Test
  public void testLoadEventsWithDecorators() {
    UUID identifier = UUID.randomUUID();
    SpyEventPreprocessor decorator1 = new SpyEventPreprocessor();
    SpyEventPreprocessor decorator2 = new SpyEventPreprocessor();
    testSubject.setEventStreamDecorators(Arrays.asList(decorator1, decorator2));
    when(mockEventStore.readEvents("test", identifier))
        .thenReturn(
            new SimpleDomainEventStream(
                new GenericDomainEventMessage<String>(
                    identifier, (long) 1, "Mock contents", MetaData.emptyInstance()),
                new GenericDomainEventMessage<String>(
                    identifier, (long) 2, "Mock contents", MetaData.emptyInstance()),
                new GenericDomainEventMessage<String>(
                    identifier, (long) 3, "Mock contents", MetaData.emptyInstance())));
    TestAggregate aggregate = testSubject.load(identifier);
    // loading them in...
    InOrder inOrder = Mockito.inOrder(decorator1.lastSpy, decorator2.lastSpy);
    inOrder.verify(decorator2.lastSpy).next();
    inOrder.verify(decorator1.lastSpy).next();

    inOrder.verify(decorator2.lastSpy).next();
    inOrder.verify(decorator1.lastSpy).next();

    inOrder.verify(decorator2.lastSpy).next();
    inOrder.verify(decorator1.lastSpy).next();
    aggregate.apply(new StubDomainEvent());
    aggregate.apply(new StubDomainEvent());
  }
コード例 #3
0
  @Test
  public void testSaveEventsWithDecorators() {
    SpyEventPreprocessor decorator1 = new SpyEventPreprocessor();
    SpyEventPreprocessor decorator2 = new SpyEventPreprocessor();
    testSubject.setEventStreamDecorators(Arrays.asList(decorator1, decorator2));
    testSubject.setEventStore(
        new EventStore() {
          @Override
          public void appendEvents(String type, DomainEventStream events) {
            while (events.hasNext()) {
              events.next();
            }
          }

          @Override
          public DomainEventStream readEvents(String type, Object identifier) {
            return mockEventStore.readEvents(type, identifier);
          }
        });
    UUID identifier = UUID.randomUUID();
    when(mockEventStore.readEvents("test", identifier))
        .thenReturn(
            new SimpleDomainEventStream(
                new GenericDomainEventMessage<String>(
                    identifier, (long) 3, "Mock contents", MetaData.emptyInstance())));
    TestAggregate aggregate = testSubject.load(identifier);
    aggregate.apply(new StubDomainEvent());
    aggregate.apply(new StubDomainEvent());

    CurrentUnitOfWork.commit();

    InOrder inOrder = Mockito.inOrder(decorator1.lastSpy, decorator2.lastSpy);
    inOrder.verify(decorator1.lastSpy).next();
    inOrder.verify(decorator2.lastSpy).next();

    inOrder.verify(decorator1.lastSpy).next();
    inOrder.verify(decorator2.lastSpy).next();
  }