use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.
the class ConjureSourceFileValidatorTest method testInvalidSafetyArgument_reference.
@Test
public void testInvalidSafetyArgument_reference() {
ConjureDefinition conjureDef = ConjureDefinition.builder().version(1).types(TypeDefinition.object(ObjectDefinition.builder().typeName(FOO).build())).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.reference(FOO)).paramType(ParameterType.body(BodyParameterType.of())).safety(LogSafety.UNSAFE).build()).build()).build()).build();
assertThatThrownBy(() -> ConjureDefinitionValidator.validateAll(conjureDef, SafetyDeclarationRequirements.ALLOWED)).isInstanceOf(IllegalStateException.class).hasMessageContaining("Service.end(arg): end cannot declare log safety. Only conjure primitives and wrappers around" + " conjure primitives may declare safety. package.Foo is not a primitive type.");
}
use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.
the class ConjureSourceFileValidatorTest method testNoSafetyOnComplexTypes.
@Test
public void testNoSafetyOnComplexTypes() {
ConjureDefinition conjureDef = ConjureDefinition.builder().version(1).types(TypeDefinition.alias(AliasDefinition.builder().typeName(TypeName.of("AliasName", "package")).alias(Type.list(ListType.of(Type.primitive(PrimitiveType.STRING)))).build())).types(TypeDefinition.object(ObjectDefinition.builder().typeName(FOO).fields(FieldDefinition.builder().fieldName(FieldName.of("bad")).type(Type.reference(TypeName.of("AliasName", "package"))).safety(LogSafety.UNSAFE).docs(DOCS).build()).build())).build();
assertThatThrownBy(() -> ConjureDefinitionValidator.validateAll(conjureDef, SafetyDeclarationRequirements.ALLOWED)).isInstanceOf(IllegalStateException.class).hasMessageContaining("Only conjure primitives and wrappers around conjure primitives may declare safety");
}
use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.
the class ConjureDefTest method resolvesCircularType_multiFile.
@Test
public void resolvesCircularType_multiFile() {
ConjureDefinition conjureDefinition = ConjureParserUtils.parseConjureDef(ConjureParser.parseAnnotated(ImmutableList.of(new File("src/test/resources/example-multi-file-circular-import-a.yml"), new File("src/test/resources/example-multi-file-circular-import-b.yml"))));
assertThat(conjureDefinition.getTypes()).hasSize(2);
}
use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.
the class ConjureDefTest method resolvesCircularType_singleFile.
@Test
public void resolvesCircularType_singleFile() {
ConjureDefinition conjureDefinition = ConjureParserUtils.parseConjureDef(ConjureParser.parseAnnotated(new File("src/test/resources/example-circular.yml")));
assertThat(conjureDefinition.getTypes()).hasSize(2);
}
use of com.palantir.conjure.spec.ConjureDefinition in project conjure by palantir.
the class ConjureDefTest method resolvesRecursiveImportType.
@Test
public void resolvesRecursiveImportType() {
ConjureDefinition conjureDefinition = ConjureParserUtils.parseConjureDef(ConjureParser.parseAnnotated(new File("src/test/resources/example-recursive-imports.yml")));
assertThat(conjureDefinition.getTypes()).hasSize(1);
}
Aggregations