Search in sources :

Example 31 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.

the class ConjureSourceFileValidatorTest method testArgumentMissingRequiredSafetyInformation.

@Test
public void testArgumentMissingRequiredSafetyInformation() {
    ConjureDefinition conjureDef = ConjureDefinition.builder().version(1).services(ServiceDefinition.builder().serviceName(TypeName.of("Service", "com.palantir.product")).endpoints(EndpointDefinition.builder().endpointName(EndpointName.of("end")).httpMethod(HttpMethod.PUT).httpPath(HttpPath.of("/path")).args(ArgumentDefinition.builder().argName(ArgumentName.of("arg")).type(Type.primitive(PrimitiveType.STRING)).paramType(ParameterType.body(BodyParameterType.of())).build()).build()).build()).build();
    assertThatThrownBy(() -> ConjureDefinitionValidator.validateAll(conjureDef, SafetyDeclarationRequirements.REQUIRED)).isInstanceOf(ConjureIllegalStateException.class).hasMessageContaining("Endpoint end argument arg must declare log safety");
}
Also used : ConjureIllegalStateException(com.palantir.conjure.exceptions.ConjureIllegalStateException) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) Test(org.junit.jupiter.api.Test)

Example 32 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.

the class ConjureSourceFileValidatorTest method testNoIllegalMapKeys_allowsExternalImport.

@Test
public void testNoIllegalMapKeys_allowsExternalImport() {
    ConjureDefinition conjureDef = ConjureDefinition.builder().version(1).types(TypeDefinition.object(ObjectDefinition.builder().typeName(FOO).fields(FieldDefinition.builder().fieldName(FieldName.of("bad")).type(Type.map(MapType.of(Type.external(ExternalReference.builder().externalReference(TypeName.of("Foo", "package")).fallback(Type.primitive(PrimitiveType.STRING)).build()), Type.primitive(PrimitiveType.STRING)))).docs(DOCS).build()).build())).build();
    assertThatCode(() -> ConjureDefinitionValidator.ILLEGAL_MAP_KEYS.validate(conjureDef)).describedAs("External imports may be used as map keys provided the fallback type is valid").doesNotThrowAnyException();
}
Also used : ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) Test(org.junit.jupiter.api.Test)

Example 33 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.

the class ConjureDefTest method resolvesImportedAliases.

@Test
public void resolvesImportedAliases() {
    ConjureDefinition conjureDefinition = ConjureParserUtils.parseConjureDef(ConjureParser.parseAnnotated(new File("src/test/resources/example-conjure-imports.yml")));
    assertThat(conjureDefinition.getTypes()).hasSize(3);
}
Also used : ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 34 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure-python by palantir.

the class ConjurePythonGeneratorTest method assertThatFilesRenderAsExpected.

@ConjureSubfolderRunner.Test
public void assertThatFilesRenderAsExpected(Path folder) throws IOException {
    Path expected = folder.resolve("expected");
    ConjureDefinition definition = getInputDefinitions(folder);
    maybeResetExpectedDirectory(expected, definition);
    generator.write(definition, pythonFileWriter);
    assertFoldersEqual(expected);
}
Also used : Path(java.nio.file.Path) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition)

Example 35 with ConjureDefinition

use of com.palantir.conjure.spec.ConjureDefinition in project conjure-postman by palantir.

the class ConjurePostmanGeneratorTest method assertThatFilesRenderAsExpected.

@ConjureSubfolderRunner.Test
public void assertThatFilesRenderAsExpected(Path folder) throws IOException {
    UuidProvider.setUseRandom(false);
    Path expected = folder.resolve("expected");
    ConjureDefinition definition = getInputDefinitions(folder);
    maybeResetExpectedDirectory(expected, definition);
    writer.write(generator.generate(definition));
    assertFoldersEqual(expected);
}
Also used : Path(java.nio.file.Path) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition)

Aggregations

ConjureDefinition (com.palantir.conjure.spec.ConjureDefinition)65 Test (org.junit.jupiter.api.Test)49 File (java.io.File)40 Path (java.nio.file.Path)30 ConjureIllegalStateException (com.palantir.conjure.exceptions.ConjureIllegalStateException)13 JerseyServiceGenerator (com.palantir.conjure.java.services.JerseyServiceGenerator)9 UndertowServiceGenerator (com.palantir.conjure.java.services.UndertowServiceGenerator)9 GenerationCoordinator (com.palantir.conjure.java.GenerationCoordinator)8 Retrofit2ServiceGenerator (com.palantir.conjure.java.services.Retrofit2ServiceGenerator)4 DialogueServiceGenerator (com.palantir.conjure.java.services.dialogue.DialogueServiceGenerator)4 AnnotatedConjureSourceFile (com.palantir.conjure.parser.AnnotatedConjureSourceFile)4 TypeDefinition (com.palantir.conjure.spec.TypeDefinition)4 BeforeAll (org.junit.jupiter.api.BeforeAll)4 TypeName (com.palantir.conjure.spec.TypeName)3 ImmutableList (com.google.common.collect.ImmutableList)2 ReferenceTypeResolver (com.palantir.conjure.defs.ConjureTypeParserVisitor.ReferenceTypeResolver)2 ConjureRuntimeException (com.palantir.conjure.exceptions.ConjureRuntimeException)2 ConjureSourceFile (com.palantir.conjure.parser.ConjureSourceFile)2 DefaultPostmanCollectionFileWriter (com.palantir.conjure.postman.writer.DefaultPostmanCollectionFileWriter)2 PostmanCollectionFileWriter (com.palantir.conjure.postman.writer.PostmanCollectionFileWriter)2