Package com.google.api.explorer.client.base

Examples of com.google.api.explorer.client.base.ApiMethod


   * When a ServiceLoadedEvent fires, the Display becomes visible and displays
   * the user as un-authenticated by default.
   */

  public void testServiceLoadedWithoutAuth() {
    ApiMethod method1 = EasyMock.createControl().createMock(ApiMethod.class);
    ApiMethod method2 = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(service.allMethods()).andReturn(
        ImmutableMap.of("method.one", method1, "method.two", method2));
    EasyMock.expect(service.getName()).andReturn("service");
    display.setScopes(Collections.<String, ApiService.AuthScope>emptyMap());
    display.setState(State.PUBLIC, EMPTY_SCOPES, EMPTY_SCOPES);
View Full Code Here


    EasyMock.verify(display);
  }

  /** Check the flow which sets up the display for auth. */
  public void testAuthGranted() {
    ApiMethod method1 = EasyMock.createControl().createMock(ApiMethod.class);
    ApiMethod method2 = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(method1.getScopes()).andReturn(ImmutableList.of("scopeName")).anyTimes();
    ImmutableSet<String> authScopes = ImmutableSet.of("scopeName");
    Map<String, AuthInformation> auth = generateAuthInformation(authScopes);
    EasyMock.expect(service.getAuth()).andReturn(auth).anyTimes();

View Full Code Here

    assertEquals(mockService.getVersion(), apiResult.getService().getVersion());
  }

  /** Test that method names and descriptions get indexed correctly. */
  public void testMethods() {
    ApiMethod mockMethod = EasyMock.createMock(ApiMethod.class);
    EasyMock.expect(mockMethod.getDescription()).andReturn("method description").anyTimes();
    EasyMock.expect(mockMethod.getId()).andReturn("collection.methodName").anyTimes();
    EasyMock.expect(mockMethod.getParameters()).andReturn(null).anyTimes();

    ApiMethod mockMethod2 = EasyMock.createMock(ApiMethod.class);
    EasyMock.expect(mockMethod2.getDescription()).andReturn("anotherMethod description").anyTimes();
    EasyMock.expect(mockMethod2.getId()).andReturn("collection.anotherMethod").anyTimes();
    EasyMock.expect(mockMethod2.getParameters()).andReturn(null).anyTimes();

    EasyMock.expect(mockService.allMethods()).andReturn(ImmutableMap.of(
        "collection.methodName", mockMethod, "collection.anotherMethod", mockMethod2));

    EasyMock.replay(mockService, mockMethod, mockMethod2);

    List<SearchEntry> entries = ImmutableList.copyOf(discoveryStrategy.index(mockService));

    EasyMock.verify(mockService, mockMethod, mockMethod2);

    assertEquals(3, entries.size());

    // Extract the entries.
    SearchEntry method1Entry = null;
    SearchEntry method2Entry = null;
    SearchEntry serviceEntry = null;
    for (SearchEntry entry : entries) {
      SearchResult result = entry.getSearchResult();

      if (result.getKind() == Kind.SERVICE) {
        serviceEntry = entry;
      } else if (result.getKind() == Kind.METHOD) {
        if (mockMethod.equals(result.getMethodBundle().getMethod())) {
          method1Entry = entry;
        } else if (mockMethod2.equals(result.getMethodBundle().getMethod())) {
          method2Entry = entry;
        } else {
          fail("Unexpected method result: " + result.getMethodBundle().getMethod());
        }
      } else {
View Full Code Here

        .andReturn("parameterDescription description").anyTimes();

    Schema noDescription = EasyMock.createMock(Schema.class);
    EasyMock.expect(noDescription.getDescription()).andReturn(null).anyTimes();

    ApiMethod mockMethod = EasyMock.createMock(ApiMethod.class);
    EasyMock.expect(mockMethod.getDescription()).andReturn("method description").anyTimes();
    EasyMock.expect(mockMethod.getId()).andReturn("collection.methodName").anyTimes();
    EasyMock.expect(mockMethod.getParameters())
        .andReturn(ImmutableMap.of("paramName", parameter, "noDescription", noDescription))
        .anyTimes();

    EasyMock.expect(mockService.allMethods())
        .andReturn(ImmutableMap.of("collection.methodName", mockMethod));
View Full Code Here

    assertEquals(1, service.getMethods().keySet().size());
  }

  /** Tests that a top-level method is parsed as expected. */
  public void testToplevelMethod() {
    ApiMethod get = service.getMethods().get("get");
    assertEquals("/get/{param}", get.getPath());
    assertEquals(HttpMethod.GET, get.getHttpMethod());

    Schema param = get.getParameters().get("param");
    assertFalse(param.isRequired());
    assertNull(param.getPattern());
  }
View Full Code Here

  public void testResource() {
    RestApiService.ApiResource series = service.getResources().get("series");
    assertEquals(1, series.getMethods().keySet().size());
    assertEquals(1, series.getResources().keySet().size());

    ApiMethod seriesGet = series.getMethods().get("get");
    assertEquals("/series/{seriesId}", seriesGet.getPath());
    assertEquals(HttpMethod.GET, seriesGet.getHttpMethod());

    Schema seriesId = seriesGet.getParameters().get("seriesId");

    // TODO(jasonhall): There is a bug with AutoBeans in JRE where booleans --
    // like isRequired() -- are always false, meaning this always passes
    // validation in JUnit tests. When this bug is fixed, uncomment this line.
    // assertTrue(seriesId.isRequired());
View Full Code Here

    RestApiService.ApiResource my = series.getResources().get("my");
    assertNull(my.getResources());
    assertEquals(1, my.getMethods().keySet().size());

    ApiMethod myGet = my.getMethods().get("get");
    assertEquals("/series/my/{seriesId}", myGet.getPath());
    assertEquals(HttpMethod.GET, myGet.getHttpMethod());
    assertEquals(1, myGet.getParameters().keySet().size());

    Schema seriesId = myGet.getParameters().get("seriesId");
    assertFalse(seriesId.isRequired());
    assertEquals("(foo|bar)", seriesId.getPattern());
  }
View Full Code Here

  /**
   * Tests generation of the request path when it is not explicitly set on
   * construction.
   */
  public void testGetRequestPath() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(method.getHttpMethod()).andReturn(HttpMethod.GET);
    EasyMock.expect(method.getPath()).andReturn("/path/to/{pathParam}").times(4);

    RestApiService service = EasyMock.createControl().createMock(RestApiService.class);
    EasyMock.expect(service.basePath()).andReturn("/base").times(4);

    EasyMock.replay(method, service);
View Full Code Here

  /**
   * Tests generation of the request path when the first parameter component is
   * at the beginning of the path.
   */
  public void testMultipleComponents() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(method.getHttpMethod()).andReturn(HttpMethod.GET);
    EasyMock.expect(method.getPath()).andReturn("{firstParam}/path/to/{secondParam}").times(3);

    RestApiService service = EasyMock.createControl().createMock(RestApiService.class);
    EasyMock.expect(service.basePath()).andReturn("/base").times(3);

    EasyMock.replay(method, service);
View Full Code Here

  /**
   * Tests generation of the request path when the entire path is a placeholder.
   */
  public void testLonelyPlaceholder() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(method.getHttpMethod()).andReturn(HttpMethod.GET);
    EasyMock.expect(method.getPath()).andReturn("{lonelyParam}").times(3);

    RestApiService service = EasyMock.createControl().createMock(RestApiService.class);
    EasyMock.expect(service.basePath()).andReturn("/base").times(3);

    EasyMock.replay(method, service);
View Full Code Here

TOP

Related Classes of com.google.api.explorer.client.base.ApiMethod

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.