Search in sources :

Example 6 with GeneratorResult

use of com.linkedin.pegasus.generator.GeneratorResult in project rest.li by linkedin.

the class TestRestLiSnapshotExporter method testCircularSnapshot.

@Test
public void testCircularSnapshot() throws Exception {
    RestLiSnapshotExporter exporter = new RestLiSnapshotExporter();
    exporter.setResolverPath(resolverPath);
    assertEquals(outdir.list().length, 0);
    GeneratorResult result = exporter.export("circular", null, new String[] { moduleDir + FS + TEST_DIR + FS + "snapshot" }, new String[] { "com.linkedin.restli.tools.snapshot.circular" }, null, outdir.getAbsolutePath());
    String[] expectedFiles = { CIRCULAR_FILE };
    assertEquals(outdir.list().length, expectedFiles.length);
    assertEquals(result.getModifiedFiles().size(), expectedFiles.length);
    assertEquals(result.getTargetFiles().size(), expectedFiles.length);
    for (String file : expectedFiles) {
        String actualFile = outdir + FS + file;
        String expectedFile = SNAPSHOTS_DIR + FS + file;
        compareFiles(actualFile, expectedFile);
        assertTrue(result.getModifiedFiles().contains(new File(actualFile)));
        assertTrue(result.getTargetFiles().contains(new File(actualFile)));
    }
}
Also used : GeneratorResult(com.linkedin.pegasus.generator.GeneratorResult) File(java.io.File) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 7 with GeneratorResult

use of com.linkedin.pegasus.generator.GeneratorResult in project rest.li by linkedin.

the class TestRestLiSnapshotExporter method testSampleGreetingSnapshot.

@Test
public void testSampleGreetingSnapshot() throws Exception {
    RestLiSnapshotExporter exporter = new RestLiSnapshotExporter();
    exporter.setResolverPath(moduleDir + File.separator + "src" + File.separator + "test" + File.separator + PEGASUS_SUFFIX);
    assertEquals(outdir.list().length, 0);
    GeneratorResult result = exporter.export("sample", null, new String[] { moduleDir + FS + TEST_DIR }, new String[] { "com.linkedin.restli.tools.sample" }, null, outdir.getAbsolutePath());
    String[] expectedFiles = { GREETINGS_FILE };
    assertEquals(outdir.list().length, expectedFiles.length);
    assertEquals(result.getModifiedFiles().size(), expectedFiles.length);
    assertEquals(result.getTargetFiles().size(), expectedFiles.length);
    for (String file : expectedFiles) {
        String actualFile = outdir + FS + file;
        String expectedFile = SNAPSHOTS_DIR + FS + file;
        compareFiles(actualFile, expectedFile);
        assertTrue(result.getModifiedFiles().contains(new File(actualFile)));
        assertTrue(result.getTargetFiles().contains(new File(actualFile)));
    }
}
Also used : GeneratorResult(com.linkedin.pegasus.generator.GeneratorResult) File(java.io.File) Test(org.testng.annotations.Test) AfterTest(org.testng.annotations.AfterTest) BeforeTest(org.testng.annotations.BeforeTest)

Example 8 with GeneratorResult

use of com.linkedin.pegasus.generator.GeneratorResult in project rest.li by linkedin.

the class TestRestLiResourceModelExporter method testSampleGreeting.

@Test
public void testSampleGreeting() throws Exception {
    RestLiResourceModelExporter exporter = new RestLiResourceModelExporter();
    assertEquals(outdir.list().length, 0);
    GeneratorResult result = exporter.export(null, null, new String[] { moduleDir + FS + TEST_DIR }, new String[] { "com.linkedin.restli.tools.sample" }, null, outdir.getAbsolutePath());
    String[] expectedFiles = { GREETING_FILE };
    assertEquals(outdir.list().length, expectedFiles.length);
    assertEquals(result.getModifiedFiles().size(), expectedFiles.length);
    assertEquals(result.getTargetFiles().size(), expectedFiles.length);
    for (String file : expectedFiles) {
        String actualFile = outdir + FS + file;
        String expectedFile = moduleDir + FS + IDL_DIR + FS + file;
        compareFiles(actualFile, expectedFile);
        assertTrue(result.getModifiedFiles().contains(new File(actualFile)));
        assertTrue(result.getTargetFiles().contains(new File(actualFile)));
    }
}
Also used : GeneratorResult(com.linkedin.pegasus.generator.GeneratorResult) File(java.io.File) Test(org.testng.annotations.Test)

Aggregations

GeneratorResult (com.linkedin.pegasus.generator.GeneratorResult)8 File (java.io.File)6 Test (org.testng.annotations.Test)5 ResourceModel (com.linkedin.restli.internal.server.model.ResourceModel)3 ArrayList (java.util.ArrayList)3 AfterTest (org.testng.annotations.AfterTest)3 BeforeTest (org.testng.annotations.BeforeTest)3 DocsProvider (com.linkedin.restli.internal.server.model.ResourceModelEncoder.DocsProvider)2 RestLiApiBuilder (com.linkedin.restli.internal.server.model.RestLiApiBuilder)2 RestLiConfig (com.linkedin.restli.server.RestLiConfig)2 HashMap (java.util.HashMap)2 ResourceModelEncoder (com.linkedin.restli.internal.server.model.ResourceModelEncoder)1 ResourceSchema (com.linkedin.restli.restspec.ResourceSchema)1 DocletDocsProvider (com.linkedin.restli.tools.idlgen.DocletDocsProvider)1 MultiLanguageDocsProvider (com.linkedin.restli.tools.idlgen.MultiLanguageDocsProvider)1