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

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


   * 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

        String.valueOf(Integer.MAX_VALUE), Type.INTEGER);
  }

  private static void assertParameterDescription(
      String expected, String description, String minimum, String maximum, Type type) {
    Schema param = EasyMock.createControl().createMock(Schema.class);
    EasyMock.expect(param.getDescription()).andReturn(description);
    EasyMock.expect(param.getMinimum()).andReturn(minimum);
    EasyMock.expect(param.getMaximum()).andReturn(maximum);
    EasyMock.expect(param.getType()).andReturn(type);
    EasyMock.replay(param);

    assertEquals(expected, EmbeddedParameterFormPresenter.generateDescriptionString(param));

    EasyMock.verify(param);
View Full Code Here

   * 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"));
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);
    display.setMethod(
View Full Code Here

  public void testGetMethod() {
    RpcApiMethod get = service.getMethods().get("moderator.get");
    assertEquals(ImmutableList.of("https://www.googleapis.com/auth/scopename"), get.getScopes());
    assertEquals(ImmutableList.<String>of(), get.getParameterOrder());

    Schema param = get.getParameters().get("param");
    assertFalse(param.isRequired());
    assertNull(param.getPattern());

    @SuppressWarnings("unchecked")
    AutoBean<RpcApiService> serviceBean = EasyMock.createMock(AutoBean.class);
    EasyMock.expect(serviceBean.as()).andReturn(service).anyTimes();
    EasyMock.replay(serviceBean);

    Schema returnsSchema = ApiServiceWrapper.responseSchema(serviceBean, get);
    assertEquals(Type.OBJECT, returnsSchema.getType());

    Schema status = returnsSchema.getProperties().get("status");
    assertEquals(Type.STRING, status.getType());
  }
View Full Code Here

    if (editors.containsKey(key)) {
      return editors.get(key);
    }

    String selectedKey = key == null ? listBox.getValue(listBox.getSelectedIndex()) : key;
    Schema selectedProperty = properties.get(selectedKey);

    SchemaEditor editor = schemaForm.getSchemaEditorForSchema(service, selectedProperty,
        /* Descendants inherit nullability. */ nullableValues);

    boolean isRemovable = !isRequired && !selectedProperty.locked();
    final ObjectElement row =
        new ObjectElement(selectedKey, editor, selectedProperty, isRemovable, nullableValues);
    panel.add(row);
    editors.put(selectedKey, row);

View Full Code Here

    HTMLPanel inner = new HTMLPanel("");
    inner.getElement().getStyle().setPaddingLeft(20, Unit.PX);

    for (String childKey : keys) {
      final Schema property = properties.get(childKey);
      final Map<String, Schema> childProperties = property.getProperties();
      final Schema items = property.getItems();

      if (childProperties == null && items == null) {
        // This is a simple field
        CheckBox checkBox = new CheckBox(childKey);
        checkBox.setValue(root.getValue());
        checkBox.setTitle(property.getDescription());
        children.put(childKey, checkBox);
        checkBox.getElement().appendChild(Document.get().createBRElement());
        inner.add(checkBox);
      } else {

        final FieldsEditor editor = new FieldsEditor(service, childKey);
        children.put(childKey, editor);
        inner.add(editor);

        if (childProperties != null) {
          editor.setProperties(childProperties);
        } else if (property.getRef() != null) {
          editor.setRef(property.getRef());
        } else if (items != null) {
          if (items.getProperties() != null) {
            editor.setProperties(items.getProperties());
          } else if (items.getRef() != null) {
            editor.setRef(items.getRef());
          }
        }
      }
    }
    add(inner);
View Full Code Here

    expando.addStyleName(Resources.INSTANCE.style().clickable());
    expando.setTitle("Click to show more fields");
    expando.addClickHandler(new ClickHandler() {
      @Override
      public void onClick(ClickEvent event) {
        Schema sch = service.getSchemas().get(ref);
        setProperties(sch.getProperties());
        remove(expando);
      }
    });
  }
View Full Code Here

  /** Returns the SchemaEditor for the given Property value. */
  SchemaEditor getSchemaEditorForSchema(
      ApiService service, Schema schema, boolean descendantsNullable) {

    Schema dereferenced = schema;

    if (schema.getRef() != null) {
      // Properties of this object are defined elsewhere.
      dereferenced = service.getSchemas().get(schema.getRef());
    }

    SchemaEditor editor;
    if (dereferenced.getType() != null) {
      switch (dereferenced.getType()) {
        case OBJECT:
          editor = new ObjectSchemaEditor(this,
              method.getId(),
              service,
              dereferenced.getProperties(),
              dereferenced.getAdditionalProperties(),
              methodIsPatch() && descendantsNullable);
          break;

        case ARRAY:
          editor = new ArraySchemaEditor(service, this, dereferenced.getItems());
          break;

        case BOOLEAN:
          editor = new BooleanSchemaEditor();
          break;
View Full Code Here

TOP

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

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.