use of net.morimekta.providence.reflect.util.ProgramRegistry in project providence by morimekta.
the class CProgramTest method testProgram.
@Test
public void testProgram() {
ProgramRegistry registry = new ProgramRegistry();
CStructDescriptor declaredDesc = new CStructDescriptor(null, "prog", "Struct", ImmutableList.of(), ImmutableMap.of());
CService service = new CService("Documentation", "prog", "Service", null, ImmutableList.of(), ImmutableMap.of());
CConst constant = new CConst(null, "kC", PPrimitive.STRING.provider(), new ConstProvider(registry.registryForPath("prog.thrift"), "string", "prog", "\"value\"", 2, 10), ImmutableMap.of());
CProgram program = new CProgram("prog.thrift", "Documentation", "prog", ImmutableMap.of("java", "net.morimekta.providence", "cpp", "morimekta.providence"), ImmutableSet.of("first", "second"), ImmutableList.of("../something/first.thrift", "second.thrift"), ImmutableMap.of("S", "Struct"), ImmutableList.of(declaredDesc), ImmutableList.of(service), ImmutableList.of(constant));
assertThat(program.getDocumentation(), is("Documentation"));
assertThat(program.getProgramName(), is("prog"));
assertThat(program.getTypedefs().entrySet(), hasSize(1));
assertThat(program.getTypedefs().get("S"), is("Struct"));
assertThat(program.getConstants(), hasSize(1));
assertThat(program.getConstants(), hasItem(constant));
assertThat(program.getServices(), hasSize(1));
assertThat(program.getServices(), hasItem(service));
assertThat(program.getDeclaredTypes(), hasSize(1));
assertThat(program.getDeclaredTypes(), hasItem(declaredDesc));
assertThat(program.getNamespaceForLanguage("java"), is("net.morimekta.providence"));
assertThat(program.getNamespaceForLanguage("cpp"), is("morimekta.providence"));
}
Aggregations