diff --git a/build.gradle b/build.gradle index 64aa450..d945131 100644 --- a/build.gradle +++ b/build.gradle @@ -49,6 +49,8 @@ dependencies { testCompile( 'org.codehaus.groovy:groovy-all:2.5.3', 'org.spockframework:spock-core:1.2-groovy-2.5', - "io.projectreactor:reactor-test:${reactorVersion}" + "io.projectreactor:reactor-test:${reactorVersion}", + 'net.bytebuddy:byte-buddy:1.9.2', + 'org.objenesis:objenesis:3.0.1' ) } diff --git a/src/test/groovy/io/github/aplotnikov/batch/processing/reactor/source/XmlFileSourceSpec.groovy b/src/test/groovy/io/github/aplotnikov/batch/processing/reactor/source/XmlFileSourceSpec.groovy new file mode 100644 index 0000000..fc5403c --- /dev/null +++ b/src/test/groovy/io/github/aplotnikov/batch/processing/reactor/source/XmlFileSourceSpec.groovy @@ -0,0 +1,35 @@ +package io.github.aplotnikov.batch.processing.reactor.source + +import reactor.core.publisher.Flux +import reactor.test.StepVerifier +import spock.lang.Specification +import spock.lang.Subject + +class XmlFileSourceSpec extends Specification { + + Repository repository = Mock() + + Queue queue = Mock() + + @Subject + XmlFileSource source = new XmlFileSource(repository, queue) + + void 'should merge results from DB and from queue'() { + given: + String fileFromDB = 'file_from_db.xml' + and: + String fileFromQueue = 'file_from_queue.xml' + when: + Flux files = source.readAll() + then: + StepVerifier.create(files) + .expectNext(fileFromDB) + .expectNext(fileFromQueue) + and: + 1 * repository.readAll() >> Flux.just(fileFromDB) + and: + 1 * queue.poll() >> Flux.just(fileFromQueue) + and: + 0 * _ + } +}