Examples of ApiMethod


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

    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

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

  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

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

    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

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

  /**
   * 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

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

  /**
   * 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

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

  /**
   * 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

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

  /**
   * Tests repeated parameters.
   */
  public void testRepeated() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    EasyMock.expect(method.getHttpMethod()).andReturn(HttpMethod.GET);
    EasyMock.expect(method.getPath()).andReturn("/path/to{/repeatedParam*}").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

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

  private ApiService plusService;
  private UrlEncoder originalEncoder;

  @Override
  public void setUp() {
    ApiMethod listActivities = EasyMock.createNiceMock(ApiMethod.class);
    expect(listActivities.getHttpMethod()).andReturn(HttpMethod.GET).anyTimes();
    expect(listActivities.getPath()).andReturn(LIST_METHOD_PATH).anyTimes();
    expect(listActivities.getId()).andReturn(LIST_METHOD_NAME).anyTimes();
    replay(listActivities);

    Map<String, ApiMethod> allActivities = Maps.newHashMap();
    allActivities.put(LIST_METHOD_NAME, listActivities);
View Full Code Here

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

  /**
   * Test the identification of explorer links
   */
  public void testExplorerLinks() {
    ApiMethod method = JsonPrettifier.getMethodForUrl(plusService, PLUS_LINK);
    assertNotNull(method);
    assertEquals(LIST_METHOD_NAME, method.getId());
    assertEquals(HttpMethod.GET, method.getHttpMethod());

    String link = JsonPrettifier.createExplorerLink(plusService, PLUS_LINK, method);
    assertEquals(EXPLORER_LINK, link);
  }
View Full Code Here

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

    Capture<ExplorerContext> contextCapture = new Capture<ExplorerContext>();
    delegate.setContext(EasyMock.capture(contextCapture));
    EasyMock.expectLastCall();

    ApiService service = EasyMock.createMock(ApiService.class);
    ApiMethod method = EasyMock.createMock(ApiMethod.class);
    Map<String, ApiMethod> allMethods = ImmutableMap.of("plus.method.name", method);
    EasyMock.expect(service.allMethods()).andReturn(allMethods);
    EasyMock.expect(service.displayTitle()).andReturn("Plus API");
    EasyMock.expect(service.getVersion()).andReturn("v1");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.