Search in sources :

Example 16 with ProgramType

use of net.morimekta.providence.model.ProgramType in project providence by morimekta.

the class ThriftProgramParserTest method testAutoId.

@Test
public void testAutoId() throws IOException {
    copyResourceTo("/parser/tests/autoid.thrift", tmp.getRoot());
    File autoid = new File(tmp.getRoot(), "autoid.thrift");
    ThriftProgramParser parser = new ThriftProgramParser();
    ProgramType program = parser.parse(new FileInputStream(autoid), autoid, new TreeSet<>());
    assertEquals("{\n" + "  program_name = \"autoid\"\n" + "  namespaces = {\n" + "    \"java\": \"net.morimekta.test.autoid\"\n" + "  }\n" + "  decl = [\n" + "    {\n" + "      decl_struct = {\n" + "        variant = EXCEPTION\n" + "        name = \"AutoId\"\n" + "        fields = [\n" + "          {\n" + "            id = -1\n" + "            type = \"string\"\n" + "            name = \"message\"\n" + "          },\n" + "          {\n" + "            id = -2\n" + "            type = \"i32\"\n" + "            name = \"second\"\n" + "          }\n" + "        ]\n" + "      }\n" + "    },\n" + "    {\n" + "      decl_service = {\n" + "        name = \"AutoParam\"\n" + "        methods = [\n" + "          {\n" + "            return_type = \"i32\"\n" + "            name = \"method\"\n" + "            params = [\n" + "              {\n" + "                id = -1\n" + "                type = \"i32\"\n" + "                name = \"a\"\n" + "              },\n" + "              {\n" + "                id = -2\n" + "                type = \"i32\"\n" + "                name = \"b\"\n" + "              }\n" + "            ]\n" + "            exceptions = [\n" + "              {\n" + "                id = -1\n" + "                type = \"AutoId\"\n" + "                name = \"auto1\"\n" + "              }\n" + "            ]\n" + "          }\n" + "        ]\n" + "      }\n" + "    }\n" + "  ]\n" + "}", debugString(program));
}
Also used : ProgramType(net.morimekta.providence.model.ProgramType) File(java.io.File) FileInputStream(java.io.FileInputStream) Test(org.junit.Test)

Aggregations

ProgramType (net.morimekta.providence.model.ProgramType)16 File (java.io.File)14 FileInputStream (java.io.FileInputStream)11 Test (org.junit.Test)8 ThriftProgramParser (net.morimekta.providence.reflect.parser.ThriftProgramParser)4 Before (org.junit.Before)4 ArrayList (java.util.ArrayList)3 ProgramConverter (net.morimekta.providence.reflect.util.ProgramConverter)3 ProgramRegistry (net.morimekta.providence.reflect.util.ProgramRegistry)3 ConstType (net.morimekta.providence.model.ConstType)2 Declaration (net.morimekta.providence.model.Declaration)2 EnumType (net.morimekta.providence.model.EnumType)2 MessageType (net.morimekta.providence.model.MessageType)2 ServiceType (net.morimekta.providence.model.ServiceType)2 CProgram (net.morimekta.providence.reflect.contained.CProgram)2 ImmutableList (com.google.common.collect.ImmutableList)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 BufferedInputStream (java.io.BufferedInputStream)1 ByteArrayInputStream (java.io.ByteArrayInputStream)1 InputStream (java.io.InputStream)1