Tabnine Logo
EndpointDefinition$Builder.httpMethod
Code IndexAdd Tabnine to your IDE (free)

How to use
httpMethod
method
in
com.palantir.conjure.spec.EndpointDefinition$Builder

Best Java code snippets using com.palantir.conjure.spec.EndpointDefinition$Builder.httpMethod (Showing top 12 results out of 315)

origin: palantir/conjure

@Test
public void testPathParamValidatorMissingParams() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path/{paramName}"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Path parameters defined path template but not present in endpoint: [paramName]");
}
origin: palantir/conjure

@Test
public void testNoGetBodyValidator() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(BODY_ARG_BUILDER.argName(ArgumentName.of("bodyArg")).build())
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage(String.format(
          "Endpoint cannot be a GET and contain a body: method: %s, path: %s",
          HttpMethod.GET,
          "/a/path"));
}
origin: palantir/conjure

private static EndpointDefinition parseEndpoint(
    String name,
    com.palantir.conjure.parser.services.EndpointDefinition def,
    PathString basePath,
    Optional<AuthType> defaultAuth,
    ReferenceTypeResolver typeResolver,
    DealiasingTypeVisitor dealiasingVisitor) {
  HttpPath httpPath = parseHttpPath(def, basePath);
  EndpointDefinition endpoint = EndpointDefinition.builder()
      .endpointName(EndpointName.of(name))
      .httpMethod(HttpMethod.valueOf(def.http().method()))
      .httpPath(httpPath)
      .auth(def.auth().map(ConjureParserUtils::parseAuthType).orElse(defaultAuth))
      .args(parseArgs(def.args(), httpPath, typeResolver))
      .markers(parseMarkers(def.markers(), typeResolver))
      .returns(def.returns().map(t -> t.visit(new ConjureTypeParserVisitor(typeResolver))))
      .docs(def.docs().map(Documentation::of))
      .deprecated(def.deprecated().map(Documentation::of))
      .build();
  EndpointDefinitionValidator.validateAll(endpoint, dealiasingVisitor);
  return endpoint;
}
origin: palantir/conjure

  @Test
  public void testComplexHeaderObject() {
    TypeName typeName = TypeName.of("SomeObject", "com.palantir.foo");
    EndpointDefinition.Builder definition = EndpointDefinition.builder()
        .args(ArgumentDefinition.builder()
            .argName(ArgumentName.of("someName"))
            .type(Type.reference(typeName))
            .paramType(ParameterType.header(HeaderParameterType.of(ParameterId.of("SomeId"))))
            .build())
        .endpointName(ENDPOINT_NAME)
        .httpMethod(HttpMethod.GET)
        .httpPath(HttpPath.of("/a/path"));

    DealiasingTypeVisitor dealiasingVisitor = new DealiasingTypeVisitor(ImmutableMap.of(
        typeName, TypeDefinition.object(ObjectDefinition.of(typeName, ImmutableList.of(), Documentation.of("")))
    ));

    assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), dealiasingVisitor))
        .isInstanceOf(IllegalStateException.class)
        .hasMessage("Header parameters must be enums, primitives, aliases or optional primitive:"
            + " \"someName\" is not allowed");
  }
}
origin: palantir/conjure

@Test
public void testPathParamValidatorUniquePathParams() {
  ArgumentDefinition paramDefinition1 = ArgumentDefinition.builder()
      .argName(ArgumentName.of("paramName"))
      .type(Type.primitive(PrimitiveType.STRING))
      .paramType(ParameterType.path(PathParameterType.of()))
      .build();
  ArgumentDefinition paramDefinition2 = ArgumentDefinition.builder()
      .argName(ArgumentName.of("paramName"))
      .type(Type.primitive(PrimitiveType.STRING))
      .paramType(ParameterType.path(PathParameterType.of()))
      .build();
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(ImmutableList.of(paramDefinition1, paramDefinition2))
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Path parameter with identifier \"paramName\" is defined multiple times for endpoint");
}
origin: palantir/conjure

@Test
public void testComplexHeader() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(ArgumentDefinition.builder()
          .argName(ArgumentName.of("someName"))
          .type(Type.list(ListType.builder().itemType(Type.primitive(PrimitiveType.STRING)).build()))
          .paramType(ParameterType.header(HeaderParameterType.of(ParameterId.of("someId"))))
          .build())
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Header parameters must be enums, primitives, aliases or optional primitive:"
          + " \"someName\" is not allowed");
}
origin: palantir/conjure

@Test
public void testPathParamValidatorExtraParams() {
  ArgumentDefinition paramDefinition = ArgumentDefinition.builder()
      .type(Type.primitive(PrimitiveType.STRING))
      .argName(ArgumentName.of("paramName"))
      .paramType(ParameterType.path(PathParameterType.of()))
      .build();
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(paramDefinition)
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalStateException.class)
      .hasMessageContaining(
          "Path parameters defined in endpoint but not present in path template: [paramName]");
}
origin: palantir/conjure

@Test
@SuppressWarnings("CheckReturnValue")
public void testArgumentBodyTypeValidator() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(ImmutableList.of(ArgumentDefinition.builder()
          .argName(ArgumentName.of("testArg"))
          .type(Type.primitive(PrimitiveType.BINARY))
          .paramType(ParameterType.body(BodyParameterType.of()))
          .build()))
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.POST)
      .httpPath(HttpPath.of("/a/path"));
  // Should not throw exception
  EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor);
}
origin: palantir/conjure

  private EndpointDefinition createEndpoint(ParameterType paramType) {
    ArgumentDefinition arg = ArgumentDefinition.builder()
        .argName(PARAMETER_NAME)
        .paramType(paramType)
        .type(Type.primitive(PrimitiveType.INTEGER))
        .build();
    EndpointDefinition definition = EndpointDefinition.builder()
        .httpMethod(HttpMethod.POST)
        .httpPath(HttpPath.of("/a/path"))
        .args(arg)
        .endpointName(EndpointName.of("test"))
        .build();

    EndpointDefinitionValidator.validateAll(definition, dealiasingVisitor);
    return definition;
  }
}
origin: palantir/conjure

@Test
public void testArgumentTypeValidator() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(ImmutableList.of(ArgumentDefinition.builder()
          .argName(ArgumentName.of("testArg"))
          .type(Type.primitive(PrimitiveType.BINARY))
          .paramType(ParameterType.header(HeaderParameterType.of(ParameterId.of("testArg"))))
          .build()))
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalArgumentException.class)
      .hasMessage("Non body parameters cannot be of the 'binary' type: 'testArg' is not allowed");
}
origin: palantir/conjure

  private EndpointDefinition.Builder createEndpoint(String paramName) {
    ArgumentDefinition arg = ArgumentDefinition.builder()
        .paramType(ParameterType.body(BodyParameterType.of()))
        .type(Type.primitive(PrimitiveType.STRING))
        .argName(ArgumentName.of(paramName))
        .build();
    return EndpointDefinition.builder()
        .httpMethod(HttpMethod.POST)
        .httpPath(HttpPath.of("/a/path"))
        .args(ImmutableList.of(arg))
        .endpointName(EndpointName.of("test"));
  }
}
origin: palantir/conjure

@Test
public void testSingleBodyParamValidator() {
  EndpointDefinition.Builder definition = EndpointDefinition.builder()
      .args(BODY_ARG_BUILDER.argName(ArgumentName.of("bodyArg1")).build())
      .args(BODY_ARG_BUILDER.argName(ArgumentName.of("bodyArg2")).build())
      .endpointName(ENDPOINT_NAME)
      .httpMethod(HttpMethod.GET)
      .httpPath(HttpPath.of("/a/path"));
  assertThatThrownBy(() -> EndpointDefinitionValidator.validateAll(definition.build(), emptyDealiasingVisitor))
      .isInstanceOf(IllegalStateException.class)
      .hasMessage("Endpoint cannot have multiple body parameters: [bodyArg1, bodyArg2]");
}
com.palantir.conjure.specEndpointDefinition$BuilderhttpMethod

Popular methods of EndpointDefinition$Builder

  • args
  • build
  • endpointName
  • httpPath
  • auth
  • deprecated
  • docs
  • markers
  • returns

Popular in Java

  • Reactive rest calls using spring rest template
  • compareTo (BigDecimal)
  • setRequestProperty (URLConnection)
  • getSystemService (Context)
  • Container (java.awt)
    A generic Abstract Window Toolkit(AWT) container object is a component that can contain other AWT co
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • String (java.lang)
  • ConnectException (java.net)
    A ConnectException is thrown if a connection cannot be established to a remote host on a specific po
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • CodeWhisperer alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now