use of com.palantir.conjure.java.GenerationCoordinator in project conjure-java by palantir.
the class ObjectGeneratorTests method testConjureErrors.
@Test
public void testConjureErrors() throws IOException {
ConjureDefinition def = Conjure.parse(ImmutableList.of(new File("src/test/resources/example-errors.yml"), new File("src/test/resources/example-errors-other.yml")));
List<Path> files = new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new ErrorGenerator(Options.builder().useImmutableBytes(true).excludeEmptyOptionals(true).build()))).emit(def, tempDir);
assertThatFilesAreTheSame(files, REFERENCE_FILES_FOLDER);
}
use of com.palantir.conjure.java.GenerationCoordinator in project conjure-java by palantir.
the class ObjectGeneratorTests method testObjectGenerator_allExamples.
@Test
public void testObjectGenerator_allExamples() throws IOException {
ConjureDefinition def = Conjure.parse(ImmutableList.of(new File("src/test/resources/example-types.yml")));
List<Path> files = new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new ObjectGenerator(Options.builder().useImmutableBytes(true).strictObjects(true).nonNullCollections(true).excludeEmptyOptionals(true).unionsWithUnknownValues(true).build()))).emit(def, tempDir);
assertThatFilesAreTheSame(files, REFERENCE_FILES_FOLDER);
}
use of com.palantir.conjure.java.GenerationCoordinator in project conjure-java by palantir.
the class ObjectGeneratorTests method testObjectGenerator_allExamples_with_prefix.
@Test
public void testObjectGenerator_allExamples_with_prefix() throws IOException {
ConjureDefinition def = Conjure.parse(ImmutableList.of(new File("src/test/resources/example-types.yml")));
List<Path> files = new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new ObjectGenerator(Options.builder().packagePrefix("test.prefix").excludeEmptyOptionals(true).build()))).emit(def, tempDir);
assertThatFilesAreTheSame(files, REFERENCE_FILES_FOLDER);
}
use of com.palantir.conjure.java.GenerationCoordinator in project conjure-java by palantir.
the class ObjectGeneratorTests method testObjectGenerator_byteBufferCompatibility.
@Test
public void testObjectGenerator_byteBufferCompatibility() throws IOException {
ConjureDefinition def = Conjure.parse(ImmutableList.of(new File("src/test/resources/example-binary-types.yml")));
List<Path> files = new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new ObjectGenerator(Options.builder().excludeEmptyOptionals(true).build()))).emit(def, tempDir);
assertThatFilesAreTheSame(files, REFERENCE_FILES_FOLDER);
}
use of com.palantir.conjure.java.GenerationCoordinator in project conjure-java by palantir.
the class ObjectGeneratorTests method testConjureImports.
@Test
public void testConjureImports() throws IOException {
ConjureDefinition conjure = Conjure.parse(ImmutableList.of(new File("src/test/resources/example-conjure-imports.yml"), new File("src/test/resources/example-types.yml"), new File("src/test/resources/example-service.yml")));
File src = Files.createDirectory(tempDir.toPath().resolve("src")).toFile();
new GenerationCoordinator(MoreExecutors.directExecutor(), ImmutableSet.of(new ObjectGenerator(Options.builder().useImmutableBytes(true).excludeEmptyOptionals(true).build()))).emit(conjure, src);
// Generated files contain imports
assertThat(compiledFileContent(src, "test/api/with/imports/ComplexObjectWithImports.java")).contains("import com.palantir.product.StringExample;");
// Imported files are not generated.
assertThat(new File(src, "com/palantir/foundry/catalog/api/datasets/BackingFileSystem.java")).doesNotExist();
assertThat(new File(src, "test/api/StringExample.java")).doesNotExist();
}
Aggregations