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

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


  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

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

    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

  public void testDataBinding() {
    Map<String, Schema> properties =
        ImmutableMap.of("oneProp", CustomSchema.lockedStringField(null));
    Schema simpleSchema = CustomSchema.objectSchema(properties, null, false);

    ApiMethod apiMethodWithSchema = new MockApiMethod();
    mockService.schemaForMethod.put(apiMethodWithSchema, simpleSchema);

    ApiMethod apiMethodWithoutSchema = new MockApiMethod();
    mockService.schemaForMethod.put(apiMethodWithoutSchema, null);

    // Set the first method and some data in the editors.
    form.setContent(mockService, apiMethodWithSchema, simpleSchema, "");
    String value = "{\n  \"oneProp\": \"oneValue\"\n}";
View Full Code Here

  /**
   * When a MethodSelectedEvent fires, it results in a call to setMethod() with
   * that method.
   */
  public void testMethodSelected() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    Schema param = EasyMock.createControl().createMock(Schema.class);
    EasyMock.expect(method.getParameters()).andReturn(ImmutableMap.of("foo", param)).anyTimes();
    EasyMock.expect(method.getParameterOrder()).andReturn(null);
    EasyMock.expect(param.isRequired()).andReturn(false).anyTimes();

    display.setMethod(service, method, ImmutableSortedMap.of("foo", param),
        ImmutableMultimap.<String, String>of(), null);
    EasyMock.expectLastCall();
View Full Code Here

  /**
   * When a MethodSelectedEvent fires and specifies parameters to fill in, it
   * results in a call to setMethod() as well as setParameterValues().
   */
  public void testMethodSelected_withParams() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    Schema param = EasyMock.createControl().createMock(Schema.class);
    EasyMock.expect(method.getParameters()).andReturn(ImmutableMap.of("foo", param)).anyTimes();
    EasyMock.expect(method.getParameterOrder()).andReturn(null);
    EasyMock.expect(param.isRequired()).andReturn(false).anyTimes();

    Multimap<String, String> queryParams = ImmutableMultimap.of("foo", "bar");
    display.setMethod(service, method, ImmutableSortedMap.of("foo", param), queryParams, null);
    EasyMock.expectLastCall();
View Full Code Here

   * The algorithm in ParameterComparator assures that parameters will be
   * ordered as defined in the parameterOrder list, then alphabetically, even
   * when the parameter map returns the keys in an incorrect order.
   */
  public void testParameterComparator() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    Schema a = EasyMock.createControl().createMock(Schema.class);
    Schema b = EasyMock.createControl().createMock(Schema.class);
    Schema reqA = EasyMock.createControl().createMock(Schema.class);
    Schema reqB = EasyMock.createControl().createMock(Schema.class);
    // Using a SortedMap so that the keys can be guaranteed to be returned in a
    // known unsorted order.
    EasyMock.expect(method.getParameters()).andReturn(
        ImmutableSortedMap.of("b", b, "req-a", reqA, "a", a, "req-b", reqB));
    EasyMock.expect(method.getParameterOrder()).andReturn(ImmutableList.of("req-b", "req-a"));
    EasyMock.replay(method);

    assertEquals(ImmutableSortedSet.of("req-b", "req-a", "a", "b"), ImmutableSortedMap.copyOf(
        method.getParameters(), new ParameterComparator(method.getParameterOrder())).keySet());

    EasyMock.verify(method);
  }
View Full Code Here

  /**
   * Test that when a request body is specified as a query param that it gets mapped to the request
   * body editor.
   */
  public void testRequestBodyPredefinition() {
    ApiMethod method = EasyMock.createControl().createMock(ApiMethod.class);
    Schema param = EasyMock.createControl().createMock(Schema.class);
    EasyMock.expect(method.getParameters()).andReturn(ImmutableMap.of("foo", param)).anyTimes();
    EasyMock.expect(method.getParameterOrder()).andReturn(null);
    EasyMock.expect(param.isRequired()).andReturn(false).anyTimes();

    String requestBodyValue = "{\"key\": \"value\"}";
    Multimap<String, String> queryParams =
        ImmutableMultimap.of("foo", "bar", UrlBuilder.BODY_QUERY_PARAM_KEY, requestBodyValue);
View Full Code Here

      HistoryItem item = Iterables.getOnlyElement(context.getHistoryItems());
      EmbeddedHistoryItemView view = generateHistoryItemView(item);

      detailPane.add(view);
    } else if (context.isMethodFormVisible()) {
      ApiMethod method = context.getMethod();

      // Wrap the callback given by the context so that we may also be notified when a request is
      // finished. Pass through events to the original callback.
      CallbackWrapper cbWrapper = new CallbackWrapper();
      cbWrapper.delegate = context.getRequestFinishedCallback();
      cbWrapper.methodName = method.getId();

      // Create the view of the request editor and the single history item.
      EmbeddedView view = new EmbeddedView(authManager,
          context.getService(),
          method,
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.