TypeRegistry { TypeName resolveMessageType(String typeId) { return checkNotNull(typeMap.get(typeId), "Unable to resolve type id: " + typeId); } private  TypeRegistry();   }
@Test public void testRequiredTypeMap() { TypeRegistry map = RequestInfo.withTypeRegistry(TestRequestLoader.getRequiredRequest()).getTypeRegistry(); assertTrue(map.typeMap.size() >= 2); assertEquals("protos.test.protobuf.UnittestRequired.SimpleMessage", map.resolveMessageType(".quickbuf_unittest_import.SimpleMessage").toString()); assertEquals("protos.test.protobuf.UnittestRequired.TestAllTypesRequired", map.resolveMessageType(".quickbuf_unittest_import.TestAllTypesRequired").toString()); }
@Test public void testImportTypeMap() { CodeGeneratorRequest request = TestRequestLoader.getImportRequest(); TypeRegistry map = RequestInfo.withTypeRegistry(request).getTypeRegistry(); assertEquals(8, map.typeMap.entrySet().size()); assertEquals("protos.test.protobuf.ContainerMessage", map.resolveMessageType(".quickbuf_unittest.ContainerMessage").toString()); assertEquals("protos.test.protobuf.ForeignEnum", map.resolveMessageType(".quickbuf_unittest.ForeignEnum").toString()); String typeId = request .getProtoFile(1) .getMessageType(0) .getField(6) .getTypeName(); assertEquals("protos.test.protobuf.external.ImportMessage.NestedImportMessage", map.resolveMessageType(typeId).toString()); }
@Test public void testAllTypesTypeMap() { CodeGeneratorRequest request = TestRequestLoader.getAllTypesRequest(); TypeRegistry map = RequestInfo.withTypeRegistry(request).getTypeRegistry(); assertEquals(10, map.typeMap.entrySet().size()); assertEquals("protos.test.quickbuf.external.ImportMessage", map.resolveMessageType(".quickbuf_unittest_import.ImportMessage").toString()); assertEquals("protos.test.quickbuf.external.ImportMessage.NestedImportMessage", map.resolveMessageType(".quickbuf_unittest_import.ImportMessage.NestedImportMessage").toString()); assertEquals("protos.test.quickbuf.ForeignEnum", map.resolveMessageType(".quickbuf_unittest.ForeignEnum").toString()); }