@Test
 public void addTrait() {
   Raml raml = this.parseRaml("org/raml/traits/single-trait-add.yaml");
   Map<String, QueryParameter> queryParams =
       raml.getResources().get("/media").getAction(GET).getQueryParameters();
   assertThat(queryParams.size(), is(1));
   assertThat(queryParams.get("count").getType(), is(ParamType.INTEGER));
   assertThat(
       raml.getResources().get("/media").getAction(POST).getQueryParameters().size(), is(2));
 }
  private Raml verifyDump(Raml source, String dump) {
    RamlDocumentBuilder verifier = new RamlDocumentBuilder();
    Raml target = verifier.build(dump, "");

    assertThat(target.getTitle(), is(source.getTitle()));
    assertThat(target.getVersion(), is(source.getVersion()));
    assertThat(target.getBaseUri(), is(source.getBaseUri()));
    assertThat(target.getBaseUriParameters().size(), is(source.getBaseUriParameters().size()));
    assertThat(target.getDocumentation().size(), is(source.getDocumentation().size()));
    assertThat(target.getResources().size(), is(source.getResources().size()));

    return target;
  }
예제 #3
0
  private Set<String> run(final Raml raml, final Configuration configuration) throws Exception {
    validate(configuration);

    context = new Context(configuration, raml);
    types = new Types(context);

    for (final Resource resource : raml.getResources().values()) {
      createResourceInterface(resource);
    }

    return context.generate();
  }
 @Test
 public void mergeOptionalTrait() {
   Raml raml = this.parseRaml("org/raml/traits/single-trait-optional-merge.yaml");
   assertThat(raml.getResources().get("/media").getAction(GET).getQueryParameters().size(), is(2));
 }
 @Test
 public void addOptionalTrait() {
   Raml raml = this.parseRaml("org/raml/traits/single-trait-optional-add.yaml");
   assertThat(raml.getResources().get("/media").getAction(GET), nullValue());
 }