コード例 #1
0
  @SuppressWarnings("unchecked")
  public void testGetPlayURIHappyPath() throws URISyntaxException, IOException {

    // mock request and response
    RestResponse restResponse = mock(RestResponse.class);
    when(restClient.doGet(
            eq(Const.USE_HTTPS),
            eq(HostName.PLAY),
            eq(Path.MUSIC_PLAY),
            isA(Map.class),
            isA(Map.class),
            isA(Map.class)))
        .thenReturn(restResponse);

    when(restResponse.getStatusCode()).thenReturn(HttpStatus.SC_OK);

    String playResponseJson = "playResponseJson";
    when(restResponse.getBody()).thenReturn(playResponseJson);
    StreamingUrl streamingUrl = mock(StreamingUrl.class);
    when(gsonWrapper.fromJson(playResponseJson, StreamingUrl.class)).thenReturn(streamingUrl);

    String url = "http://google.com";
    when(streamingUrl.getUrl()).thenReturn(url);

    URI uri = new URI(url);

    // do the call
    assertEquals(uri, playClient.getPlayURI(songId, playSession));
  }
コード例 #2
0
  public void testGetPlayURIFailsDueNullPlaySession() throws IOException, URISyntaxException {
    try {
      playClient.getPlayURI(songId, null);

      fail("should have thrown exception");
    } catch (IllegalArgumentException e) {
    }
  }
コード例 #3
0
  public void testGetPlayURIFailsDueToEmptySongId() throws IOException, URISyntaxException {
    try {
      playClient.getPlayURI("", playSession);

      fail("should have thrown exception");
    } catch (IllegalArgumentException e) {
    }
  }