Skip to content

Commit

Permalink
Add unit tests for XmlFileSource
Browse files Browse the repository at this point in the history
  • Loading branch information
aplotnikov committed Oct 28, 2018
1 parent 8defbb3 commit c86a2cd
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
)
}
Original file line number Diff line number Diff line change
@@ -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<String> 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 * _
}
}

0 comments on commit c86a2cd

Please sign in to comment.