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");
}
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();
}
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);
}
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);
}
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);
}
Aggregations