Search in sources :

Example 1 with GenerationCoordinator

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);
}
Also used : Path(java.nio.file.Path) GenerationCoordinator(com.palantir.conjure.java.GenerationCoordinator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 2 with GenerationCoordinator

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);
}
Also used : Path(java.nio.file.Path) GenerationCoordinator(com.palantir.conjure.java.GenerationCoordinator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 3 with GenerationCoordinator

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);
}
Also used : Path(java.nio.file.Path) GenerationCoordinator(com.palantir.conjure.java.GenerationCoordinator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 4 with GenerationCoordinator

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);
}
Also used : Path(java.nio.file.Path) GenerationCoordinator(com.palantir.conjure.java.GenerationCoordinator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) Test(org.junit.jupiter.api.Test)

Example 5 with GenerationCoordinator

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();
}
Also used : GenerationCoordinator(com.palantir.conjure.java.GenerationCoordinator) ConjureDefinition(com.palantir.conjure.spec.ConjureDefinition) File(java.io.File) Test(org.junit.jupiter.api.Test)

Aggregations

GenerationCoordinator (com.palantir.conjure.java.GenerationCoordinator)8 ConjureDefinition (com.palantir.conjure.spec.ConjureDefinition)8 File (java.io.File)8 Test (org.junit.jupiter.api.Test)8 Path (java.nio.file.Path)7