예제 #1
0
 public static ImmutableList<Request> getAllRequests(
     final Ds3ApiSpec spec, final Ds3DocSpec docSpec) throws ParseException {
   final ImmutableList.Builder<Request> allRequestsBuilder = ImmutableList.builder();
   if (ConverterUtil.hasContent(spec.getRequests())) {
     for (final Ds3Request ds3Request : spec.getRequests()) {
       allRequestsBuilder.add(RequestConverter.toRequest(ds3Request, docSpec));
     }
   }
   return allRequestsBuilder.build();
 }
 @Test
 public void twoRequestHandlers() throws IOException {
   final Ds3SpecParser parser = new Ds3SpecParserImpl();
   final Ds3ApiSpec spec =
       parser.getSpec(
           Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/twoRequestHandlers.xml"));
   assertThat(spec, is(notNullValue()));
   assertThat(spec.getRequests(), is(notNullValue()));
   assertThat(spec.getRequests().size(), is(2));
   assertThat(
       spec.getRequests().get(0).getName(),
       is("com.spectralogic.s3.server.handler.reqhandler.amazons3.GetObjectRequest"));
   assertThat(
       spec.getRequests().get(1).getName(),
       is("com.spectralogic.s3.server.handler.reqhandler.amazons3.AbortMultiPartUploadRequest"));
 }
예제 #3
0
 /** Requests with optional paging require an extra "ds3_paging" member */
 public static ImmutableSet<String> getPaginatedTypes(final Ds3ApiSpec spec) {
   return spec.getRequests()
       .stream()
       .filter(Ds3RequestClassificationUtil::supportsPaginationRequest)
       .map(req -> RequestConverter.getResponseType(req.getDs3ResponseCodes()))
       .collect(GuavaCollectors.immutableSet());
 }
 @Test
 public void fullXml_3_2() throws IOException {
   final Ds3SpecParser parser = new Ds3SpecParserImpl();
   final Ds3ApiSpec spec =
       parser.getSpec(Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/3_2_fullXml.xml"));
   assertThat(spec, is(notNullValue()));
   assertThat(spec.getRequests(), is(notNullValue()));
   assertThat(spec.getTypes(), is(notNullValue()));
 }
  @Test
  public void SingleRequestHandler() throws IOException {
    final Ds3SpecParser parser = new Ds3SpecParserImpl();
    final Ds3ApiSpec spec =
        parser.getSpec(
            Ds3SpecParserImpl_Test.class.getResourceAsStream("/specs/singleRequestHandler.xml"));
    assertThat(spec, is(notNullValue()));
    assertThat(spec.getRequests().size(), is(1));

    final Ds3Request ds3Request = spec.getRequests().get(0);
    assertThat(
        ds3Request.getName(),
        is("com.spectralogic.s3.server.handler.reqhandler.amazons3.GetObjectRequest"));
    assertThat(ds3Request.getHttpVerb(), is(HttpVerb.GET));
    assertThat(ds3Request.getClassification(), is(Classification.amazons3));
    assertThat(ds3Request.getBucketRequirement(), is(Requirement.REQUIRED));
    assertThat(ds3Request.getObjectRequirement(), is(Requirement.REQUIRED));
    assertThat(ds3Request.getAction(), is(nullValue()));
    assertThat(ds3Request.getResource(), is(nullValue()));
    assertThat(ds3Request.getResourceType(), is(nullValue()));
    assertThat(ds3Request.getOperation(), is(nullValue()));

    assertThat(ds3Request.getDs3ResponseCodes().size(), is(1));
    assertThat(ds3Request.getDs3ResponseCodes().get(0).getCode(), is(200));
    assertThat(ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().size(), is(1));
    assertThat(
        ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().get(0).getType(),
        is("java.lang.String"));
    assertThat(
        ds3Request.getDs3ResponseCodes().get(0).getDs3ResponseTypes().get(0).getComponentType(),
        is(nullValue()));

    assertThat(ds3Request.getOptionalQueryParams().size(), is(0));
    assertThat(ds3Request.getRequiredQueryParams().size(), is(1));
    assertThat(ds3Request.getRequiredQueryParams().get(0).getName(), is("Id"));
    assertThat(ds3Request.getRequiredQueryParams().get(0).getType(), is("java.util.UUID"));
  }