コード例 #1
0
  @Test
  public void testPlayerSelectorNameSelection() {
    ArrayList<Player> players = new ArrayList<Player>();
    Player p1 = new Player("Tim Player1", Position.QB, null, 1.0);
    Player p2 = new Player("Tom Player2", Position.QB, null, 1.0);
    Player p3 = new Player("John Player3", Position.QB, null, 1.0);
    players.add(p1);
    players.add(p2);
    players.add(p3);

    PlayerSelector sel = new PlayerSelector(players);

    assertEquals(sel.getNumTotalPlayers(), 3);
    assertEquals(sel.getNumAvailablePlayers(), 3);
    assertEquals(sel.getAvailablePlayer(0), p3);

    sel.setText("T");

    assertEquals(sel.getNumTotalPlayers(), 3);
    assertEquals(sel.getNumAvailablePlayers(), 2);
    assertEquals(sel.getAvailablePlayer(0), p1);

    sel.setText("to");

    assertEquals(sel.getNumTotalPlayers(), 3);
    assertEquals(sel.getNumAvailablePlayers(), 1);
    assertEquals(sel.getAvailablePlayer(0), p2);
  }
コード例 #2
0
ファイル: ObservableTests.java プロジェクト: spoon-bot/RxJava
  @Test
  public void fromIterable() {
    ArrayList<String> items = new ArrayList<>();
    items.add("one");
    items.add("two");
    items.add("three");

    assertEquals((Long) 3L, Observable.fromIterable(items).count().toBlocking().single());
    assertEquals("two", Observable.fromIterable(items).skip(1).take(1).toBlocking().single());
    assertEquals("three", Observable.fromIterable(items).takeLast(1).toBlocking().single());
  }
コード例 #3
0
  @Test
  public void testPlayerSelectionEvent() {
    ArrayList<Player> players = new ArrayList<Player>();
    Player p1 = new Player("ABC Player1", Position.QB, null, 1.0);
    Player p2 = new Player("DEF Player2", Position.QB, null, 1.0);
    players.add(p1);
    players.add(p2);

    PlayerSelector sel = new PlayerSelector(players);

    NameSelectionListener listener = mock(NameSelectionListener.class);
    NameSelectionListener listener2 = mock(NameSelectionListener.class);
    sel.addNameSelectionListener(listener);
    sel.addNameSelectionListener(listener2);

    assertEquals(sel.getAvailablePlayer(0), p1);

    sel.setText("de");

    assertEquals(sel.getAvailablePlayer(0), p2);

    sel.selectName();

    verify(listener).nameSelected(p2);
    verify(listener2).nameSelected(p2);

    sel.removeNameSelectionListener(listener);
    sel.setText("ab");
    sel.selectName();

    verifyNoMoreInteractions(listener);
    verify(listener2).nameSelected(p1);
  }
コード例 #4
0
ファイル: TestSparkClient.java プロジェクト: u39kun/livy
    @Override
    public ArrayList<String> call(JobContext jc) {
      String inputFile = "src/test/resources/testweet.json";
      SQLContext sqlctx = jc.sqlctx();
      DataFrame input = sqlctx.jsonFile(inputFile);
      input.registerTempTable("tweets");

      DataFrame topTweets =
          sqlctx.sql("SELECT text, retweetCount FROM tweets ORDER BY retweetCount LIMIT 10");
      ArrayList<String> tweetList = new ArrayList<>();
      for (Row r : topTweets.collect()) {
        tweetList.add(r.toString());
      }
      return tweetList;
    }
コード例 #5
0
ファイル: ObservableTests.java プロジェクト: spoon-bot/RxJava
  @Test
  public void testOfTypeWithPolymorphism() {
    ArrayList<Integer> l1 = new ArrayList<>();
    l1.add(1);
    LinkedList<Integer> l2 = new LinkedList<>();
    l2.add(2);

    @SuppressWarnings("rawtypes")
    Observable<List> observable = Observable.<Object>just(l1, l2, "123").ofType(List.class);

    Subscriber<Object> observer = TestHelper.mockSubscriber();

    observable.subscribe(observer);

    verify(observer, times(1)).onNext(l1);
    verify(observer, times(1)).onNext(l2);
    verify(observer, never()).onNext("123");
    verify(observer, never()).onError(org.mockito.Matchers.any(Throwable.class));
    verify(observer, times(1)).onComplete();
  }