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

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


      List<String> enumDescriptions,
      String minimum,
      String maximum,
      boolean required,
      String pattern) {
    Schema parameter = EasyMock.createControl().createMock(Schema.class);
    EasyMock.expect(parameter.isRepeated()).andReturn(repeated);
    EasyMock.expect(parameter.getType()).andReturn(type);
    EasyMock.expect(parameter.getEnumValues()).andReturn(enumValues);
    EasyMock.expect(parameter.getEnumDescriptions()).andReturn(enumDescriptions);
    EasyMock.expect(parameter.getMinimum()).andReturn(minimum);
    EasyMock.expect(parameter.getMaximum()).andReturn(maximum);
    EasyMock.expect(parameter.isRequired()).andReturn(required);
    EasyMock.expect(parameter.getPattern()).andReturn(pattern);

    EasyMock.replay(parameter);

    Editor editor = EditorFactory.forParameter(parameter);
    EasyMock.verify(parameter);
View Full Code Here


    schemaForm.setSchema(
        new MockApiService(), new MockApiMethod(), CustomSchema.objectSchema(null, null, false));
  }

  public void testLockedRequiredFields() {
    Schema lockedString = CustomSchema.lockedStringField(null);
    Schema optional = CustomSchema.objectSchema(EMPTY_PROPERTIES, null, false);

    Map<String, Schema> properties = ImmutableMap.of("locked", lockedString, "optional", optional);
    ObjectSchemaEditor objectEditor =
        new ObjectSchemaEditor(schemaForm, null, null, properties, null, false);
View Full Code Here

    assertEquals(true, objectEditor.listBox.isVisible());
    assertEquals(false, objectEditor.newItem.isVisible());
  }

  public void testRequredNotDuplicated() {
    Schema lockedString = CustomSchema.lockedStringField(null);
    Map<String, Schema> properties = ImmutableMap.of("prop1", lockedString);
    ObjectSchemaEditor objectEditor =
        new ObjectSchemaEditor(schemaForm, null, null, properties, null, false);

    // Initialize a value for this property
View Full Code Here

        ((ObjectElement) objectEditor.editors.get("prop1")).innerEditor.getClass());
    assertEquals("\"a value\"", objectEditor.editors.get("prop1").getJSONValue().toString());
  }

  public void testAdditionalProperties() {
    Schema additionalProperties = CustomSchema.objectSchema(EMPTY_PROPERTIES, null, false);
    ObjectSchemaEditor objectEditor = new ObjectSchemaEditor(schemaForm,
        null,
        null,
        EMPTY_PROPERTIES,
        additionalProperties,
View Full Code Here

    assertEquals(0, objectEditor.editors.size());
    assertEquals(1, objectEditor.additionalPropertyEditors.size());
  }

  public void testSchemaAndAdditionalProperties() {
    Schema object1 = CustomSchema.objectSchema(EMPTY_PROPERTIES, null, false);
    Schema object2 = CustomSchema.objectSchema(EMPTY_PROPERTIES, null, false);

    Map<String, Schema> properties = ImmutableMap.of("obj1", object1, "obj2", object2);

    Schema additionalProperties = CustomSchema.objectSchema(EMPTY_PROPERTIES, null, false);
    ObjectSchemaEditor objectEditor = new ObjectSchemaEditor(schemaForm,
        null,
        null,
        properties,
        additionalProperties,
View Full Code Here

    assertEquals(mockMethod, methodResult.getMethodBundle().getMethod());
  }

  /** Test that method parameters, and method parameter descriptions get indexed. */
  public void testMethodParameters() {
    Schema parameter = EasyMock.createMock(Schema.class);
    EasyMock.expect(parameter.getDescription())
        .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())
View Full Code Here

  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

    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());
    assertEquals("[^/]+", seriesId.getPattern());
  }
View Full Code Here

    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

  /** Test that the free-form to schema data binding works as expected. */
  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();
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.