Tabnine Logo
ArgumentName.of
Code IndexAdd Tabnine to your IDE (free)

How to use
of
method
in
com.palantir.conjure.spec.ArgumentName

Best Java code snippets using com.palantir.conjure.spec.ArgumentName.of (Showing top 10 results out of 315)

origin: palantir/conjure

private static List<ArgumentDefinition> parseArgs(
    Map<ParameterName, com.palantir.conjure.parser.services.ArgumentDefinition> args,
    HttpPath httpPath,
    ReferenceTypeResolver typeResolver) {
  ImmutableList.Builder<ArgumentDefinition> resultBuilder = ImmutableList.builder();
  for (Map.Entry<com.palantir.conjure.parser.services.ParameterName,
      com.palantir.conjure.parser.services.ArgumentDefinition> entry : args.entrySet()) {
    com.palantir.conjure.parser.services.ArgumentDefinition original = entry.getValue();
    ArgumentName argName = ArgumentName.of(entry.getKey().name());
    ParameterType paramType = parseParameterType(original, argName, httpPath);
    ArgumentDefinition.Builder builder = ArgumentDefinition.builder()
        .argName(argName)
        .type(original.type().visit(new ConjureTypeParserVisitor(typeResolver)))
        .paramType(paramType)
        .docs(original.docs().map(Documentation::of))
        .markers(parseMarkers(original.markers(), typeResolver));
    resultBuilder.add(builder.build());
  }
  return resultBuilder.build();
}
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]");
}
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

@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

@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 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

  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 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);
}
com.palantir.conjure.specArgumentNameof

Popular methods of ArgumentName

  • get

Popular in Java

  • Making http post requests using okhttp
  • notifyDataSetChanged (ArrayAdapter)
  • findViewById (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • Format (java.text)
    The base class for all formats. This is an abstract base class which specifies the protocol for clas
  • Comparator (java.util)
    A Comparator is used to compare two objects to determine their ordering with respect to each other.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Best plugins for Eclipse
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