Java Code Examples for rx.observers.AssertableSubscriber#assertValue()

The following examples show how to use rx.observers.AssertableSubscriber#assertValue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AwsObservableExtTest.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
@Test
public void asyncActionSingle() throws Exception {
    AmazonWebServiceRequest someRequest = AmazonWebServiceRequest.NOOP;
    final MockAsyncClient<AmazonWebServiceRequest, String> client = new MockAsyncClient<>(someRequest, "some response");
    Single<String> single = AwsObservableExt.asyncActionSingle(supplier -> client.someAsyncOperation(supplier.handler()));

    TestScheduler testScheduler = Schedulers.test();
    final AssertableSubscriber<String> subscriber = single.subscribeOn(testScheduler).test();

    testScheduler.triggerActions();
    subscriber.assertNoValues();
    subscriber.assertNotCompleted();

    client.run();
    testScheduler.triggerActions();
    subscriber.assertValueCount(1);
    subscriber.assertValue("some response");
    subscriber.assertCompleted();
}
 
Example 2
Source File: TransformersTest.java    From mobius with Apache License 2.0 5 votes vote down vote up
@Test
public void effectPerformerInvokesFunctionWithReceivedEffectAndEmitsReturnedEvents() {
  PublishSubject<String> upstream = PublishSubject.create();
  TestScheduler scheduler = new TestScheduler();
  Function<String, Integer> function = s -> s.length();
  AssertableSubscriber<Integer> observer =
      upstream.compose(Transformers.fromFunction(function, scheduler)).test();

  upstream.onNext("Hello");
  scheduler.triggerActions();
  observer.assertValue(5);
}
 
Example 3
Source File: AggregatingJobServiceGatewayTest.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Test
public void findJob() {
    Random random = new Random();
    List<Job> cellOneSnapshot = new ArrayList<>(dataGenerator.newServiceJobs(10, GrpcJobManagementModelConverters::toGrpcJob));
    cellOne.getServiceRegistry().addService(new CellWithFixedJobsService(cellOneSnapshot, cellOneUpdates.serialize()));
    cellTwo.getServiceRegistry().addService(new CellWithFixedJobsService(Collections.emptyList(), cellTwoUpdates.serialize()));

    Job expected = withStackName(cellOneSnapshot.get(random.nextInt(cellOneSnapshot.size())));
    AssertableSubscriber<Job> testSubscriber = service.findJob(expected.getId(), UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertValue(expected);
}
 
Example 4
Source File: AggregatingJobServiceGatewayTest.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Test
public void findJobWithFailingCell() {
    Random random = new Random();
    List<Job> cellOneSnapshot = new ArrayList<>(dataGenerator.newServiceJobs(10, GrpcJobManagementModelConverters::toGrpcJob));
    cellOne.getServiceRegistry().addService(new CellWithFixedJobsService(cellOneSnapshot, cellOneUpdates.serialize()));
    cellTwo.getServiceRegistry().addService(new CellWithFailingJobManagementService());

    Job expected = withStackName(cellOneSnapshot.get(random.nextInt(cellOneSnapshot.size())));
    AssertableSubscriber<Job> testSubscriber = service.findJob(expected.getId(), UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertValue(expected);
}
 
Example 5
Source File: AggregatingJobServiceGatewayTest.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Test
public void findTask() {
    Random random = new Random();
    List<Task> cellOneSnapshot = new ArrayList<>(dataGenerator.newServiceJobWithTasks());
    cellOne.getServiceRegistry().addService(new CellWithFixedTasksService(cellOneSnapshot));
    cellTwo.getServiceRegistry().addService(new CellWithFixedTasksService(Collections.emptyList()));

    Task expected = withStackName(cellOneSnapshot.get(random.nextInt(cellOneSnapshot.size())));
    AssertableSubscriber<Task> testSubscriber = service.findTask(expected.getId(), UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertValue(expected);
}
 
Example 6
Source File: AggregatingJobServiceGatewayTest.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
@Test
public void findTaskWithFailingCell() {
    Random random = new Random();
    List<Task> cellOneSnapshot = new ArrayList<>(dataGenerator.newServiceJobWithTasks());
    cellOne.getServiceRegistry().addService(new CellWithFixedTasksService(cellOneSnapshot));
    cellTwo.getServiceRegistry().addService(new CellWithFailingJobManagementService(DEADLINE_EXCEEDED));

    Task expected = withStackName(cellOneSnapshot.get(random.nextInt(cellOneSnapshot.size())));
    AssertableSubscriber<Task> testSubscriber = service.findTask(expected.getId(), UNDEFINED_CALL_METADATA).test();
    testSubscriber.awaitTerminalEvent(1, TimeUnit.SECONDS);
    testSubscriber.assertNoErrors();
    testSubscriber.assertValueCount(1);
    testSubscriber.assertValue(expected);
}