コード例 #1
0
  @Test
  public void lightService_requestFavourites() {
    List<LightModel> lights = new ArrayList<>();

    mockClient();
    when(lightRepository.findFavourites()).thenReturn(Observable.just(lights));

    TestSubscriber<List<LightModel>> tester = new TestSubscriber<>();
    lightService.requestFavourites().subscribe(tester);

    tester.assertValue(lights);
    tester.assertCompleted();
    tester.assertNoErrors();
  }
コード例 #2
0
  @Test
  public void lightService_delete() {
    String LIGHT_UUID = "myUuid";

    when(lightRepository.delete(LIGHT_UUID)).thenReturn(Observable.just(null));

    TestSubscriber<Void> tester = new TestSubscriber<>();
    lightService.delete(LIGHT_UUID).subscribe(tester);

    verify(lightRepository).delete(LIGHT_UUID);

    tester.assertCompleted();
    tester.assertNoErrors();
  }
コード例 #3
0
  @Test
  public void lightService_update() {
    LightModel lightModel = new LightModel();

    when(lightRepository.update(lightModel)).thenReturn(Observable.just(null));

    TestSubscriber<Void> tester = new TestSubscriber<>();
    lightService.update(lightModel).subscribe(tester);

    verify(lightRepository).update(lightModel);

    tester.assertCompleted();
    tester.assertNoErrors();
  }
コード例 #4
0
  @Test
  public void lightService_requestByEnvironment() {
    Integer ENVIRONMENT = 108;
    List<LightModel> lights = new ArrayList<>();

    mockClient();
    when(lightRepository.findByEnvironment(ENVIRONMENT)).thenReturn(Observable.just(lights));

    TestSubscriber<List<LightModel>> tester = new TestSubscriber<>();
    lightService.requestByEnvironment(ENVIRONMENT).subscribe(tester);

    tester.assertValue(lights);
    tester.assertCompleted();
    tester.assertNoErrors();
  }
コード例 #5
0
  @Test
  public void lightService_add() {
    String LIGHT_UUID = "myUuid";
    LightModel lightModel = new LightModel();

    when(lightRepository.add(lightModel)).thenReturn(Observable.just(LIGHT_UUID));

    TestSubscriber<String> tester = new TestSubscriber<>();
    lightService.add(lightModel).subscribe(tester);

    verify(lightRepository).add(lightModel);

    tester.assertValue(LIGHT_UUID);
    tester.assertCompleted();
    tester.assertNoErrors();
  }