Тест ScalikeJDBC Издатель с Scalatest - PullRequest
0 голосов
/ 26 сентября 2019

Есть ли у вас какие-либо идеи, почему этот код должен «добавлять людей и затем искать по имени» в {неявном сеансе: DBSession => val person1: Person = Person.create (firstname1, lastname1, ssn1, email1,dob1) .get val person3: Person = Person.create (имя1, фамилия3, ssn3, email3, dob3) .get

val publisher1: DatabasePublisher[Person] = Person.findByFirstName(firstname1)

val probe1 = TestSink.probe[Person](actorSystem)
val (_, sink) = Source
  .fromPublisher(publisher1)
  .toMat(probe1)(Keep.both)
  .run()

sink.request(2)
sink.expectNext(person1, person3)
sink.expectComplete()

}

выдаст эту ошибку

2019-09-26 16:28:13,846 INFO  s.s.DatabasePublisher@[kka.actor.default-dispatcher-6] - Database stream requested by subscriber: akka.stream.impl.fusing.ActorGraphInterpreter$BatchingActorInputBoundary$$anon$1@17b79df0 is ready
2019-09-26 16:28:13,855 INFO  s.s.DatabaseSubscription@[la-execution-context-global-24] - All data for subscriber: akka.stream.impl.fusing.ActorGraphInterpreter$BatchingActorInputBoundary$$anon$1@17b79df0 has been sent
2019-09-26 16:28:13,857 INFO  s.s.DatabaseSubscription@[la-execution-context-global-24] - Finished cleaning up database resources occupied for subscriber: akka.stream.impl.fusing.ActorGraphInterpreter$BatchingActorInputBoundary$$anon$1@17b79df0
[ERROR] Tests run: 11, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 1.683 s <<< FAILURE! - in com.bah.devops.common.entities.PersonTest
[ERROR] Person should add person s and then find-by-firstname(com.bah.devops.common.entities.PersonTest)  Time elapsed: 0.144 s  <<< FAILURE!
    java.lang.AssertionError: assertion failed: expected OnNext(Person(14,FN1,LN1,000-00-0001,1@email.test.com,2019-01-02)), found OnComplete
        at com.bah.devops.common.entities.PersonTest.$anonfun$new$22(PersonTest.scala:418)
        at com.bah.devops.common.entities.PersonTest.$anonfun$new$22$adapted(PersonTest.scala:284)
        at com.bah.devops.common.entities.PersonTest.using(PersonTest.scala:27)
        at com.bah.devops.common.entities.PersonTest.withFixture(PersonTest.scala:27)

?Я не знаю, почему два onNext звонка пропущены.

1 Ответ

0 голосов
/ 26 сентября 2019

Это будет сделано.

val person1: Person = Person.create (имя1, фамилия1, ssn1, email1, dob1) .get val person3: Person = Person.create (имя1, фамилия3, ssn3,email3, dob3) .get

val publisher1: DatabasePublisher[Person] = Person.findByFirstName(firstname1)

val results1Future: Future[Seq[Person]] =
  Source.fromPublisher(publisher1).take(2).runWith(Sink.seq)

val results1: Seq[Person] = Await.result(results1Future, Duration(5, TimeUnit.SECONDS))

results1 should contain(person1)
results1 should contain(person3)
...